diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2021-12-05 20:36:59 +0100 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2021-12-05 20:36:59 +0100 |
| commit | bbbff41f1b4edd5d227f291158191c214cf57706 (patch) | |
| tree | 293881010a58bea022b9f0d53878d94e63ad3352 /tests | |
| parent | 8f73e4e4f64b46bee43fe659cad8ea4d505fb3f0 (diff) | |
Incorrect behavior where globals were not added as variables.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/completions_test.odin | 97 | ||||
| -rw-r--r-- | tests/definition_test.odin | 7 | ||||
| -rw-r--r-- | tests/signatures_test.odin | 19 |
3 files changed, 123 insertions, 0 deletions
diff --git a/tests/completions_test.odin b/tests/completions_test.odin index 93dd9df..7b3d014 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -569,6 +569,45 @@ ast_generic_make_completion :: proc(t: ^testing.T) { test.expect_completion_details(t, &source, ".", {"My_Struct.my_int: int"}); } +@(test) +ast_generic_make_completion_2 :: proc(t: ^testing.T) { + + source := test.Source { + main = `package test + + make :: proc{ + make_dynamic_array, + make_dynamic_array_len, + make_dynamic_array_len_cap, + make_map, + make_slice, + }; + make_slice :: proc($T: typeid/[]$E, auto_cast len: int, loc := #caller_location) -> (T, Allocator_Error) #optional_second { + } + make_map :: proc($T: typeid/map[$K]$E, auto_cast cap: int = DEFAULT_RESERVE_CAPACITY, loc := #caller_location) -> T { + } + make_dynamic_array :: proc($T: typeid/[dynamic]$E, loc := #caller_location) -> (T, Allocator_Error) #optional_second { + } + make_dynamic_array_len :: proc($T: typeid/[dynamic]$E, auto_cast len: int, loc := #caller_location) -> (T, Allocator_Error) #optional_second { + } + make_dynamic_array_len_cap :: proc($T: typeid/[dynamic]$E, auto_cast len: int, auto_cast cap: int, loc := #caller_location) -> (T, Allocator_Error) #optional_second { + } + + My_Struct :: struct { + my_int: int, + } + + main :: proc() { + allocator: Allocator; + my_array := make([]My_Struct, 343); + my_array[2].* + } + `, + packages = {}, + }; + + test.expect_completion_details(t, &source, ".", {"My_Struct.my_int: int"}); +} @(test) ast_struct_for_in_switch_stmt_completion :: proc(t: ^testing.T) { @@ -776,6 +815,64 @@ ast_package_procedure_completion :: proc(t: ^testing.T) { test.expect_completion_details(t, &source, ".", {"my_package.my_proc: proc() -> bool"}); } +@(test) +ast_poly_with_comp_lit_empty_completion :: proc(t: ^testing.T) { + + source := test.Source { + main = `package test + + My_Struct :: struct { + a: int, + } + + new_type :: proc($T: typeid, pos, end: My_Struct) -> ^T { + } + + main :: proc() { + t := new_type(My_Struct, {}, {}) + t.* + } + `, + packages = {}, + }; + + test.expect_completion_details(t, &source, ".", {"my_package.my_proc: proc() -> bool"}); +} + +@(test) +ast_global_struct_completion :: proc(t: ^testing.T) { + + source := test.Source { + main = `package main + + Foo :: struct { x: int } + foo := Foo{} + main :: proc() { + x := foo.* + } + `, + packages = {}, + }; + + test.expect_completion_details(t, &source, ".", {"Foo.x: int"}); +} + +@(test) +ast_global_non_mutable_completion :: proc(t: ^testing.T) { + source := test.Source { + main = `package main + + Foo :: struct { x: int } + main :: proc() { + x := Foo.* + } + `, + packages = {}, + }; + + test.expect_completion_details(t, &source, ".", {}); +} + /* Looks like a bug in for each on w.* diff --git a/tests/definition_test.odin b/tests/definition_test.odin new file mode 100644 index 0000000..ff9a8f5 --- /dev/null +++ b/tests/definition_test.odin @@ -0,0 +1,7 @@ +package tests + +import "core:testing" +import "core:fmt" + +import test "shared:testing" + diff --git a/tests/signatures_test.odin b/tests/signatures_test.odin index 5cb721c..0e0af1f 100644 --- a/tests/signatures_test.odin +++ b/tests/signatures_test.odin @@ -467,6 +467,25 @@ index_variable_pointer_signature :: proc(t: ^testing.T) { test.expect_signature_labels(t, &source, {"my_package.My_Fun: proc(a: int)"}); } +@(test) +shared_value_decl_type_signature :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + + my_function :: proc(a, b: int) { + + } + + main :: proc() { + my_function(*) + } + `, + packages = {}, + }; + + test.expect_signature_labels(t, &source, {"test.my_function: proc(a: int, b: int)"}); +} + /* @(test) signature_function_inside_when :: proc(t: ^testing.T) { |