Skip to content

Commit

Permalink
[Refractor] Refractor lsp unit test (#1379)
Browse files Browse the repository at this point in the history
* Refractored lambda_local_var_test

Signed-off-by: Wck-iipi <[email protected]>

* Refractored goto_def_test with snapshot testing

Signed-off-by: Wck-iipi <[email protected]>

* Fixed goto_local_var_def_tests

Signed-off-by: Wck-iipi <[email protected]>

---------

Signed-off-by: Wck-iipi <[email protected]>
  • Loading branch information
Wck-iipi authored May 31, 2024
1 parent d07b448 commit c07925f
Show file tree
Hide file tree
Showing 60 changed files with 543 additions and 618 deletions.
844 changes: 247 additions & 597 deletions kclvm/tools/src/LSP/src/goto_def.rs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/complex_select_goto_def/complex_select_goto_def.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 13, column : Some(22), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/complex_select_goto_def/complex_select_goto_def.k\", range: Range { start: Position { line: 4, character: 4 }, end: Position { line: 4, character: 9 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/config_desuger_def_goto_def/config_desuger_def_goto_def.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 7, column : Some(9), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/config_desuger_def_goto_def/config_desuger_def_goto_def.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 13 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_assign_type_test/goto_assign_type_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 5, column : Some(17), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/goto_assign_type_test/goto_assign_type_test.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 15 } }"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let(file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\")\n ; let pos = KCLPos\n { filename : file.clone(), line : 13, column : Some(15), } ; let res =\n goto_def(& pos, & gs) ; fmt_resp(& res)\n })"
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 13, column : Some(15), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\", range: Range { start: Position { line: 1, character: 4 }, end: Position { line: 1, character: 8 } }"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let(file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\")\n ; let pos = KCLPos\n { filename : file.clone(), line : 15, column : Some(7), } ; let res =\n goto_def(& pos, & gs) ; fmt_resp(& res)\n })"
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 15, column : Some(7), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\", range: Range { start: Position { line: 4, character: 4 }, end: Position { line: 4, character: 8 } }"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let(file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\")\n ; let pos = KCLPos\n { filename : file.clone(), line : 19, column : Some(7), } ; let res =\n goto_def(& pos, & gs) ; fmt_resp(& res)\n })"
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 19, column : Some(7), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\", range: Range { start: Position { line: 9, character: 4 }, end: Position { line: 9, character: 8 } }"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let(file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\")\n ; let pos = KCLPos\n { filename : file.clone(), line : 26, column : Some(11), } ; let res =\n goto_def(& pos, & gs) ; fmt_resp(& res)\n })"
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 26, column : Some(11), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\", range: Range { start: Position { line: 4, character: 4 }, end: Position { line: 4, character: 8 } }"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let(file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\")\n ; let pos = KCLPos\n { filename : file.clone(), line : 33, column : Some(11), } ; let res =\n goto_def(& pos, & gs) ; fmt_resp(& res)\n })"
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 33, column : Some(11), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\", range: Range { start: Position { line: 9, character: 4 }, end: Position { line: 9, character: 8 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_identifier_def_test/goto_identifier_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 8, column : Some(6), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/goto_identifier_def_test/goto_identifier_def_test.k\", range: Range { start: Position { line: 2, character: 0 }, end: Position { line: 2, character: 1 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 13, column : Some(5), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k\", range: Range { start: Position { line: 8, character: 0 }, end: Position { line: 8, character: 2 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 13, column : Some(8), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k\", range: Range { start: Position { line: 6, character: 4 }, end: Position { line: 6, character: 5 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 13, column : Some(12), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k\", range: Range { start: Position { line: 3, character: 4 }, end: Position { line: 3, character: 8 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_import_pkg_test/goto_import_pkg_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 1, column : Some(11), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 0, character: 0 }, end: Position { line: 0, character: 0 } }\npath: \"src/test_data/goto_def_test/pkg/schema_def1.k\", range: Range { start: Position { line: 0, character: 0 }, end: Position { line: 0, character: 0 } }\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_lambda_param_goto_def/goto_lambda_param_goto_def.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 2, column : Some(5), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/goto_lambda_param_goto_def/goto_lambda_param_goto_def.k\", range: Range { start: Position { line: 0, character: 14 }, end: Position { line: 0, character: 15 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_lambda_param_goto_def/goto_lambda_param_goto_def.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 2, column : Some(9), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/goto_lambda_param_goto_def/goto_lambda_param_goto_def.k\", range: Range { start: Position { line: 0, character: 22 }, end: Position { line: 0, character: 23 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 7, column : Some(11), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k\", range: Range { start: Position { line: 4, character: 4 }, end: Position { line: 4, character: 9 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 9, column : Some(11), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k\", range: Range { start: Position { line: 4, character: 4 }, end: Position { line: 4, character: 9 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 11, column : Some(11), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k\", range: Range { start: Position { line: 4, character: 4 }, end: Position { line: 4, character: 9 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_pkg_prefix_def_test/goto_pkg_prefix_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 3, column : Some(7), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 0, character: 0 }, end: Position { line: 0, character: 0 } }\npath: \"src/test_data/goto_def_test/pkg/schema_def1.k\", range: Range { start: Position { line: 0, character: 0 }, end: Position { line: 0, character: 0 } }\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_attr_def_test/goto_schema_attr_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 4, column : Some(7), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 4, character: 4 }, end: Position { line: 4, character: 8 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_attr_def_test/goto_schema_attr_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 18, column : Some(12), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/goto_schema_attr_def_test/goto_schema_attr_def_test.k\", range: Range { start: Position { line: 8, character: 4 }, end: Position { line: 8, character: 8 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 4, column : Some(15), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 13 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 5, column : Some(15), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 13 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 6, column : Some(22), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 13 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 7, column : Some(17), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 13 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 7, column : Some(28), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/pkg/schema_def1.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 14 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_def_test/goto_schema_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 3, column : Some(11), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 13 } }"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let(file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_def.k\") ; let pos\n = KCLPos { filename : file.clone(), line : 3, column : Some(1), } ;\n let res = goto_def(& pos, & gs) ; fmt_resp(& res)\n })"
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_system_pkg_test/goto_system_pkg_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 1, column : Some(1), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"None"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 7, column : Some(36), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k\", range: Range { start: Position { line: 5, character: 11 }, end: Position { line: 5, character: 14 } }"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tools/src/LSP/src/goto_def.rs
expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 7, column : Some(44), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })"
---
"path: \"src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k\", range: Range { start: Position { line: 5, character: 16 }, end: Position { line: 5, character: 21 } }"
Loading

0 comments on commit c07925f

Please sign in to comment.