about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/core/tests/cmp.rs18
-rw-r--r--src/test/ui/consts/const-ordering.rs15
2 files changed, 17 insertions, 16 deletions
diff --git a/library/core/tests/cmp.rs b/library/core/tests/cmp.rs
index 4086917780f..835289daf71 100644
--- a/library/core/tests/cmp.rs
+++ b/library/core/tests/cmp.rs
@@ -1,4 +1,7 @@
-use core::cmp::{self, Ordering::*};
+use core::cmp::{
+    self,
+    Ordering::{self, *},
+};
 
 #[test]
 fn test_int_totalord() {
@@ -116,3 +119,16 @@ fn test_user_defined_eq() {
     assert!(SketchyNum { num: 37 } == SketchyNum { num: 34 });
     assert!(SketchyNum { num: 25 } != SketchyNum { num: 57 });
 }
+
+#[test]
+fn ordering_const() {
+    // test that the methods of `Ordering` are usable in a const context
+
+    const ORDERING: Ordering = Greater;
+
+    const REVERSE: Ordering = ORDERING.reverse();
+    assert_eq!(REVERSE, Less);
+
+    const THEN: Ordering = Equal.then(ORDERING);
+    assert_eq!(THEN, Greater);
+}
diff --git a/src/test/ui/consts/const-ordering.rs b/src/test/ui/consts/const-ordering.rs
deleted file mode 100644
index 454f2da00df..00000000000
--- a/src/test/ui/consts/const-ordering.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// run-pass
-
-use std::cmp::Ordering;
-
-// the following methods of core::cmp::Ordering are const:
-//  - reverse
-//  - then
-
-fn main() {
-    const REVERSE : Ordering = Ordering::Greater.reverse();
-    assert_eq!(REVERSE, Ordering::Less);
-
-    const THEN : Ordering = Ordering::Equal.then(REVERSE);
-    assert_eq!(THEN, Ordering::Less);
-}