From ac226021cfd26a9332b5971f3e05118d77822af5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 26 Aug 2018 12:09:28 +0300 Subject: scope based comletion --- crates/libeditor/tests/test.rs | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'crates/libeditor/tests/test.rs') diff --git a/crates/libeditor/tests/test.rs b/crates/libeditor/tests/test.rs index 20de2f240..ecdc149c7 100644 --- a/crates/libeditor/tests/test.rs +++ b/crates/libeditor/tests/test.rs @@ -256,25 +256,23 @@ struct Foo { f: u32 } "); } -// #[test] -// fn test_completion() { -// fn do_check(code: &str, expected_completions: &str) { -// let (off, code) = extract_offset(&code); -// let file = file(&code); -// let completions = scope_completion(&file, off).unwrap(); -// assert_eq_dbg(expected_completions, &completions); -// } +#[test] +fn test_completion() { + fn do_check(code: &str, expected_completions: &str) { + let (off, code) = extract_offset(&code); + let file = file(&code); + let completions = scope_completion(&file, off).unwrap(); + assert_eq_dbg(expected_completions, &completions); + } -// do_check(r" -// fn foo(foo: i32) { -// let bar = 92; -// 1 + <|> -// } -// ", r#" -// CompletionItem { name: "bar" }, -// CompletionItem { name: "foo" }, -// "#); -// } + do_check(r" +fn quux(x: i32) { + let y = 92; + 1 + <|> +} +", r#"[CompletionItem { name: "y" }, + CompletionItem { name: "x" }]"#); +} fn file(text: &str) -> File { File::parse(text) -- cgit v1.2.3