From 7ffb65ba464614797ecf560c6eaba7d674fc57e4 Mon Sep 17 00:00:00 2001 From: hatoo <hato2000@gmail.com> Date: Sat, 17 Feb 2024 16:47:05 +0900 Subject: [PATCH] save --- src/src_tree.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/src_tree.rs b/src/src_tree.rs index 2f59e46..1d023ea 100644 --- a/src/src_tree.rs +++ b/src/src_tree.rs @@ -610,7 +610,7 @@ fn test_diagnostic() { #[test] fn test_completion() { - fn completion(src: &str, pos: Point, label: &str) { + fn complete(src: &str, pos: Point, label: &str) { let src_tree = SrcTree::new(src.to_string()); src_tree @@ -620,7 +620,7 @@ fn test_completion() { .unwrap(); } fn root_command(src: &str, pos: Point) { - completion(src, pos, "run"); + complete(src, pos, "run"); } fn complete_not(src: &str, pos: Point, label: &str) { let src_tree = SrcTree::new(src.to_string()); @@ -631,16 +631,22 @@ fn test_completion() { .find(|c| c.label == label) .is_none()); } + fn not_complete(src: &str, pos: Point) { + let src_tree = SrcTree::new(src.to_string()); + + assert!(src_tree.completion(pos).is_empty()); + } root_command("()", Point { row: 0, column: 1 }); root_command("(let x 1)\n()", Point { row: 1, column: 1 }); root_command("(let x 1)\n()\n(run 100)", Point { row: 1, column: 1 }); - completion("(run 100 :)", Point { row: 0, column: 10 }, "until"); - completion("(datatype A (X ))", Point { row: 0, column: 14 }, "i64"); - completion( + complete("(run 100 :)", Point { row: 0, column: 10 }, "until"); + complete("(datatype A (X ))", Point { row: 0, column: 14 }, "i64"); + complete( "(sort S)\n(datatype A (X ))", Point { row: 1, column: 14 }, "S", ); complete_not("(function A ())", Point { row: 0, column: 13 }, "+"); + not_complete("(function )", Point { row: 0, column: 10 }); }