about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2014-02-24 08:11:00 -0500
committerDaniel Micay <danielmicay@gmail.com>2014-03-07 22:45:22 -0500
commit4d7d101a76deea69e9078d9ed6bb93ecca70e52a (patch)
tree3365108e59d5c6d4ee0655347ce3ed447cc7d016 /src/test
parent33768c46ec980a911284d77804e5e45ead6530eb (diff)
downloadrust-4d7d101a76deea69e9078d9ed6bb93ecca70e52a.tar.gz
rust-4d7d101a76deea69e9078d9ed6bb93ecca70e52a.zip
create a sensible comparison trait hierarchy
* `Ord` inherits from `Eq`
* `TotalOrd` inherits from `TotalEq`
* `TotalOrd` inherits from `Ord`
* `TotalEq` inherits from `Eq`

This is a partial implementation of #12517.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/bench/shootout-k-nucleotide.rs2
-rw-r--r--src/test/compile-fail/deriving-span-Ord-enum-struct-variant.rs4
-rw-r--r--src/test/compile-fail/deriving-span-Ord-enum.rs4
-rw-r--r--src/test/compile-fail/deriving-span-Ord-struct.rs4
-rw-r--r--src/test/compile-fail/deriving-span-Ord-tuple-struct.rs4
-rw-r--r--src/test/compile-fail/deriving-span-TotalEq-enum-struct-variant.rs4
-rw-r--r--src/test/compile-fail/deriving-span-TotalEq-enum.rs4
-rw-r--r--src/test/compile-fail/deriving-span-TotalEq-struct.rs4
-rw-r--r--src/test/compile-fail/deriving-span-TotalEq-tuple-struct.rs4
-rw-r--r--src/test/compile-fail/deriving-span-TotalOrd-enum-struct-variant.rs4
-rw-r--r--src/test/compile-fail/deriving-span-TotalOrd-enum.rs4
-rw-r--r--src/test/compile-fail/deriving-span-TotalOrd-struct.rs4
-rw-r--r--src/test/compile-fail/deriving-span-TotalOrd-tuple-struct.rs4
-rw-r--r--src/test/compile-fail/issue-3344.rs1
-rw-r--r--src/test/run-pass/cmp-default.rs16
-rw-r--r--src/test/run-pass/vector-sort-failure-safe.rs2
16 files changed, 43 insertions, 26 deletions
diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs
index a8f3489cb87..2ddea19b4c9 100644
--- a/src/test/bench/shootout-k-nucleotide.rs
+++ b/src/test/bench/shootout-k-nucleotide.rs
@@ -26,7 +26,7 @@ static OCCURRENCES: [&'static str, ..5] = [
 
 // Code implementation
 
-#[deriving(Eq, TotalOrd, TotalEq)]
+#[deriving(Eq, Ord, TotalOrd, TotalEq)]
 struct Code(u64);
 
 impl Code {
diff --git a/src/test/compile-fail/deriving-span-Ord-enum-struct-variant.rs b/src/test/compile-fail/deriving-span-Ord-enum-struct-variant.rs
index e3e442e70cf..319ba14c31c 100644
--- a/src/test/compile-fail/deriving-span-Ord-enum-struct-variant.rs
+++ b/src/test/compile-fail/deriving-span-Ord-enum-struct-variant.rs
@@ -13,10 +13,10 @@
 #[feature(struct_variant)];
 extern crate extra;
 
-
+#[deriving(Eq)]
 struct Error;
 
-#[deriving(Ord)]
+#[deriving(Eq, Ord)]
 enum Enum {
    A {
      x: Error //~ ERROR
diff --git a/src/test/compile-fail/deriving-span-Ord-enum.rs b/src/test/compile-fail/deriving-span-Ord-enum.rs
index 41e6c2c9e8d..0067546d1aa 100644
--- a/src/test/compile-fail/deriving-span-Ord-enum.rs
+++ b/src/test/compile-fail/deriving-span-Ord-enum.rs
@@ -13,10 +13,10 @@
 #[feature(struct_variant)];
 extern crate extra;
 
-
+#[deriving(Eq)]
 struct Error;
 
-#[deriving(Ord)]
+#[deriving(Eq, Ord)]
 enum Enum {
    A(
      Error //~ ERROR
diff --git a/src/test/compile-fail/deriving-span-Ord-struct.rs b/src/test/compile-fail/deriving-span-Ord-struct.rs
index 2caf68a26fc..a64f51f142d 100644
--- a/src/test/compile-fail/deriving-span-Ord-struct.rs
+++ b/src/test/compile-fail/deriving-span-Ord-struct.rs
@@ -13,10 +13,10 @@
 #[feature(struct_variant)];
 extern crate extra;
 
-
+#[deriving(Eq)]
 struct Error;
 
-#[deriving(Ord)]
+#[deriving(Eq, Ord)]
 struct Struct {
     x: Error //~ ERROR
 //~^ ERROR
diff --git a/src/test/compile-fail/deriving-span-Ord-tuple-struct.rs b/src/test/compile-fail/deriving-span-Ord-tuple-struct.rs
index c783befa391..d289a426932 100644
--- a/src/test/compile-fail/deriving-span-Ord-tuple-struct.rs
+++ b/src/test/compile-fail/deriving-span-Ord-tuple-struct.rs
@@ -13,10 +13,10 @@
 #[feature(struct_variant)];
 extern crate extra;
 
-
+#[deriving(Eq)]
 struct Error;
 
-#[deriving(Ord)]
+#[deriving(Eq, Ord)]
 struct Struct(
     Error //~ ERROR
 //~^ ERROR
diff --git a/src/test/compile-fail/deriving-span-TotalEq-enum-struct-variant.rs b/src/test/compile-fail/deriving-span-TotalEq-enum-struct-variant.rs
index f054e9e7e77..7fc030bdb36 100644
--- a/src/test/compile-fail/deriving-span-TotalEq-enum-struct-variant.rs
+++ b/src/test/compile-fail/deriving-span-TotalEq-enum-struct-variant.rs
@@ -13,10 +13,10 @@
 #[feature(struct_variant)];
 extern crate extra;
 
-
+#[deriving(Eq)]
 struct Error;
 
-#[deriving(TotalEq)]
+#[deriving(Eq, TotalEq)]
 enum Enum {
    A {
      x: Error //~ ERROR
diff --git a/src/test/compile-fail/deriving-span-TotalEq-enum.rs b/src/test/compile-fail/deriving-span-TotalEq-enum.rs
index 38b8d55bcd8..166311e030b 100644
--- a/src/test/compile-fail/deriving-span-TotalEq-enum.rs
+++ b/src/test/compile-fail/deriving-span-TotalEq-enum.rs
@@ -13,10 +13,10 @@
 #[feature(struct_variant)];
 extern crate extra;
 
-
+#[deriving(Eq)]
 struct Error;
 
-#[deriving(TotalEq)]
+#[deriving(Eq, TotalEq)]
 enum Enum {
    A(
      Error //~ ERROR
diff --git a/src/test/compile-fail/deriving-span-TotalEq-struct.rs b/src/test/compile-fail/deriving-span-TotalEq-struct.rs
index 66e5ef57a00..f96c41a3865 100644
--- a/src/test/compile-fail/deriving-span-TotalEq-struct.rs
+++ b/src/test/compile-fail/deriving-span-TotalEq-struct.rs
@@ -13,10 +13,10 @@
 #[feature(struct_variant)];
 extern crate extra;
 
-
+#[deriving(Eq)]
 struct Error;
 
-#[deriving(TotalEq)]
+#[deriving(Eq, TotalEq)]
 struct Struct {
     x: Error //~ ERROR
 }
diff --git a/src/test/compile-fail/deriving-span-TotalEq-tuple-struct.rs b/src/test/compile-fail/deriving-span-TotalEq-tuple-struct.rs
index dd0be2dc04a..4b825adb8cf 100644
--- a/src/test/compile-fail/deriving-span-TotalEq-tuple-struct.rs
+++ b/src/test/compile-fail/deriving-span-TotalEq-tuple-struct.rs
@@ -13,10 +13,10 @@
 #[feature(struct_variant)];
 extern crate extra;
 
-
+#[deriving(Eq)]
 struct Error;
 
-#[deriving(TotalEq)]
+#[deriving(Eq, TotalEq)]
 struct Struct(
     Error //~ ERROR
 );
diff --git a/src/test/compile-fail/deriving-span-TotalOrd-enum-struct-variant.rs b/src/test/compile-fail/deriving-span-TotalOrd-enum-struct-variant.rs
index 76bcd332562..7be90a2aa76 100644
--- a/src/test/compile-fail/deriving-span-TotalOrd-enum-struct-variant.rs
+++ b/src/test/compile-fail/deriving-span-TotalOrd-enum-struct-variant.rs
@@ -13,10 +13,10 @@
 #[feature(struct_variant)];
 extern crate extra;
 
-#[deriving(TotalEq)]
+#[deriving(Eq, Ord, TotalEq)]
 struct Error;
 
-#[deriving(TotalOrd,TotalEq)]
+#[deriving(Eq, Ord, TotalOrd,TotalEq)]
 enum Enum {
    A {
      x: Error //~ ERROR
diff --git a/src/test/compile-fail/deriving-span-TotalOrd-enum.rs b/src/test/compile-fail/deriving-span-TotalOrd-enum.rs
index 303e35108fe..ba97b28d18c 100644
--- a/src/test/compile-fail/deriving-span-TotalOrd-enum.rs
+++ b/src/test/compile-fail/deriving-span-TotalOrd-enum.rs
@@ -13,10 +13,10 @@
 #[feature(struct_variant)];
 extern crate extra;
 
-#[deriving(TotalEq)]
+#[deriving(Eq, Ord, TotalEq)]
 struct Error;
 
-#[deriving(TotalOrd,TotalEq)]
+#[deriving(Eq, Ord, TotalOrd,TotalEq)]
 enum Enum {
    A(
      Error //~ ERROR
diff --git a/src/test/compile-fail/deriving-span-TotalOrd-struct.rs b/src/test/compile-fail/deriving-span-TotalOrd-struct.rs
index bbcc3ae7e04..014a5b97e36 100644
--- a/src/test/compile-fail/deriving-span-TotalOrd-struct.rs
+++ b/src/test/compile-fail/deriving-span-TotalOrd-struct.rs
@@ -13,10 +13,10 @@
 #[feature(struct_variant)];
 extern crate extra;
 
-#[deriving(TotalEq)]
+#[deriving(Eq, Ord, TotalEq)]
 struct Error;
 
-#[deriving(TotalOrd,TotalEq)]
+#[deriving(Eq, Ord, TotalOrd,TotalEq)]
 struct Struct {
     x: Error //~ ERROR
 }
diff --git a/src/test/compile-fail/deriving-span-TotalOrd-tuple-struct.rs b/src/test/compile-fail/deriving-span-TotalOrd-tuple-struct.rs
index 4e8697749e7..7e4d5b2201b 100644
--- a/src/test/compile-fail/deriving-span-TotalOrd-tuple-struct.rs
+++ b/src/test/compile-fail/deriving-span-TotalOrd-tuple-struct.rs
@@ -13,10 +13,10 @@
 #[feature(struct_variant)];
 extern crate extra;
 
-#[deriving(TotalEq)]
+#[deriving(Eq, Ord, TotalEq)]
 struct Error;
 
-#[deriving(TotalOrd,TotalEq)]
+#[deriving(Eq, Ord, TotalOrd,TotalEq)]
 struct Struct(
     Error //~ ERROR
 );
diff --git a/src/test/compile-fail/issue-3344.rs b/src/test/compile-fail/issue-3344.rs
index 88414dddd66..e79a5871e70 100644
--- a/src/test/compile-fail/issue-3344.rs
+++ b/src/test/compile-fail/issue-3344.rs
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#[deriving(Eq)]
 struct thing(uint);
 impl Ord for thing { //~ ERROR not all trait methods implemented, missing: `lt`
     fn le(&self, other: &thing) -> bool { true }
diff --git a/src/test/run-pass/cmp-default.rs b/src/test/run-pass/cmp-default.rs
index 3650564d929..2ab6a70839f 100644
--- a/src/test/run-pass/cmp-default.rs
+++ b/src/test/run-pass/cmp-default.rs
@@ -22,6 +22,14 @@ impl Eq for Fool {
 
 struct Int(int);
 
+impl Eq for Int {
+    fn eq(&self, other: &Int) -> bool {
+        let Int(this) = *self;
+        let Int(other) = *other;
+        this == other
+    }
+}
+
 impl Ord for Int {
     fn lt(&self, other: &Int) -> bool {
         let Int(this) = *self;
@@ -32,6 +40,14 @@ impl Ord for Int {
 
 struct RevInt(int);
 
+impl Eq for RevInt {
+    fn eq(&self, other: &RevInt) -> bool {
+        let RevInt(this) = *self;
+        let RevInt(other) = *other;
+        this == other
+    }
+}
+
 impl Ord for RevInt {
     fn lt(&self, other: &RevInt) -> bool {
         let RevInt(this) = *self;
diff --git a/src/test/run-pass/vector-sort-failure-safe.rs b/src/test/run-pass/vector-sort-failure-safe.rs
index 74f27e48090..2c4a8aece19 100644
--- a/src/test/run-pass/vector-sort-failure-safe.rs
+++ b/src/test/run-pass/vector-sort-failure-safe.rs
@@ -15,7 +15,7 @@ static MAX_LEN: uint = 20;
 static mut drop_counts: [uint, .. MAX_LEN] = [0, .. MAX_LEN];
 static mut clone_count: uint = 0;
 
-#[deriving(Rand, Ord, TotalEq, TotalOrd)]
+#[deriving(Rand, Eq, Ord, TotalEq, TotalOrd)]
 struct DropCounter { x: uint, clone_num: uint }
 
 impl Clone for DropCounter {