-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
const
-ness tests for i32::signum
- Loading branch information
1 parent
bd899d0
commit f6611db
Showing
1 changed file
with
12 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
#![feature(const_int_sign)] | ||
|
||
const NEGATIVE_A: bool = (-10i32).is_negative(); | ||
const NEGATIVE_B: bool = 10i32.is_negative(); | ||
const POSITIVE_A: bool= (-10i32).is_positive(); | ||
const POSITIVE_B: bool= 10i32.is_positive(); | ||
const POSITIVE_A: bool = (-10i32).is_positive(); | ||
const POSITIVE_B: bool = 10i32.is_positive(); | ||
|
||
const SIGNUM_POS: i32 = 10i32.signum(); | ||
const SIGNUM_NIL: i32 = 0i32.signum(); | ||
const SIGNUM_NEG: i32 = (-42i32).signum(); | ||
|
||
fn main() { | ||
assert!(NEGATIVE_A); | ||
assert!(!NEGATIVE_B); | ||
assert!(!POSITIVE_A); | ||
assert!(POSITIVE_B); | ||
|
||
assert_eq!(SIGNUM_POS, 1); | ||
assert_eq!(SIGNUM_NIL, 0); | ||
assert_eq!(SIGNUM_NEG, -1); | ||
} |