mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
parent
ea5dc0909e
commit
79d563c819
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user