Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/hover/tests.rs')
-rw-r--r--crates/ide/src/hover/tests.rs178
1 files changed, 178 insertions, 0 deletions
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index f4528dd754..f2e5d24fcc 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -8742,3 +8742,181 @@ fn foo() {
"#]],
);
}
+
+#[test]
+fn test_hover_function_with_pat_param() {
+ check(
+ r#"fn test_1$0((start_range, end_range): (u32, u32), a: i32) {}"#,
+ expect![[r#"
+ *test_1*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ fn test_1((start_range, end_range): (u32, u32), a: i32)
+ ```
+ "#]],
+ );
+
+ // Test case with tuple pattern and mutable parameters
+ check(
+ r#"fn test_2$0((mut x, y): (i32, i32)) {}"#,
+ expect![[r#"
+ *test_2*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ fn test_2((mut x, y): (i32, i32))
+ ```
+ "#]],
+ );
+
+ // Test case with a pattern in a reference type
+ check(
+ r#"fn test_3$0(&(a, b): &(i32, i32)) {}"#,
+ expect![[r#"
+ *test_3*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ fn test_3(&(a, b): &(i32, i32))
+ ```
+ "#]],
+ );
+
+ // Test case with complex pattern (struct destructuring)
+ check(
+ r#"struct Point { x: i32, y: i32 } fn test_4$0(Point { x, y }: Point) {}"#,
+ expect![[r#"
+ *test_4*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ fn test_4(Point { x, y }: Point)
+ ```
+ "#]],
+ );
+
+ // Test case with a nested pattern
+ check(
+ r#"fn test_5$0(((a, b), c): ((i32, i32), i32)) {}"#,
+ expect![[r#"
+ *test_5*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ fn test_5(((a, b), c): ((i32, i32), i32))
+ ```
+ "#]],
+ );
+
+ // Test case with an unused variable in the pattern
+ check(
+ r#"fn test_6$0((_, y): (i32, i64)) {}"#,
+ expect![[r#"
+ *test_6*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ fn test_6((_, y): (i32, i64))
+ ```
+ "#]],
+ );
+
+ // Test case with a complex pattern involving both tuple and struct
+ check(
+ r#"struct Foo { a: i32, b: i32 } fn test_7$0((x, Foo { a, b }): (i32, Foo)) {}"#,
+ expect![[r#"
+ *test_7*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ fn test_7((x, Foo { a, b }): (i32, Foo))
+ ```
+ "#]],
+ );
+
+ // Test case with Enum and Or pattern
+ check(
+ r#"enum MyEnum { A(i32), B(i32) } fn test_8$0((MyEnum::A(x) | MyEnum::B(x)): MyEnum) {}"#,
+ expect![[r#"
+ *test_8*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ fn test_8((MyEnum::A(x) | MyEnum::B(x)): MyEnum)
+ ```
+ "#]],
+ );
+
+ // Test case with a pattern as a function parameter
+ check(
+ r#"struct Foo { a: i32, b: i32 } fn test_9$0(Foo { a, b }: Foo) {}"#,
+ expect![[r#"
+ *test_9*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ fn test_9(Foo { a, b }: Foo)
+ ```
+ "#]],
+ );
+
+ // Test case with a pattern as a function parameter with a different name
+ check(
+ r#"struct Foo { a: i32, b: i32 } fn test_10$0(Foo { a, b: b1 }: Foo) {}"#,
+ expect![[r#"
+ *test_10*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ fn test_10(Foo { a, b: b1 }: Foo)
+ ```
+ "#]],
+ );
+
+ // Test case with a pattern as a function parameter with annotations
+ check(
+ r#"struct Foo { a: i32, b: i32 } fn test_10$0(Foo { a, b: mut b }: Foo) {}"#,
+ expect![[r#"
+ *test_10*
+
+ ```rust
+ test
+ ```
+
+ ```rust
+ fn test_10(Foo { a, b: mut b }: Foo)
+ ```
+ "#]],
+ );
+}