Files
corelang/programs/any.kl
2022-06-20 19:27:22 +02:00

71 lines
1.7 KiB
Plaintext

#import "os_windows.kl"
main :: (argc: int, argv: **char): int
test_any()
test_arrays()
test_type()
test_array_any :: (any: Any, array_of_any: ..)
for array_of_any
pass
test_any :: ()
some_int_value := 10
thing: Any = some_int_value
other_any: Any = thing
imp_any := thing
assert(thing.type != Any)
any_array := []Any{some_int_value, thing}
for any_array
assert(it.type == S64)
test_arrays :: ()
array1 := []S64{1,2,3,4,5}
array2: []S64 = {0,9,8}
array4 := [][]S64{[]S64{5,6},[]S64{4,3},[]S64{2,3}}
array5 := [][]S64{{5,6},{4,3},{2,3}}
for i := 0, i < length_of(array1), i+=1
assert(i+1 == array1[i])
array6: []*S64 = {&array1[0]}
for array1;; *it = 0
for array2;; *it = 0
for i := 0, i < length_of(array1), i+=1;; assert(0 == array1[i])
print("Thing % %", {30, 20})
test_array_any(array_of_any = {20, 30}, any = 10)
// test_array_any(10, 20, 30) // @fix
Some_Struct :: struct
thing: int
test_type :: ()
type1: Type = **[]int
type2 := []*[]*Some_Struct
type3 := Some_Struct
type4 := [32]Some_Struct
type5 := [][32]*Some_Struct
type6 := [][32]*[16][]Some_Struct
t1 := get_type_info(type1)
assert(t1.kind == Type_Info_Kind.POINTER)
t2 := get_type_info(type2)
assert(t2.kind == Type_Info_Kind.SLICE)
t3 := get_type_info(type3)
assert(t3.kind == Type_Info_Kind.STRUCT)
t4 := get_type_info(type4)
assert(t4.array_size == 32)
assert(t4.kind == Type_Info_Kind.ARRAY)
t5 := get_type_info(type5)
t51 := get_type_info(t5.base_type)
assert(t51.kind == Type_Info_Kind.ARRAY)
t6 := get_type_info(type6)
t61 := get_type_info(t6.base_type)
t62 := get_type_info(t61.base_type)
assert(t62.kind == Type_Info_Kind.POINTER)