about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosh Stone <cuviper@gmail.com>2019-03-27 18:15:32 -0700
committerGitHub <noreply@github.com>2019-03-27 18:15:32 -0700
commit413aaf3227be873d11aa47243489ea84b09c1500 (patch)
treea71d98d402e1266c9117d7708e0c5bcf7f696cb4
parent35b339bd5fbf678dd319c62ea1316a5d1160f0df (diff)
parentc709a10434ecfdaa9ec8b726a405fb0d027edd07 (diff)
downloadrust-413aaf3227be873d11aa47243489ea84b09c1500.tar.gz
rust-413aaf3227be873d11aa47243489ea84b09c1500.zip
Rollup merge of #59393 - czipperz:refactor_tuple_comparison_tests, r=shepmaster
Refactor tuple comparison tests
-rw-r--r--src/libcore/tests/tuple.rs44
1 files changed, 24 insertions, 20 deletions
diff --git a/src/libcore/tests/tuple.rs b/src/libcore/tests/tuple.rs
index a4c171eb424..c7ed1612dd5 100644
--- a/src/libcore/tests/tuple.rs
+++ b/src/libcore/tests/tuple.rs
@@ -1,4 +1,5 @@
 use std::cmp::Ordering::{Equal, Less, Greater};
+use std::f64::NAN;
 
 #[test]
 fn test_clone() {
@@ -8,18 +9,18 @@ fn test_clone() {
 }
 
 #[test]
-fn test_tuple_cmp() {
+fn test_partial_eq() {
     let (small, big) = ((1, 2, 3), (3, 2, 1));
-
-    let nan = 0.0f64/0.0;
-
-    // PartialEq
     assert_eq!(small, small);
     assert_eq!(big, big);
-    assert!(small != big);
-    assert!(big != small);
+    assert_ne!(small, big);
+    assert_ne!(big, small);
+}
+
+#[test]
+fn test_partial_ord() {
+    let (small, big) = ((1, 2, 3), (3, 2, 1));
 
-    // PartialOrd
     assert!(small < big);
     assert!(!(small < small));
     assert!(!(big < small));
@@ -33,18 +34,21 @@ fn test_tuple_cmp() {
     assert!(big >= small);
     assert!(big >= big);
 
-    assert!(!((1.0f64, 2.0f64) < (nan, 3.0)));
-    assert!(!((1.0f64, 2.0f64) <= (nan, 3.0)));
-    assert!(!((1.0f64, 2.0f64) > (nan, 3.0)));
-    assert!(!((1.0f64, 2.0f64) >= (nan, 3.0)));
-    assert!(((1.0f64, 2.0f64) < (2.0, nan)));
-    assert!(!((2.0f64, 2.0f64) < (2.0, nan)));
-
-    // Ord
-    assert!(small.cmp(&small) == Equal);
-    assert!(big.cmp(&big) == Equal);
-    assert!(small.cmp(&big) == Less);
-    assert!(big.cmp(&small) == Greater);
+    assert!(!((1.0f64, 2.0f64) < (NAN, 3.0)));
+    assert!(!((1.0f64, 2.0f64) <= (NAN, 3.0)));
+    assert!(!((1.0f64, 2.0f64) > (NAN, 3.0)));
+    assert!(!((1.0f64, 2.0f64) >= (NAN, 3.0)));
+    assert!(((1.0f64, 2.0f64) < (2.0, NAN)));
+    assert!(!((2.0f64, 2.0f64) < (2.0, NAN)));
+}
+
+#[test]
+fn test_ord() {
+    let (small, big) = ((1, 2, 3), (3, 2, 1));
+    assert_eq!(small.cmp(&small), Equal);
+    assert_eq!(big.cmp(&big), Equal);
+    assert_eq!(small.cmp(&big), Less);
+    assert_eq!(big.cmp(&small), Greater);
 }
 
 #[test]