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

57 lines
1.3 KiB
Plaintext

main :: (argc: int, argv: **char): int
test_arrays()
test_any()
test_type()
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]}
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}
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)