Rollup merge of #139889 - spencer3035:clean-ui-tests-3-of-n, r=jieyouxu
Clean UI tests 3 of n Cleaned up 2 tests in `tests/ui/numbers-arithemetic` to be more useful. One for each commit. I can squash these into one commit when approved. Related Issues: #73494 #133895 r? jieyouxu
This commit is contained in:
commit
afb60d3097
4 changed files with 50 additions and 12 deletions
|
@ -1,6 +0,0 @@
|
|||
//@ run-pass
|
||||
|
||||
|
||||
|
||||
|
||||
pub fn main() { let _x: isize = 10; }
|
25
tests/ui/numbers-arithmetic/isize-base.rs
Normal file
25
tests/ui/numbers-arithmetic/isize-base.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
//! Tests basic `isize` functionality
|
||||
|
||||
//@ run-pass
|
||||
|
||||
pub fn main() {
|
||||
// Literal matches assignment type
|
||||
let a: isize = 42isize;
|
||||
// Literal cast
|
||||
let b: isize = 42 as isize;
|
||||
// Literal type inference from assignment type
|
||||
let c: isize = 42;
|
||||
// Assignment type inference from literal (and later comparison)
|
||||
let d = 42isize;
|
||||
// Function return value type inference
|
||||
let e = return_val();
|
||||
|
||||
assert_eq!(a, b);
|
||||
assert_eq!(a, c);
|
||||
assert_eq!(a, d);
|
||||
assert_eq!(a, e);
|
||||
}
|
||||
|
||||
fn return_val() -> isize {
|
||||
42
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
//@ run-pass
|
||||
|
||||
|
||||
|
||||
|
||||
pub fn main() { let _x: usize = 10 as usize; }
|
25
tests/ui/numbers-arithmetic/usize-base.rs
Normal file
25
tests/ui/numbers-arithmetic/usize-base.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
//! Tests basic `usize` functionality
|
||||
|
||||
//@ run-pass
|
||||
|
||||
pub fn main() {
|
||||
// Literal matches assignment type
|
||||
let a: usize = 42usize;
|
||||
// Literal cast
|
||||
let b: usize = 42 as usize;
|
||||
// Literal type inference from assignment type
|
||||
let c: usize = 42;
|
||||
// Assignment type inference from literal (and later comparison)
|
||||
let d = 42usize;
|
||||
// Function return value type inference
|
||||
let e = return_val();
|
||||
|
||||
assert_eq!(a, b);
|
||||
assert_eq!(a, c);
|
||||
assert_eq!(a, d);
|
||||
assert_eq!(a, e);
|
||||
}
|
||||
|
||||
fn return_val() -> usize {
|
||||
42
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue