Skip to content

Commit b9b42e8

Browse files
committed
tests: add hover tests for const generics
1 parent 4cbf23c commit b9b42e8

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

crates/ide/src/hover/tests.rs

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,6 +2958,106 @@ struct S$0T<const C: usize = 1, T = Foo>(T);
29582958
);
29592959
}
29602960

2961+
#[test]
2962+
fn const_generic_positive_i8_literal() {
2963+
check(
2964+
r#"
2965+
struct Const<const N: i8>;
2966+
2967+
fn main() {
2968+
let v$0alue = Const::<1>;
2969+
}
2970+
"#,
2971+
expect![[r#"
2972+
*value*
2973+
2974+
```rust
2975+
let value: Const<1>
2976+
```
2977+
"#]],
2978+
);
2979+
}
2980+
2981+
#[test]
2982+
fn const_generic_zero_i8_literal() {
2983+
check(
2984+
r#"
2985+
struct Const<const N: i8>;
2986+
2987+
fn main() {
2988+
let v$0alue = Const::<0>;
2989+
}
2990+
"#,
2991+
expect![[r#"
2992+
*value*
2993+
2994+
```rust
2995+
let value: Const<0>
2996+
```
2997+
"#]],
2998+
);
2999+
}
3000+
3001+
#[test]
3002+
fn const_generic_negative_i8_literal() {
3003+
check(
3004+
r#"
3005+
struct Const<const N: i8>;
3006+
3007+
fn main() {
3008+
let v$0alue = Const::<-1>;
3009+
}
3010+
"#,
3011+
expect![[r#"
3012+
*value*
3013+
3014+
```rust
3015+
let value: Const<-1>
3016+
```
3017+
"#]],
3018+
);
3019+
}
3020+
3021+
#[test]
3022+
fn const_generic_bool_literal() {
3023+
check(
3024+
r#"
3025+
struct Const<const F: bool>;
3026+
3027+
fn main() {
3028+
let v$0alue = Const::<true>;
3029+
}
3030+
"#,
3031+
expect![[r#"
3032+
*value*
3033+
3034+
```rust
3035+
let value: Const<true>
3036+
```
3037+
"#]],
3038+
);
3039+
}
3040+
3041+
#[test]
3042+
fn const_generic_char_literal() {
3043+
check(
3044+
r#"
3045+
struct Const<const C: char>;
3046+
3047+
fn main() {
3048+
let v$0alue = Const::<'🦀'>;
3049+
}
3050+
"#,
3051+
expect![[r#"
3052+
*value*
3053+
3054+
```rust
3055+
let value: Const<'🦀'>
3056+
```
3057+
"#]],
3058+
);
3059+
}
3060+
29613061
#[test]
29623062
fn hover_self_param_shows_type() {
29633063
check(

0 commit comments

Comments
 (0)