mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Add some tests in number evaluvation and hover to prevent regression
Added a test near positive extermes and two test near negative extermes as well one for 0. Added a test using the `as` cast and one with comparison with 0.
This commit is contained in:
parent
b8017928af
commit
410ede9101
2 changed files with 84 additions and 0 deletions
|
@ -2018,6 +2018,57 @@ fn consts() {
|
||||||
"#,
|
"#,
|
||||||
6,
|
6,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
check_number(
|
||||||
|
r#"
|
||||||
|
const F1: i32 = 2147483647;
|
||||||
|
const F2: i32 = F1 - 25;
|
||||||
|
const GOAL: i32 = F2;
|
||||||
|
"#,
|
||||||
|
2147483622,
|
||||||
|
);
|
||||||
|
|
||||||
|
check_number(
|
||||||
|
r#"
|
||||||
|
const F1: i32 = -2147483648;
|
||||||
|
const F2: i32 = F1 + 18;
|
||||||
|
const GOAL: i32 = F2;
|
||||||
|
"#,
|
||||||
|
-2147483630,
|
||||||
|
);
|
||||||
|
|
||||||
|
check_number(
|
||||||
|
r#"
|
||||||
|
const F1: i32 = 10;
|
||||||
|
const F2: i32 = F1 - 20;
|
||||||
|
const GOAL: i32 = F2;
|
||||||
|
"#,
|
||||||
|
-10,
|
||||||
|
);
|
||||||
|
|
||||||
|
check_number(
|
||||||
|
r#"
|
||||||
|
const F1: i32 = 25;
|
||||||
|
const F2: i32 = F1 - 25;
|
||||||
|
const GOAL: i32 = F2;
|
||||||
|
"#,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
|
||||||
|
check_number(
|
||||||
|
r#"
|
||||||
|
const A: i32 = -2147483648;
|
||||||
|
const GOAL: bool = A > 0;
|
||||||
|
"#,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
|
||||||
|
check_number(
|
||||||
|
r#"
|
||||||
|
const GOAL: i64 = (-2147483648_i32) as i64;
|
||||||
|
"#,
|
||||||
|
-2147483648,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -779,6 +779,39 @@ const foo$0: u32 = {
|
||||||
```
|
```
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
check(
|
||||||
|
r#"const FOO$0: i32 = -2147483648;"#,
|
||||||
|
expect![[r#"
|
||||||
|
*FOO*
|
||||||
|
|
||||||
|
```rust
|
||||||
|
test
|
||||||
|
```
|
||||||
|
|
||||||
|
```rust
|
||||||
|
const FOO: i32 = -2147483648 (0x80000000)
|
||||||
|
```
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
const FOO: i32 = -2147483648;
|
||||||
|
const BAR$0: bool = FOO > 0;
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
*BAR*
|
||||||
|
|
||||||
|
```rust
|
||||||
|
test
|
||||||
|
```
|
||||||
|
|
||||||
|
```rust
|
||||||
|
const BAR: bool = false
|
||||||
|
```
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue