Add test cases for const Location
This commit is contained in:
parent
4e3b9ed337
commit
834cab7244
3 changed files with 34 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
|||
#![feature(const_assume)]
|
||||
#![feature(const_black_box)]
|
||||
#![feature(const_bool_to_option)]
|
||||
#![feature(const_caller_location)]
|
||||
#![feature(const_cell_into_inner)]
|
||||
#![feature(const_convert)]
|
||||
#![feature(const_heap)]
|
||||
|
@ -131,6 +132,7 @@ mod num;
|
|||
mod ops;
|
||||
mod option;
|
||||
mod pattern;
|
||||
mod panic;
|
||||
mod pin;
|
||||
mod pin_macro;
|
||||
mod ptr;
|
||||
|
|
1
library/core/tests/panic.rs
Normal file
1
library/core/tests/panic.rs
Normal file
|
@ -0,0 +1 @@
|
|||
mod location;
|
31
library/core/tests/panic/location.rs
Normal file
31
library/core/tests/panic/location.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
use core::panic::Location;
|
||||
|
||||
// Note: Some of the following tests depend on the source location,
|
||||
// so please be careful when editing this file.
|
||||
|
||||
#[test]
|
||||
fn location_const_caller() {
|
||||
const _CALLER_REFERENCE: &Location<'static> = Location::caller();
|
||||
const _CALLER: Location<'static> = *Location::caller();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn location_const_file() {
|
||||
const CALLER: &Location<'static> = Location::caller();
|
||||
const FILE: &str = CALLER.file();
|
||||
assert_eq!(FILE, "library/core/tests/panic/location.rs");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn location_const_line() {
|
||||
const CALLER: &Location<'static> = Location::caller();
|
||||
const LINE: u32 = CALLER.line();
|
||||
assert_eq!(LINE, 21);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn location_const_column() {
|
||||
const CALLER: &Location<'static> = Location::caller();
|
||||
const COLUMN: u32 = CALLER.column();
|
||||
assert_eq!(COLUMN, 39);
|
||||
}
|
Loading…
Reference in a new issue