test for #2378
This commit is contained in:
parent
44c100c28d
commit
81caf926b4
10
src/test/auxiliary/issue2378a.rs
Normal file
10
src/test/auxiliary/issue2378a.rs
Normal file
@ -0,0 +1,10 @@
|
||||
enum maybe<T> { just(T), nothing }
|
||||
|
||||
impl methods<T:copy> for maybe<T> {
|
||||
fn [](idx: uint) -> T {
|
||||
alt self {
|
||||
just(t) { t }
|
||||
nothing { fail; }
|
||||
}
|
||||
}
|
||||
}
|
12
src/test/auxiliary/issue2378b.rs
Normal file
12
src/test/auxiliary/issue2378b.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use issue2378a;
|
||||
|
||||
import issue2378a::maybe;
|
||||
import issue2378a::methods;
|
||||
|
||||
type two_maybes<T> = {a: maybe<T>, b: maybe<T>};
|
||||
|
||||
impl methods<T:copy> for two_maybes<T> {
|
||||
fn [](idx: uint) -> (T, T) {
|
||||
(self.a[idx], self.b[idx])
|
||||
}
|
||||
}
|
14
src/test/run-pass/issue2378c.rs
Normal file
14
src/test/run-pass/issue2378c.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// xfail-test -- #2378 unfixed
|
||||
// aux-build:issue2378a.rs
|
||||
// aux-build:issue2378b.rs
|
||||
|
||||
use issue2378a;
|
||||
use issue2378b;
|
||||
|
||||
import issue2378a::{just, methods};
|
||||
import issue2378b::{methods};
|
||||
|
||||
fn main() {
|
||||
let x = {a: just(3), b: just(5)};
|
||||
assert x[0u] == (3, 5);
|
||||
}
|
Loading…
Reference in New Issue
Block a user