diff options
Diffstat (limited to 'tests/definition_test.odin')
| -rw-r--r-- | tests/definition_test.odin | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/definition_test.odin b/tests/definition_test.odin index 4810361..fe4cd3b 100644 --- a/tests/definition_test.odin +++ b/tests/definition_test.odin @@ -723,3 +723,56 @@ ast_goto_package_declaration_with_alias :: proc(t: ^testing.T) { test.expect_definition_locations(t, &source, locations[:]) } +@(test) +ast_goto_proc_group_overload_with_selector :: proc(t: ^testing.T) { + packages := make([dynamic]test.Package, context.temp_allocator) + + append(&packages, test.Package{pkg = "my_package", source = `package my_package + push_back :: proc(arr: ^[dynamic]int, val: int) {} + push_back_elems :: proc(arr: ^[dynamic]int, vals: ..int) {} + append :: proc{push_back, push_back_elems} + `}) + source := test.Source { + main = `package test + import mp "my_package" + + main :: proc() { + arr: [dynamic]int + mp.app{*}end(&arr, 1) + } + `, + packages = packages[:], + config = {enable_overload_resolution = true}, + } + // Should go to push_back (line 1, character 3) instead of append (line 3) + // because push_back is the overload being used with a single value argument + locations := []common.Location { + {range = {start = {line = 1, character = 3}, end = {line = 1, character = 12}}}, + } + + test.expect_definition_locations(t, &source, locations[:]) +} + +@(test) +ast_goto_proc_group_overload_identifier :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + push_back :: proc(arr: ^[dynamic]int, val: int) {} + push_back_elems :: proc(arr: ^[dynamic]int, vals: ..int) {} + append :: proc{push_back, push_back_elems} + + main :: proc() { + arr: [dynamic]int + app{*}end(&arr, 1) + } + `, + config = {enable_overload_resolution = true}, + } + // Should go to push_back (line 1, character 2) instead of append (line 3) + // because push_back is the overload being used with a single value argument + locations := []common.Location { + {range = {start = {line = 1, character = 2}, end = {line = 1, character = 11}}}, + } + + test.expect_definition_locations(t, &source, locations[:]) +}
\ No newline at end of file |