Skip to content

Commit e2c09fa

Browse files
committed
Got test cases to pass, after some major surgery
1 parent 32840a4 commit e2c09fa

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

src/test/auxiliary/issue2378a.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[link (name = "issue2378a")];
12+
#[crate_type = "lib"];
13+
1114
enum maybe<T> { just(T), nothing }
1215

13-
impl copy> for maybe<T> for methods<T {
14-
fn ~[](idx: uint) -> T {
16+
impl <T:Copy> Index<uint,T> for maybe<T> {
17+
fn index(&self, idx: &uint) -> T {
1518
match self {
16-
just(t) { t }
17-
nothing { fail!(); }
19+
&just(ref t) => copy *t,
20+
&nothing => { fail!(); }
1821
}
1922
}
2023
}

src/test/auxiliary/issue2378b.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use issue2378a;
11+
#[link (name = "issue2378b")];
12+
#[crate_type = "lib"];
13+
14+
extern mod issue2378a;
1215

1316
use issue2378a::maybe;
14-
use issue2378a::methods;
1517

16-
type two_maybes<T> = {a: maybe<T>, b: maybe<T>};
18+
struct two_maybes<T> {a: maybe<T>, b: maybe<T>}
1719

18-
impl copy> for two_maybes<T> for methods<T {
19-
fn ~[](idx: uint) -> (T, T) {
20-
(self.a[idx], self.b[idx])
20+
impl <T:Copy> Index<uint,(T,T)> for two_maybes<T> {
21+
fn index(&self, idx: &uint) -> (T, T) {
22+
(self.a[*idx], self.b[*idx])
2123
}
2224
}

src/test/run-pass/issue2378c.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// xfail-test -- #2378 unfixed
1211
// aux-build:issue2378a.rs
1312
// aux-build:issue2378b.rs
1413

15-
use issue2378a;
16-
use issue2378b;
14+
extern mod issue2378a;
15+
extern mod issue2378b;
1716

18-
use issue2378a::{just, methods};
19-
use issue2378b::{methods};
17+
use issue2378a::{just};
18+
use issue2378b::{two_maybes};
2019

2120
pub fn main() {
22-
let x = {a: just(3), b: just(5)};
21+
let x = two_maybes{a: just(3), b: just(5)};
2322
assert!(x[0u] == (3, 5));
2423
}

0 commit comments

Comments
 (0)