]> Nishi Git Mirror - gwion.git/commitdiff
:white_check_mark: Add tests 145/head
authorfennecdjay <astor.jeremie@wanadoo.fr>
Thu, 19 Sep 2019 01:10:07 +0000 (03:10 +0200)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Thu, 19 Sep 2019 01:10:07 +0000 (03:10 +0200)
tests/match/assign.gw [new file with mode: 0644]
tests/match/litteral.gw [new file with mode: 0644]
tests/match/litteral_when.gw [new file with mode: 0644]
tests/match/litteral_when_fail.gw [new file with mode: 0644]
tests/match/too_many.gw [new file with mode: 0644]
tests/match/tuple.c [new file with mode: 0644]

diff --git a/tests/match/assign.gw b/tests/match/assign.gw
new file mode 100644 (file)
index 0000000..fb9915f
--- /dev/null
@@ -0,0 +1,4 @@
+#! [contains] ok
+match "ok" {
+  case v: <<< v >>>;
+}
diff --git a/tests/match/litteral.gw b/tests/match/litteral.gw
new file mode 100644 (file)
index 0000000..559b0b8
--- /dev/null
@@ -0,0 +1,6 @@
+#! [contains] ok
+
+match 1 {
+  case 1: <<< "ok" >>>;
+  case 2: <<< "not ok" >>>;
+}
diff --git a/tests/match/litteral_when.gw b/tests/match/litteral_when.gw
new file mode 100644 (file)
index 0000000..0c58221
--- /dev/null
@@ -0,0 +1,6 @@
+#! [contains] ok
+
+match 1 {
+  case 1 when 1 : <<< "ok" >>>;
+  case 1: <<< "ok" >>>;
+}
diff --git a/tests/match/litteral_when_fail.gw b/tests/match/litteral_when_fail.gw
new file mode 100644 (file)
index 0000000..d86c2f0
--- /dev/null
@@ -0,0 +1,6 @@
+#! [contains] ok
+
+match 1 {
+  case 1 when 0 : <<< "not ok" >>>;
+  case 1: <<< "ok" >>>;
+}
diff --git a/tests/match/too_many.gw b/tests/match/too_many.gw
new file mode 100644 (file)
index 0000000..67e905c
--- /dev/null
@@ -0,0 +1,4 @@
+#! [contains] too many expression to match
+match 1 {
+  case a,b: <<< "WHAT?" >>>;
+}
diff --git a/tests/match/tuple.c b/tests/match/tuple.c
new file mode 100644 (file)
index 0000000..90dbff2
--- /dev/null
@@ -0,0 +1,12 @@
+class C {
+  string name;
+  int age;
+}
+
+C charles;
+"charles" => charles.name;
+21 => charles.age;
+
+match charles {
+  case >(name, age): <<< name , " is ", age, " years old." >>>;
+}