]> git.lizzy.rs Git - rust.git/blobdiff - crates/ide/src/hover/tests.rs
test names
[rust.git] / crates / ide / src / hover / tests.rs
index 2bfda1aff2e75ac8586c70d64ccb3787ae9a75f6..c5c531c30b1a4896ed4e0c392c12457f5c0be30b 100644 (file)
@@ -1310,6 +1310,60 @@ async fn foo()
     );
 }
 
+#[test]
+fn test_hover_function_show_types() {
+    check(
+        r#"fn foo$0(a: i32, b:i32) -> i32 { 0 }"#,
+        expect![[r#"
+                *foo*
+
+                ```rust
+                test
+                ```
+
+                ```rust
+                fn foo(a: i32, b: i32) -> i32
+                ```
+            "#]],
+    );
+}
+
+#[test]
+fn test_hover_function_pointer_show_identifiers() {
+    check(
+        r#"type foo$0 = fn(a: i32, b: i32) -> i32;"#,
+        expect![[r#"
+                *foo*
+
+                ```rust
+                test
+                ```
+
+                ```rust
+                type foo = fn(a: i32, b: i32) -> i32
+                ```
+            "#]],
+    );
+}
+
+#[test]
+fn test_hover_function_pointer_no_identifier() {
+    check(
+        r#"type foo$0 = fn(i32, _: i32) -> i32;"#,
+        expect![[r#"
+                *foo*
+
+                ```rust
+                test
+                ```
+
+                ```rust
+                type foo = fn(i32, i32) -> i32
+                ```
+            "#]],
+    );
+}
+
 #[test]
 fn test_hover_trait_show_qualifiers() {
     check_actions(
@@ -3350,6 +3404,31 @@ fn hover_const_eval() {
     check(
         r#"
 /// This is a doc
+const FOO$0: usize = {
+    let b = 4;
+    let a = { let b = 2; let a = b; a } + { let a = 1; a + b };
+    a
+};
+"#,
+        expect![[r#"
+            *FOO*
+
+            ```rust
+            test
+            ```
+
+            ```rust
+            const FOO: usize = 7
+            ```
+
+            ---
+
+            This is a doc
+        "#]],
+    );
+    check(
+        r#"
+/// This is a doc
 const FOO$0: usize = 2 - 3;
 "#,
         expect![[r#"
@@ -3443,6 +3522,24 @@ fn foo() {
     );
 }
 
+#[test]
+fn array_repeat_exp() {
+    check(
+        r#"
+fn main() {
+    let til$0e4 = [0_u32; (4 * 8 * 8) / 32];
+}
+        "#,
+        expect![[r#"
+            *tile4*
+
+            ```rust
+            let tile4: [u32; 8]
+            ```
+            "#]],
+    );
+}
+
 #[test]
 fn hover_mod_def() {
     check(