Move const tests for Ordering to library\core

Part of #76268
This commit is contained in:
Christiaan Dirkx 2020-09-04 00:40:11 +02:00
parent ea5dc0909e
commit 79d563c819
2 changed files with 17 additions and 16 deletions

View File

@ -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);
}

View File

@ -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);
}