diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-06-09 14:32:59 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-06-13 15:23:36 -0400 |
| commit | 8816d531da666959b7df0c64401b8fa064b0cd3d (patch) | |
| tree | 893cf9b15bb610f13b2c6cf3c2c3148166341ed4 /src/testing | |
| parent | 023c8a0fd1d8d8e54b38bf990a74816a31dee68e (diff) | |
Add textDocument/typeDefinition support
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) |