about summary refs log tree commit diff
path: root/src/test/run-pass/trait-inheritance-overloading-simple.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/run-pass/trait-inheritance-overloading-simple.rs')
-rw-r--r--src/test/run-pass/trait-inheritance-overloading-simple.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/run-pass/trait-inheritance-overloading-simple.rs b/src/test/run-pass/trait-inheritance-overloading-simple.rs
new file mode 100644
index 00000000000..13867eed52f
--- /dev/null
+++ b/src/test/run-pass/trait-inheritance-overloading-simple.rs
@@ -0,0 +1,25 @@
+use cmp::Eq;
+
+trait MyNum : Eq { }
+
+struct MyInt { val: int }
+
+impl MyInt : Eq {
+    pure fn eq(&self, other: &MyInt) -> bool { self.val == other.val }
+    pure fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
+}
+
+impl MyInt : MyNum;
+
+fn f<T:MyNum>(x: T, y: T) -> bool {
+    return x == y;
+}
+
+pure fn mi(v: int) -> MyInt { MyInt { val: v } }
+
+fn main() {
+    let (x, y, z) = (mi(3), mi(5), mi(3));
+    assert x != y;
+    assert x == z;
+}
+