diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-05-06 22:06:25 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-05-06 22:06:25 +0300 |
| commit | 82cdf010329c4ac6827698689e7e39644fad07b6 (patch) | |
| tree | 641c75ea227892a3d8e1a28dcd1001d6ec114600 /tests/structs.ek | |
| parent | f98ec211bf60858b43b87ae125a5e13be9b41ee5 (diff) | |
| download | ek-82cdf010329c4ac6827698689e7e39644fad07b6.tar.gz ek-82cdf010329c4ac6827698689e7e39644fad07b6.zip | |
rename *.cu to *.ek
+ Name changes can be sort of difficult
Diffstat (limited to 'tests/structs.ek')
| -rw-r--r-- | tests/structs.ek | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/structs.ek b/tests/structs.ek new file mode 100644 index 0000000..8a3a1bb --- /dev/null +++ b/tests/structs.ek @@ -0,0 +1,48 @@ +typedef any {} + +struct basic_struct { + a i64; + b i64; + c i64; +} + +struct complex_struct (A any, B any, C any) { + a A; + b B; + c C; +} + +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; + + 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; + + /* 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_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_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}; + + /* 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}; +} |
