Move const tests for `Option` to `library\core`

Part of #76268
This commit is contained in:
Christiaan Dirkx 2020-09-04 00:13:25 +02:00 committed by Christiaan
parent 9486f72879
commit 4f859fbcfc
2 changed files with 16 additions and 12 deletions

View File

@ -356,3 +356,19 @@ fn test_replace() {
assert_eq!(x, Some(3));
assert_eq!(old, None);
}
#[test]
fn option_const() {
// test that the methods of `Option` are usable in a const context
const OPTION: Option<usize> = Some(32);
const REF: Option<&usize> = OPTION.as_ref();
assert_eq!(REF, Some(&32));
const IS_SOME: bool = OPTION.is_some();
assert!(IS_SOME);
const IS_NONE: bool = OPTION.is_none();
assert!(!IS_NONE);
}

View File

@ -1,12 +0,0 @@
// run-pass
const X: Option<i32> = Some(32);
const Y: Option<&i32> = X.as_ref();
const IS_SOME: bool = X.is_some();
const IS_NONE: bool = Y.is_none();
fn main() {
assert!(IS_SOME);
assert!(!IS_NONE)
}