about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristiaan Dirkx <christiaan@dirkx.email>2020-09-04 00:40:11 +0200
committerChristiaan Dirkx <christiaan@dirkx.email>2020-09-04 00:40:11 +0200
commit79d563c819483eaf6e67b6aaaef9d0ca6030337d (patch)
treedd5fa943550f060c1eb76e549437f68cae3ef39c
parentea5dc0909ea1ed4135f1bdecbaa3423051be578d (diff)
downloadrust-79d563c819483eaf6e67b6aaaef9d0ca6030337d.tar.gz
rust-79d563c819483eaf6e67b6aaaef9d0ca6030337d.zip
Move const tests for `Ordering` to `library\core`
Part of #76268
-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);
-}