From bad9ab7479d66dfdb1c8e2d18c23fbcff9ec394b Mon Sep 17 00:00:00 2001 From: Kimplul Date: Tue, 15 Aug 2023 21:41:29 +0300 Subject: updates to syntax --- tests/arr.ek | 5 +++++ tests/blocks.ek | 10 ++++++++++ tests/callbacks.ek | 4 ++-- tests/resolve.ek | 2 +- tests/structs.ek | 38 +++++++++++++++++++------------------- 5 files changed, 37 insertions(+), 22 deletions(-) create mode 100644 tests/arr.ek create mode 100644 tests/blocks.ek (limited to 'tests') diff --git a/tests/arr.ek b/tests/arr.ek new file mode 100644 index 0000000..d4f35f7 --- /dev/null +++ b/tests/arr.ek @@ -0,0 +1,5 @@ +main() +{ + a '[20]'[20]'type![u32, u32]; + a[20] = 200; +} diff --git a/tests/blocks.ek b/tests/blocks.ek new file mode 100644 index 0000000..e91d33c --- /dev/null +++ b/tests/blocks.ek @@ -0,0 +1,10 @@ +main() +{ + a mut = switch 1 { + case 2: 2 + case 1: 1 + default: 20; 20 + }; + + c mut = ({2 + 2; 4 + 4}); +} diff --git a/tests/callbacks.ek b/tests/callbacks.ek index 0249065..9b9d649 100644 --- a/tests/callbacks.ek +++ b/tests/callbacks.ek @@ -1,4 +1,4 @@ -do_stuff(proc '(u32)) +do_stuff(proc @(u32)) { proc(); } @@ -13,5 +13,5 @@ other_proc() main() { - do_stuff(other_proc as '(u32)); + do_stuff(other_proc as @(u32)); } diff --git a/tests/resolve.ek b/tests/resolve.ek index 1be0916..5ac7d71 100644 --- a/tests/resolve.ek +++ b/tests/resolve.ek @@ -30,6 +30,6 @@ some_func(generic){5;} main(){ // TODO: not fully qualified types in bodies should cause an error - a generic(i64, generic); + a [20]generic![i64, generic]; some_func(a); } diff --git a/tests/structs.ek b/tests/structs.ek index 8a3a1bb..ed0b30f 100644 --- a/tests/structs.ek +++ b/tests/structs.ek @@ -15,34 +15,34 @@ struct complex_struct (A any, B any, C any) { main() { /* infer types */ - simple_named const = {.a = 1, .b = 2, .c = 3} as basic_struct; - simple_ordinal const = {1, 2, 3} as basic_struct; - simple_mixed const = {1, .b = 2, 3} as basic_struct; + simple_named const = !{.a = 1, .b = 2, .c = 3} as basic_struct; + simple_ordinal const = !{1, 2, 3} as basic_struct; + simple_mixed const = !{1, .b = 2, 3} as basic_struct; - complex_named const = {.a = 1, .b = 2, .c = 3} as complex_struct; + complex_named const = !{.a = 1, .b = 2, .c = 3} as complex_struct; /* should parentheses be required around typeof? */ - complex_ordinal const = {1, 2, 3} as typeof complex_named; - complex_mixed const = {1, .b = 2, 3} as complex_struct; + complex_ordinal const = !{1, 2, 3} as typeof complex_named; + complex_mixed const = !{1, .b = 2, 3} as complex_struct; /* force types */ - force_named complex_struct(u32, u32, u32) = {.a = 1, .b = 2, .c = 3}; - force_ordinal typeof force_named = {1, 2, 3}; - force_mixed typeof force_ordinal = {1, .b = 2, 3}; + force_named complex_struct![u32, u32, u32] = !{.a = 1, .b = 2, .c = 3}; + force_ordinal typeof force_named = !{1, 2, 3}; + force_mixed typeof force_ordinal = !{1, .b = 2, 3}; - force_inferred_named mut = {.a = 1, .b = 2, .c = 3} as - complex_struct(u32, u32, u32); + force_inferred_named mut = !{.a = 1, .b = 2, .c = 3} as + complex_struct![u32, u32, u32]; - force_inferred_ordinal mut = {1, 2, 3} as - complex_struct(u32, u32, u32); + force_inferred_ordinal mut = !{1, 2, 3} as + complex_struct![u32, u32, u32]; - force_inferred_mixed mut = {1, .b = 2, 3} as - complex_struct(u32, u32, u32); + force_inferred_mixed mut = !{1, .b = 2, 3} as + complex_struct![u32, u32, u32]; /* shouldn't be compileable due to not enough type info */ - // error_named const = {.a = 1, .b = 2, .c = 3}; + // error_named const = !{.a = 1, .b = 2, .c = 3}; /* types should be inferred */ - force_inferred_named = {.a = 2, .b = 3, .c = 4}; - force_inferred_ordinal = {2, 3, 4}; - force_inferred_mixed = {2, .b = 3, 4}; + force_inferred_named = !{.a = 2, .b = 3, .c = 4}; + force_inferred_ordinal = !{2, 3, 4}; + force_inferred_mixed = !{2, .b = 3, 4}; } -- cgit v1.3