aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-09-29 22:21:54 +0200
committerDanielGavin <danielgavin5@hotmail.com>2024-09-29 22:21:54 +0200
commit632a1ca20e713430bdcfe6bca60ebf269f260c69 (patch)
tree7daece8a9f17d17066f6441b219e8ffacbf5afc3 /tests
parentc68b7f5c26dc0ee8f162b86a2adcc12eb922d71d (diff)
Add test and fix generics error.
Diffstat (limited to 'tests')
-rw-r--r--tests/completions_test.odin48
1 files changed, 34 insertions, 14 deletions
diff --git a/tests/completions_test.odin b/tests/completions_test.odin
index 1f17fcb..cac4285 100644
--- a/tests/completions_test.odin
+++ b/tests/completions_test.odin
@@ -1,8 +1,8 @@
package tests
import "core:fmt"
-import "core:testing"
import "core:strings"
+import "core:testing"
import test "src:testing"
@@ -1072,16 +1072,12 @@ ast_file_private_completion :: proc(t: ^testing.T) {
@(test)
ast_file_tag_private_completion :: proc(t: ^testing.T) {
- comments := []string{
- "// +private",
- "//+private file",
- "// +build ignore",
- }
+ comments := []string{"// +private", "//+private file", "// +build ignore"}
for comment in comments {
-
+
b := strings.builder_make(context.temp_allocator)
-
+
strings.write_string(&b, comment)
strings.write_string(&b, `
package my_package
@@ -1096,12 +1092,7 @@ ast_file_tag_private_completion :: proc(t: ^testing.T) {
my_package.{*}
}
`,
- packages = {
- {
- pkg = "my_package",
- source = strings.to_string(b),
- }
- },
+ packages = {{pkg = "my_package", source = strings.to_string(b)}},
}
test.expect_completion_details(t, &source, ".", {})
@@ -2836,6 +2827,35 @@ ast_generics_function_with_comp_lit_struct :: proc(t: ^testing.T) {
}
@(test)
+ast_generics_struct_poly :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package main
+ Pair :: struct($A, $B: typeid) {
+ a: A,
+ b: B,
+ }
+
+ Foo :: struct {
+ cool: int,
+ }
+
+ select :: proc($T: typeid, search: []Pair(string, any), allocator := context.temp_allocator) -> []T {
+
+ }
+
+
+ main :: proc() {
+ d := select(Foo, []Pair(string, any){})
+ d[0].c{*}
+ }
+ `,
+ }
+
+ test.expect_completion_details(t, &source, ".", {"Foo.cool: int"})
+
+}
+
+@(test)
ast_enumerated_array_index_completion :: proc(t: ^testing.T) {
source := test.Source {
main = `package main