diff options
Diffstat (limited to 'src/testing')
| -rw-r--r-- | src/testing/testing.odin | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/testing/testing.odin b/src/testing/testing.odin index 87f740a..0fff9d6 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -290,6 +290,45 @@ expect_definition_locations :: proc(t: ^testing.T, src: ^Source, expect_location } } +expect_type_definition_locations :: proc(t: ^testing.T, src: ^Source, expect_locations: []common.Location) { + setup(src) + defer teardown(src) + + locations, ok := server.get_type_definition_locations(src.document, src.position) + + if !ok { + log.error("Failed get_definition_location") + } + + if len(expect_locations) == 0 && len(locations) > 0 { + log.errorf("Expected empty locations, but received %v", locations) + } + + flags := make([]int, len(expect_locations), context.temp_allocator) + + for expect_location, i in expect_locations { + for location, j in locations { + if expect_location.uri != "" { + if location.range == expect_location.range && location.uri == expect_location.uri { + flags[i] += 1 + } + } else if location.range == expect_location.range { + flags[i] += 1 + } + } + } + + for flag, i in flags { + if flag != 1 { + if expect_locations[i].uri == "" { + log.errorf("Expected location %v, but received %v", expect_locations[i].range, locations) + } else { + log.errorf("Expected location %v, but received %v", expect_locations[i], locations) + } + } + } +} + expect_reference_locations :: proc(t: ^testing.T, src: ^Source, expect_locations: []common.Location) { setup(src) defer teardown(src) |