Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/context/tests.rs')
-rw-r--r--crates/ide-completion/src/context/tests.rs69
1 files changed, 69 insertions, 0 deletions
diff --git a/crates/ide-completion/src/context/tests.rs b/crates/ide-completion/src/context/tests.rs
index 445afa75f3..d9ec7915e3 100644
--- a/crates/ide-completion/src/context/tests.rs
+++ b/crates/ide-completion/src/context/tests.rs
@@ -279,6 +279,62 @@ fn foo() {
}
#[test]
+fn expected_type_if_let_chain_bool() {
+ check_expected_type_and_name(
+ r#"
+fn foo() {
+ let f = Foo::Quux;
+ if let c = f && $0 { }
+}
+"#,
+ expect![[r#"ty: bool, name: ?"#]],
+ );
+}
+
+#[test]
+fn expected_type_if_condition() {
+ check_expected_type_and_name(
+ r#"
+fn foo() {
+ if a$0 { }
+}
+"#,
+ expect![[r#"ty: bool, name: ?"#]],
+ );
+}
+
+#[test]
+fn expected_type_if_body() {
+ check_expected_type_and_name(
+ r#"
+enum Foo { Bar, Baz, Quux }
+
+fn foo() {
+ let _: Foo = if true {
+ $0
+ };
+}
+"#,
+ expect![[r#"ty: Foo, name: ?"#]],
+ );
+
+ check_expected_type_and_name(
+ r#"
+enum Foo { Bar, Baz, Quux }
+
+fn foo() {
+ let _: Foo = if true {
+ Foo::Bar
+ } else {
+ $0
+ };
+}
+"#,
+ expect![[r#"ty: Foo, name: ?"#]],
+ );
+}
+
+#[test]
fn expected_type_fn_ret_without_leading_char() {
cov_mark::check!(expected_type_fn_ret_without_leading_char);
check_expected_type_and_name(
@@ -526,3 +582,16 @@ fn foo() {
expect![[r#"ty: State, name: ?"#]],
);
}
+
+#[test]
+fn expected_type_logic_op() {
+ check_expected_type_and_name(
+ r#"
+enum State { Stop }
+fn foo() {
+ true && $0;
+}
+"#,
+ expect![[r#"ty: bool, name: ?"#]],
+ );
+}