aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing.odin
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2021-04-27 18:22:41 +0200
committerDaniel Gavin <danielgavin5@hotmail.com>2021-04-27 18:22:41 +0200
commit07e8e34144d2c8929c8eb40779488464d77308bc (patch)
tree25a64714b5f32241b6120071a2f3748aadc326cc /src/testing/testing.odin
parent6f6f95c000edb7305371f96d466731122ac54178 (diff)
work on completion tests + new symbols
Diffstat (limited to 'src/testing/testing.odin')
-rw-r--r--src/testing/testing.odin38
1 files changed, 34 insertions, 4 deletions
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) {