diff options
author | Igor Aleksanov <[email protected]> | 2020-10-17 08:56:00 +0100 |
---|---|---|
committer | Igor Aleksanov <[email protected]> | 2020-10-17 08:56:00 +0100 |
commit | 8f303daf458ae798b678d7e908ce5b2f27504111 (patch) | |
tree | 3b9c9e5c42145b72209aec396b07070f87010c1f | |
parent | 6ae4c70a0aecea4c7c0c5a43fe443baa170ff1d4 (diff) |
Add test for new pattern functions
-rw-r--r-- | crates/ide/src/completion/patterns.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/ide/src/completion/patterns.rs b/crates/ide/src/completion/patterns.rs index 76fcad631..f00ddeed7 100644 --- a/crates/ide/src/completion/patterns.rs +++ b/crates/ide/src/completion/patterns.rs | |||
@@ -123,6 +123,10 @@ pub(crate) fn fn_is_prev(element: SyntaxElement) -> bool { | |||
123 | .filter(|it| it.kind() == FN_KW) | 123 | .filter(|it| it.kind() == FN_KW) |
124 | .is_some() | 124 | .is_some() |
125 | } | 125 | } |
126 | #[test] | ||
127 | fn test_fn_is_prev() { | ||
128 | check_pattern_is_applicable(r"fn l<|>", fn_is_prev); | ||
129 | } | ||
126 | 130 | ||
127 | /// Check if the token previous to the previous one is `for`. | 131 | /// Check if the token previous to the previous one is `for`. |
128 | /// For example, `for _ i<|>` => true. | 132 | /// For example, `for _ i<|>` => true. |
@@ -134,6 +138,10 @@ pub(crate) fn for_is_prev2(element: SyntaxElement) -> bool { | |||
134 | .filter(|it| it.kind() == FOR_KW) | 138 | .filter(|it| it.kind() == FOR_KW) |
135 | .is_some() | 139 | .is_some() |
136 | } | 140 | } |
141 | #[test] | ||
142 | fn test_for_is_prev2() { | ||
143 | check_pattern_is_applicable(r"for i i<|>", for_is_prev2); | ||
144 | } | ||
137 | 145 | ||
138 | #[test] | 146 | #[test] |
139 | fn test_if_is_prev() { | 147 | fn test_if_is_prev() { |