aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/definition_test.odin51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/definition_test.odin b/tests/definition_test.odin
index 4810361..62165e2 100644
--- a/tests/definition_test.odin
+++ b/tests/definition_test.odin
@@ -723,3 +723,54 @@ 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[:],
+ }
+ // 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)
+ }
+ `,
+ }
+ // 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