diff options
author | Aleksey Kladov <[email protected]> | 2018-08-28 09:12:42 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-28 09:12:42 +0100 |
commit | 2fa90e736b026ee979d9eb59178dc1f792228250 (patch) | |
tree | adba3a569241a2030bf66e4e0b24ac5ffeaccbc3 /crates/libeditor/tests/test.rs | |
parent | 13110f48e948d7554500aefc336e72f96041386b (diff) |
better recovery for exprs
Diffstat (limited to 'crates/libeditor/tests/test.rs')
-rw-r--r-- | crates/libeditor/tests/test.rs | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/crates/libeditor/tests/test.rs b/crates/libeditor/tests/test.rs index d8c24610d..17926d5ae 100644 --- a/crates/libeditor/tests/test.rs +++ b/crates/libeditor/tests/test.rs | |||
@@ -9,7 +9,7 @@ use libeditor::{ | |||
9 | ActionResult, | 9 | ActionResult, |
10 | highlight, runnables, extend_selection, file_structure, | 10 | highlight, runnables, extend_selection, file_structure, |
11 | flip_comma, add_derive, add_impl, matching_brace, | 11 | flip_comma, add_derive, add_impl, matching_brace, |
12 | join_lines, scope_completion, | 12 | join_lines, on_eq_typed, scope_completion, |
13 | }; | 13 | }; |
14 | 14 | ||
15 | #[test] | 15 | #[test] |
@@ -227,7 +227,7 @@ pub fn reparse(&self, edit: &AtomEdit) -> File { | |||
227 | #[test] | 227 | #[test] |
228 | fn test_join_lines_selection() { | 228 | fn test_join_lines_selection() { |
229 | fn do_check(before: &str, after: &str) { | 229 | fn do_check(before: &str, after: &str) { |
230 | let (sel, before) = extract_range(&before); | 230 | let (sel, before) = extract_range(before); |
231 | let file = file(&before); | 231 | let file = file(&before); |
232 | let result = join_lines(&file, sel); | 232 | let result = join_lines(&file, sel); |
233 | let actual = result.edit.apply(&before); | 233 | let actual = result.edit.apply(&before); |
@@ -257,6 +257,48 @@ struct Foo { f: u32 } | |||
257 | } | 257 | } |
258 | 258 | ||
259 | #[test] | 259 | #[test] |
260 | fn test_on_eq_typed() { | ||
261 | fn do_check(before: &str, after: &str) { | ||
262 | let (offset, before) = extract_offset(before); | ||
263 | let file = file(&before); | ||
264 | let result = on_eq_typed(&file, offset).unwrap(); | ||
265 | let actual = result.edit.apply(&before); | ||
266 | assert_eq_text!(after, &actual); | ||
267 | } | ||
268 | |||
269 | do_check(r" | ||
270 | fn foo() { | ||
271 | let foo =<|> | ||
272 | } | ||
273 | ", r" | ||
274 | fn foo() { | ||
275 | let foo =; | ||
276 | } | ||
277 | "); | ||
278 | do_check(r" | ||
279 | fn foo() { | ||
280 | let foo =<|> 1 + 1 | ||
281 | } | ||
282 | ", r" | ||
283 | fn foo() { | ||
284 | let foo = 1 + 1; | ||
285 | } | ||
286 | "); | ||
287 | // do_check(r" | ||
288 | // fn foo() { | ||
289 | // let foo =<|> | ||
290 | // let bar = 1; | ||
291 | // } | ||
292 | // ", r" | ||
293 | // fn foo() { | ||
294 | // let foo =; | ||
295 | // let bar = 1; | ||
296 | // } | ||
297 | // "); | ||
298 | |||
299 | } | ||
300 | |||
301 | #[test] | ||
260 | fn test_completion() { | 302 | fn test_completion() { |
261 | fn do_check(code: &str, expected_completions: &str) { | 303 | fn do_check(code: &str, expected_completions: &str) { |
262 | let (off, code) = extract_offset(&code); | 304 | let (off, code) = extract_offset(&code); |