aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2023-12-29 17:43:10 +0100
committerDanielGavin <danielgavin5@hotmail.com>2023-12-29 17:43:10 +0100
commite93830d576ea387cc7dc635306ce07f43c515853 (patch)
treeb810eadd2dfdbaa3a72f90e9db81ade7ca36ac06 /tests
parent589f609f76040c3be20adfa799d8b79345477882 (diff)
More poly work
Diffstat (limited to 'tests')
-rw-r--r--tests/completions_test.odin78
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/completions_test.odin b/tests/completions_test.odin
index fc9575c..2e811a6 100644
--- a/tests/completions_test.odin
+++ b/tests/completions_test.odin
@@ -2494,3 +2494,81 @@ ast_poly_proc_array_constant :: proc(t: ^testing.T) {
test.expect_completion_details(t, &source, "", {"test.array: [3]f32"})
}
+
+@(test)
+ast_poly_proc_matrix_type :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package)
+
+ source := test.Source {
+ main = `package test
+
+ matrix_to_ptr :: proc "contextless" (m: ^$A/matrix[$I, $J]$E) -> ^E {
+ return &m[0, 0]
+ }
+
+
+ main :: proc() {
+ my_matrix: matrix[2, 2]f32
+ ptr := matrix_to_ptr(&my_matrix)
+ pt{*}
+ }
+
+ `,
+ packages = packages[:],
+ }
+
+ test.expect_completion_details(&t, &source, "", {"test.ptr: ^f32"})
+}
+
+@(test)
+ast_poly_proc_matrix_constant_array :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package)
+
+ source := test.Source {
+ main = `package test
+
+ matrix_to_ptr :: proc "contextless" (m: ^$A/matrix[$I, $J]$E) -> [J]E {
+ return {}
+ }
+
+ main :: proc() {
+ my_matrix: matrix[4, 3]f32
+
+ ptr := matrix_to_ptr(&my_matrix)
+ pt{*}
+ }
+ `,
+ packages = packages[:],
+ }
+
+ test.expect_completion_details(&t, &source, "", {"test.ptr: [3]f32"})
+}
+
+@(test)
+ast_poly_proc_matrix_constant_array_2 :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package)
+
+ source := test.Source {
+ main = `package test
+ array_cast :: proc "contextless" (
+ v: $A/[$N]$T,
+ $Elem_Type: typeid,
+ ) -> (
+ w: [N]Elem_Type,
+ ) {
+ for i in 0 ..< N {
+ w[i] = Elem_Type(v[i])
+ }
+ return
+ }
+ main :: proc() {
+ my_vector: [10]int
+ myss := array_cast(my_vector, f32)
+ mys{*}
+ }
+ `,
+ packages = packages[:],
+ }
+
+ test.expect_completion_details(&t, &source, "", {"test.myss: [10]f32"})
+}