diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2021-05-03 23:33:25 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2021-05-03 23:33:25 +0200 |
| commit | ea0457da00f49fb758337e8456a3fe3965e2d2fa (patch) | |
| tree | aa4d9f73e2c140b3c8a6c6baad9801e54fe5e554 /tests | |
| parent | 9aa4f1eb9dacde2b25c5cf426742795e9ec02d70 (diff) | |
fix type showing correctly on package selection
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/completions_test.odin | 52 | ||||
| -rw-r--r-- | tests/hover_test.odin | 2 | ||||
| -rw-r--r-- | tests/signatures_test.odin | 26 |
3 files changed, 50 insertions, 30 deletions
diff --git a/tests/completions_test.odin b/tests/completions_test.odin index a2aa4ad..c091209 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -21,7 +21,7 @@ ast_simple_struct_completion :: proc(t: ^testing.T) { my_struct.* } `, - source_packages = {}, + packages = {}, }; test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"}); @@ -43,7 +43,7 @@ ast_index_array_completion :: proc(t: ^testing.T) { my_struct[2].* } `, - source_packages = {}, + packages = {}, }; test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"}); @@ -65,7 +65,7 @@ ast_struct_pointer_completion :: proc(t: ^testing.T) { my_struct.* } `, - source_packages = {}, + packages = {}, }; test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"}); @@ -88,7 +88,7 @@ ast_struct_take_address_completion :: proc(t: ^testing.T) { my_pointer.* } `, - source_packages = {}, + packages = {}, }; test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"}); @@ -111,7 +111,7 @@ ast_struct_deref_completion :: proc(t: ^testing.T) { my_deref.* } `, - source_packages = {}, + packages = {}, }; test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"}); @@ -137,7 +137,7 @@ ast_range_map :: proc(t: ^testing.T) { } `, - source_packages = {}, + packages = {}, }; test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"}); @@ -163,7 +163,7 @@ ast_range_array :: proc(t: ^testing.T) { } `, - source_packages = {}, + packages = {}, }; test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"}); @@ -192,7 +192,7 @@ ast_completion_identifier_proc_group :: proc(t: ^testing.T) { grou* } `, - source_packages = {}, + packages = {}, }; test.expect_completion_details(t, &source, "", {"test.group_function: proc"}); @@ -216,7 +216,7 @@ index_completion_in_comp_lit_type :: proc(t: ^testing.T) { }; } `, - source_packages = {}, + packages = {}, }; test.expect_completion_details(t, &source, "", {"test.My_Struct: struct"}); @@ -240,7 +240,7 @@ ast_completion_range_struct_selector_strings :: proc(t: ^testing.T) { } } `, - source_packages = {}, + packages = {}, }; test.expect_completion_details(t, &source, "", {"test.value: string"}); @@ -267,12 +267,42 @@ ast_completion_selector_on_indexed_array :: proc(t: ^testing.T) { my_struct.array[len(my_struct.array)-1].* } `, - source_packages = {}, + packages = {}, }; test.expect_completion_details(t, &source, ".", {"My_Foo.a: int", "My_Foo.b: int"}); } +@(test) +ast_package_completion :: proc(t: ^testing.T) { + + packages := make([dynamic]test.Package); + + append(&packages, test.Package{ + pkg = "my_package", + source = `package my_package + My_Struct :: struct { + one: int, + two: int, + three: int, + } + `, + }); + + source := test.Source { + main = `package test + + import "my_package" + + main :: proc() { + my_package.* + } + `, + packages = packages[:], + }; + + test.expect_completion_details(t, &source, ".", {"my_package.My_Struct: struct"}); +} /* diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 5daa3e2..97f9b90 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -16,7 +16,7 @@ ast_hover_default_intialized_parameter :: proc(t: ^testing.T) { } `, - source_packages = {}, + packages = {}, }; test.expect_hover(t, &source, "test.a: bool"); diff --git a/tests/signatures_test.odin b/tests/signatures_test.odin index c00b845..d5c9da2 100644 --- a/tests/signatures_test.odin +++ b/tests/signatures_test.odin @@ -13,7 +13,7 @@ ast_declare_proc_signature :: proc(t: ^testing.T) { main = `package test main :: proc(*) `, - source_packages = {}, + packages = {}, }; test.expect_signature_labels(t, &source, {}); @@ -25,14 +25,13 @@ ast_simple_proc_signature :: proc(t: ^testing.T) { source := test.Source { main = `package test cool_function :: proc(a: int) { - } main :: proc() { cool_function(*) } `, - source_packages = {}, + packages = {}, }; test.expect_signature_labels(t, &source, {"test.cool_function: proc(a: int)"}); @@ -44,11 +43,9 @@ ast_proc_group_signature_empty_call :: proc(t: ^testing.T) { source := test.Source { main = `package test int_function :: proc(a: int) { - } bool_function :: proc(a: bool) { - } group_function :: proc { @@ -60,7 +57,7 @@ ast_proc_group_signature_empty_call :: proc(t: ^testing.T) { group_function(*) } `, - source_packages = {}, + packages = {}, }; test.expect_signature_labels(t, &source, {"test.int_function: proc(a: int)", "test.bool_function: proc(a: bool)"}); @@ -81,7 +78,7 @@ ast_proc_signature_generic :: proc(t: ^testing.T) { clone_array(*) } `, - source_packages = {}, + packages = {}, }; test.expect_signature_labels(t, &source, {"test.clone_array: proc (array: $A/[]^$T, allocator: mem.Allocator, unique_strings: ^map[string]string) -> (A)"}); @@ -93,11 +90,9 @@ ast_proc_group_signature_basic_types :: proc(t: ^testing.T) { source := test.Source { main = `package test int_function :: proc(a: int, b: bool, c: int) { - } bool_function :: proc(a: bool, b: bool, c: bool) { - } group_function :: proc { @@ -109,7 +104,7 @@ ast_proc_group_signature_basic_types :: proc(t: ^testing.T) { group_function(2, true, *) } `, - source_packages = {}, + packages = {}, }; test.expect_signature_labels(t, &source, {"test.int_function: proc(a: int, b: bool, c: int)"}); @@ -125,11 +120,9 @@ ast_proc_group_signature_distinct_basic_types :: proc(t: ^testing.T) { My_Int :: distinct int; distinct_function :: proc(a: My_Int, c: int) { - } int_function :: proc(a: int, c: int) { - } group_function :: proc { @@ -144,7 +137,7 @@ ast_proc_group_signature_distinct_basic_types :: proc(t: ^testing.T) { group_function(a, *) } `, - source_packages = {}, + packages = {}, }; test.expect_signature_labels(t, &source, {"test.distinct_function: proc(a: My_Int, c: int)"}); @@ -165,15 +158,12 @@ ast_proc_group_signature_struct :: proc(t: ^testing.T) { } distinct_function :: proc(a: My_Int, c: int) { - } int_function :: proc(a: int, c: int) { - } struct_function :: proc(a: int, b: My_Struct, c: int) { - } group_function :: proc { @@ -188,8 +178,8 @@ ast_proc_group_signature_struct :: proc(t: ^testing.T) { group_function(a, b, *) } `, - source_packages = {}, + packages = {}, }; test.expect_signature_labels(t, &source, {"test.struct_function: proc(a: int, b: My_Struct, c: int)"}); -}
\ No newline at end of file +} |