diff options
| author | Spencer <spencer3035@gmail.com> | 2025-04-15 20:04:04 -0600 |
|---|---|---|
| committer | Spencer <spencer3035@gmail.com> | 2025-04-16 08:55:50 -0600 |
| commit | 7ce21e4fb39e9d288f3fe96ad48f8bc8ec973588 (patch) | |
| tree | c9d57648c8f4321bfa026529bc6de08d243dad5e /tests/ui/numbers-arithmetic | |
| parent | 38c560ae681d5c0d3fd615eaedc537a282fb1086 (diff) | |
| download | rust-7ce21e4fb39e9d288f3fe96ad48f8bc8ec973588.tar.gz rust-7ce21e4fb39e9d288f3fe96ad48f8bc8ec973588.zip | |
Cleaned up base tests for `isize` and `usize` in `tests/ui/numbers-arithmetic`
Diffstat (limited to 'tests/ui/numbers-arithmetic')
| -rw-r--r-- | tests/ui/numbers-arithmetic/int.rs | 6 | ||||
| -rw-r--r-- | tests/ui/numbers-arithmetic/isize-base.rs | 25 | ||||
| -rw-r--r-- | tests/ui/numbers-arithmetic/uint.rs | 6 | ||||
| -rw-r--r-- | tests/ui/numbers-arithmetic/usize-base.rs | 25 |
4 files changed, 50 insertions, 12 deletions
diff --git a/tests/ui/numbers-arithmetic/int.rs b/tests/ui/numbers-arithmetic/int.rs deleted file mode 100644 index 42f8e50d6ef..00000000000 --- a/tests/ui/numbers-arithmetic/int.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ run-pass - - - - -pub fn main() { let _x: isize = 10; } diff --git a/tests/ui/numbers-arithmetic/isize-base.rs b/tests/ui/numbers-arithmetic/isize-base.rs new file mode 100644 index 00000000000..412e7ac7a2e --- /dev/null +++ b/tests/ui/numbers-arithmetic/isize-base.rs @@ -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 +} diff --git a/tests/ui/numbers-arithmetic/uint.rs b/tests/ui/numbers-arithmetic/uint.rs deleted file mode 100644 index c2087b5a06c..00000000000 --- a/tests/ui/numbers-arithmetic/uint.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ run-pass - - - - -pub fn main() { let _x: usize = 10 as usize; } diff --git a/tests/ui/numbers-arithmetic/usize-base.rs b/tests/ui/numbers-arithmetic/usize-base.rs new file mode 100644 index 00000000000..833fc049798 --- /dev/null +++ b/tests/ui/numbers-arithmetic/usize-base.rs @@ -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 +} |
