diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2021-09-28 15:30:13 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2021-09-28 15:30:13 +0200 |
| commit | b99eb75908304d84fbc729ea4209642bb3d82a1c (patch) | |
| tree | 06551c969a2e5ea0b10c70e431f5c781d04d54d4 /tests | |
| parent | 614d1130c9679e5e943b6be64221515198273cda (diff) | |
Fix incorrect handling of functions in when clauses using ODIN_OS
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/signatures_test.odin | 114 |
1 files changed, 112 insertions, 2 deletions
diff --git a/tests/signatures_test.odin b/tests/signatures_test.odin index 2716a17..f70c4cc 100644 --- a/tests/signatures_test.odin +++ b/tests/signatures_test.odin @@ -372,9 +372,119 @@ ast_index_builtin_len_proc :: proc(t: ^testing.T) { len(*) } `, - packages = {}, + packages = {}, }; test.expect_signature_labels(t, &source, {"builtin.len: proc(array: Array_Type) -> (int)"}); +} + +@(test) +ast_signature_on_invalid_package :: proc(t: ^testing.T) { + + source := test.Source { + main = `package test + import "core:totallyReal" + main :: proc() { + a := totallyReal.read_cycle_counter(*) + } + `, + packages = {}, + }; + + test.expect_signature_labels(t, &source, {}); +} + +@(test) +ast_signature_variable_pointer :: proc(t: ^testing.T) { + + source := test.Source { + main = `package test + import "core:totallyReal" + + My_Fun :: proc(a: int) { + } + + main :: proc() { + my_fun_ptr: My_Fun; + my_fun_ptr(*) + } + `, + packages = {}, + }; + + test.expect_signature_labels(t, &source, {"test.My_Fun: proc(a: int)"}); + +} + +@(test) +ast_signature_global_variable_pointer :: proc(t: ^testing.T) { + + source := test.Source { + main = `package test + import "core:totallyReal" + + My_Fun :: proc(a: int) { + } + + my_fun_ptr: My_Fun; + + main :: proc() { + my_fun_ptr(*) + } + `, + packages = {}, + }; -}
\ No newline at end of file + test.expect_signature_labels(t, &source, {"test.My_Fun: proc(a: int)"}); +} + +@(test) +index_variable_pointer_signature :: proc(t: ^testing.T) { + + packages := make([dynamic]test.Package); + + append(&packages, test.Package { + pkg = "my_package", + source = `package my_package + My_Fun :: proc(a: int) { + } + + my_fun_ptr: My_Fun; + `, + }); + + source := test.Source { + main = `package test + + import "my_package" + main :: proc() { + my_package.my_fun_ptr(*) + } + `, + packages = packages[:], + }; + + test.expect_signature_labels(t, &source, {"my_package.My_Fun: proc(a: int)"}); +} + +/* +@(test) +signature_function_inside_when :: proc(t: ^testing.T) { + + source := test.Source { + main = `package test + when ODIN_OS == "windows" { + ProcAllocationFunction :: #type proc"stdcall"(pUserData: rawptr, size: int, alignment: int, allocationScope: SystemAllocationScope) -> rawptr; + } + + main :: proc() { + ProcAllocationFunction(*) + } + `, + packages = {}, + }; + + test.expect_signature_labels(t, &source, {"test.My_Fun: proc(a: int)"}); + +} +*/
\ No newline at end of file |