Skip to content

Commit

Permalink
Move const tests for Result to library\core
Browse files Browse the repository at this point in the history
Part of #76268
  • Loading branch information
CDirkx committed Sep 3, 2020
1 parent 518f1cc commit 787b270
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
16 changes: 16 additions & 0 deletions library/core/tests/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,19 @@ fn test_result_as_deref_mut() {
let expected_result = Result::Err::<&mut u32, &mut Vec<i32>>(&mut expected_vec);
assert_eq!(mut_err.as_deref_mut(), expected_result);
}

#[test]
fn result_const() {
// test that the methods of `Result` are usable in a const context

const RESULT: Result<usize, bool> = Ok(32);

const REF: Result<&usize, &bool> = RESULT.as_ref();
assert_eq!(REF, Ok(&32));

const IS_OK: bool = RESULT.is_ok();
assert!(IS_OK);

const IS_ERR: bool = RESULT.is_err();
assert!(!IS_ERR)
}
12 changes: 0 additions & 12 deletions src/test/ui/consts/const-result.rs

This file was deleted.

0 comments on commit 787b270

Please sign in to comment.