From 89aa63b18b764336ae2e0e6f64c803f5d44001f4 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Thu, 19 Sep 2019 03:10:07 +0200 Subject: [PATCH] :white_check_mark: Add tests --- tests/match/assign.gw | 4 ++++ tests/match/litteral.gw | 6 ++++++ tests/match/litteral_when.gw | 6 ++++++ tests/match/litteral_when_fail.gw | 6 ++++++ tests/match/too_many.gw | 4 ++++ tests/match/tuple.c | 12 ++++++++++++ 6 files changed, 38 insertions(+) create mode 100644 tests/match/assign.gw create mode 100644 tests/match/litteral.gw create mode 100644 tests/match/litteral_when.gw create mode 100644 tests/match/litteral_when_fail.gw create mode 100644 tests/match/too_many.gw create mode 100644 tests/match/tuple.c diff --git a/tests/match/assign.gw b/tests/match/assign.gw new file mode 100644 index 00000000..fb9915fa --- /dev/null +++ b/tests/match/assign.gw @@ -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 index 00000000..559b0b8b --- /dev/null +++ b/tests/match/litteral.gw @@ -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 index 00000000..0c58221e --- /dev/null +++ b/tests/match/litteral_when.gw @@ -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 index 00000000..d86c2f0d --- /dev/null +++ b/tests/match/litteral_when_fail.gw @@ -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 index 00000000..67e905ca --- /dev/null +++ b/tests/match/too_many.gw @@ -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 index 00000000..90dbff2a --- /dev/null +++ b/tests/match/tuple.c @@ -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." >>>; +} -- 2.43.0