diff options
| author | Michael Sullivan <sully@msully.net> | 2013-07-11 15:08:43 -0700 |
|---|---|---|
| committer | Michael Sullivan <sully@msully.net> | 2013-07-11 15:51:10 -0700 |
| commit | 186f6faf1e6f4b507d97fefcb02fd8a7cf8d716f (patch) | |
| tree | b5b0c24a133e581034649a3498699e5d68d61a2b /src/test | |
| parent | 1bbb4348806dab6d9b4c280d4cfd324645969eca (diff) | |
| download | rust-186f6faf1e6f4b507d97fefcb02fd8a7cf8d716f.tar.gz rust-186f6faf1e6f4b507d97fefcb02fd8a7cf8d716f.zip | |
Get cross crate static default methods working. Closes #7569.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/auxiliary/trait_default_method_xc_aux.rs | 4 | ||||
| -rw-r--r-- | src/test/run-pass/trait-default-method-xc.rs | 19 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/test/auxiliary/trait_default_method_xc_aux.rs b/src/test/auxiliary/trait_default_method_xc_aux.rs index 7ae648f113a..6bd679f1304 100644 --- a/src/test/auxiliary/trait_default_method_xc_aux.rs +++ b/src/test/auxiliary/trait_default_method_xc_aux.rs @@ -5,7 +5,8 @@ pub struct Something { x: int } pub trait A { fn f(&self) -> int; fn g(&self) -> int { 10 } - fn h(&self) -> int { 10 } + fn h(&self) -> int { 11 } + fn lurr(x: &Self, y: &Self) -> int { x.g() + y.h() } } @@ -19,6 +20,7 @@ impl A for Something { trait B<T> { fn thing<U>(&self, x: T, y: U) -> (T, U) { (x, y) } + fn staticthing<U>(z: &Self, x: T, y: U) -> (T, U) { (x, y) } } impl<T> B<T> for int { } diff --git a/src/test/run-pass/trait-default-method-xc.rs b/src/test/run-pass/trait-default-method-xc.rs index 4eac1a1e730..f31b46c3339 100644 --- a/src/test/run-pass/trait-default-method-xc.rs +++ b/src/test/run-pass/trait-default-method-xc.rs @@ -4,13 +4,17 @@ #[allow(default_methods)]; extern mod aux(name = "trait_default_method_xc_aux"); -use aux::{A, B, TestEquality, Something}; - +use aux::{A, TestEquality, Something}; +use aux::B; fn f<T: aux::A>(i: T) { assert_eq!(i.g(), 10); } +fn welp<T>(i: int, x: &T) -> int { + i.g() +} + mod stuff { pub struct thing { x: int } } @@ -43,23 +47,26 @@ fn main () { // Some tests of random things f(0); + assert_eq!(A::lurr(&0, &1), 21); + let a = stuff::thing { x: 0 }; let b = stuff::thing { x: 1 }; let c = Something { x: 1 }; assert_eq!(0i.g(), 10); assert_eq!(a.g(), 10); - assert_eq!(a.h(), 10); - assert_eq!(c.h(), 10); + assert_eq!(a.h(), 11); + assert_eq!(c.h(), 11); - 0i.thing(3.14, 1); assert_eq!(0i.thing(3.14, 1), (3.14, 1)); + assert_eq!(B::staticthing(&0i, 3.14, 1), (3.14, 1)); + assert_eq!(B::staticthing::<float, int, int>(&0i, 3.14, 1), (3.14, 1)); assert_eq!(g(0i, 3.14, 1), (3.14, 1)); assert_eq!(g(false, 3.14, 1), (3.14, 1)); let obj = @0i as @A; - assert_eq!(obj.h(), 10); + assert_eq!(obj.h(), 11); // Trying out a real one |
