diff options
| author | SAJJA EASWAR <eshwarsajja20@gmail.com> | 2026-01-25 22:59:36 +0530 |
|---|---|---|
| committer | SAJJA EASWAR <eshwarsajja20@gmail.com> | 2026-01-25 22:59:36 +0530 |
| commit | ebc8b94baa6bc694cb4829e2eb2934a1f17fa6a1 (patch) | |
| tree | 71b952ad455bf17d5bdea01472f0e2297f25eabe /tests/features/test_enum_tuples.zc | |
| parent | 863118c95caac0d69a35f6ae4d2e83844734a8a1 (diff) | |
| parent | 489336b2101bf16edeec7bfc4379408eb19b936e (diff) | |
Merge branch 'main' into pr-109
Diffstat (limited to 'tests/features/test_enum_tuples.zc')
| -rw-r--r-- | tests/features/test_enum_tuples.zc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/features/test_enum_tuples.zc b/tests/features/test_enum_tuples.zc new file mode 100644 index 0000000..7e43bad --- /dev/null +++ b/tests/features/test_enum_tuples.zc @@ -0,0 +1,32 @@ + +enum Shape { + Circle(float), + Rect(float, float) +} + +fn main() { + let r = Shape.Rect(10.0, 20.0); + + let matched = 0; + match r { + Shape::Rect(w, h) => { + assert(w == 10.0, "w == 10.0"); + assert(h == 20.0, "h == 20.0"); + matched = 1; + } + Shape::Circle(r) => { + exit(1); + } + } + assert(matched == 1, "Matched Rect"); + + let c = Shape.Circle(5.0); + match c { + Shape::Circle(val) => { + assert(val == 5.0, "val == 5.0"); + } + _ => { + exit(1); + } + } +} |
