Skip to content

Commit 79d563c

Browse files
committed
Move const tests for Ordering to library\core
Part of #76268
1 parent ea5dc09 commit 79d563c

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

library/core/tests/cmp.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use core::cmp::{self, Ordering::*};
1+
use core::cmp::{
2+
self,
3+
Ordering::{self, *},
4+
};
25

36
#[test]
47
fn test_int_totalord() {
@@ -116,3 +119,16 @@ fn test_user_defined_eq() {
116119
assert!(SketchyNum { num: 37 } == SketchyNum { num: 34 });
117120
assert!(SketchyNum { num: 25 } != SketchyNum { num: 57 });
118121
}
122+
123+
#[test]
124+
fn ordering_const() {
125+
// test that the methods of `Ordering` are usable in a const context
126+
127+
const ORDERING: Ordering = Greater;
128+
129+
const REVERSE: Ordering = ORDERING.reverse();
130+
assert_eq!(REVERSE, Less);
131+
132+
const THEN: Ordering = Equal.then(ORDERING);
133+
assert_eq!(THEN, Greater);
134+
}

src/test/ui/consts/const-ordering.rs

-15
This file was deleted.

0 commit comments

Comments
 (0)