parent
ea5dc0909e
commit
79d563c819
2 changed files with 17 additions and 16 deletions
|
@ -1,4 +1,7 @@
|
||||||
use core::cmp::{self, Ordering::*};
|
use core::cmp::{
|
||||||
|
self,
|
||||||
|
Ordering::{self, *},
|
||||||
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_int_totalord() {
|
fn test_int_totalord() {
|
||||||
|
@ -116,3 +119,16 @@ fn test_user_defined_eq() {
|
||||||
assert!(SketchyNum { num: 37 } == SketchyNum { num: 34 });
|
assert!(SketchyNum { num: 37 } == SketchyNum { num: 34 });
|
||||||
assert!(SketchyNum { num: 25 } != SketchyNum { num: 57 });
|
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…
Add table
Add a link
Reference in a new issue