From 07e8e34144d2c8929c8eb40779488464d77308bc Mon Sep 17 00:00:00 2001 From: Daniel Gavin Date: Tue, 27 Apr 2021 18:22:41 +0200 Subject: work on completion tests + new symbols --- src/testing/testing.odin | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'src/testing') diff --git a/src/testing/testing.odin b/src/testing/testing.odin index aaba07b..9562bc4 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -74,7 +74,7 @@ expect_signature_labels :: proc(t: ^testing.T, src: ^Source, expect_labels: []st help, ok := server.get_signature_information(src.document, src.position); if !ok { - testing.errorf(t, "Failed get_signature_information"); + testing.error(t, "Failed get_signature_information"); } if len(expect_labels) == 0 && len(help.signatures) > 0 { @@ -83,9 +83,9 @@ expect_signature_labels :: proc(t: ^testing.T, src: ^Source, expect_labels: []st flags := make([]int, len(expect_labels)); - for expect_signature, i in expect_labels { + for expect_label, i in expect_labels { for signature, j in help.signatures { - if expect_signature == signature.label { + if expect_label == signature.label { flags[i] += 1; } } @@ -99,9 +99,39 @@ expect_signature_labels :: proc(t: ^testing.T, src: ^Source, expect_labels: []st } -expect_completion :: proc(t: ^testing.T, src: ^Source, dot: bool, expect_completions: []string) { +expect_completion_details :: proc(t: ^testing.T, src: ^Source, trigger_character: string, expect_details: []string) { setup(src); + completion_context := server.CompletionContext { + triggerCharacter = trigger_character, + }; + + completion_list, ok := server.get_completion_list(src.document, src.position, completion_context); + + if !ok { + testing.error(t, "Failed get_completion_list"); + } + + if len(expect_details) == 0 && len(completion_list.items) > 0 { + testing.errorf(t, "Expected empty completion label, but received %v", completion_list.items); + } + + flags := make([]int, len(expect_details)); + + for expect_detail, i in expect_details { + for completion, j in completion_list.items { + if expect_detail == completion.detail { + flags[i] += 1; + } + } + } + + for flag, i in flags { + if flag != 1 { + testing.errorf(t, "Expected completion label %v, but received %v", expect_details[i], completion_list.items); + } + } + } expect_hover :: proc(t: ^testing.T, src: ^Source, expect_hover_info: string) { -- cgit v1.2.3