summaryrefslogtreecommitdiff
path: root/tests/features
diff options
context:
space:
mode:
Diffstat (limited to 'tests/features')
-rw-r--r--tests/features/test_enum_tuples.zc32
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..12d9088
--- /dev/null
+++ b/tests/features/test_enum_tuples.zc
@@ -0,0 +1,32 @@
+
+enum Shape {
+ Circle(float),
+ Rect(float, float)
+}
+
+fn main() {
+ var r = Shape.Rect(10.0, 20.0);
+
+ var 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");
+
+ var c = Shape.Circle(5.0);
+ match c {
+ Shape::Circle(val) => {
+ assert(val == 5.0, "val == 5.0");
+ }
+ _ => {
+ exit(1);
+ }
+ }
+}