From 92bd9b4be2b4cdfe4095c86c73787e979d6590c9 Mon Sep 17 00:00:00 2001 From: felipegchi Date: Mon, 6 Feb 2023 10:57:25 -0300 Subject: [PATCH] test: added test --- .../kind-tests/suite/kdl/ISSUE-491-2.golden | 17 ++++++++++ crates/kind-tests/suite/kdl/ISSUE-491-2.kind2 | 32 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 crates/kind-tests/suite/kdl/ISSUE-491-2.golden create mode 100644 crates/kind-tests/suite/kdl/ISSUE-491-2.kind2 diff --git a/crates/kind-tests/suite/kdl/ISSUE-491-2.golden b/crates/kind-tests/suite/kdl/ISSUE-491-2.golden new file mode 100644 index 00000000..3feed11d --- /dev/null +++ b/crates/kind-tests/suite/kdl/ISSUE-491-2.golden @@ -0,0 +1,17 @@ +ctr {String.nil} +ctr {Pair.new fst snd} +ctr {String.cons head tail} + +fun (Test n) { + (Test ~) = (!@x1 (!@x1.0 (Pair.match x1.0 @x2 (!@x2.0 @~ (String.match x2.0 #1 @~ @~ #2) x2)) x1) {Pair.new {String.cons #84 {String.cons #101 {String.cons #115 {String.cons #116 {String.cons #101 {String.nil}}}}}} #0}) +} + +fun (Pair.match scrutinee new_) { + (Pair.match {Pair.new x0 x1} x2) = (!@x2.0 (!@x1.0 (!@x0.0 (!(!x2.0 x0.0) x1.0) x0) x1) x2) +} + +fun (String.match scrutinee nil_ cons_) { + (String.match {String.nil} x0 ~) = (!@x0.0 x0.0 x0) + (String.match {String.cons x0 x1} ~ x3) = (!@x3.0 (!@x1.0 (!@x0.0 (!(!x3.0 x0.0) x1.0) x0) x1) x3) +} + diff --git a/crates/kind-tests/suite/kdl/ISSUE-491-2.kind2 b/crates/kind-tests/suite/kdl/ISSUE-491-2.kind2 new file mode 100644 index 00000000..476d56e4 --- /dev/null +++ b/crates/kind-tests/suite/kdl/ISSUE-491-2.kind2 @@ -0,0 +1,32 @@ +Char : Type +Char = U60 + +#kdl_name = T2 +#kdl_erase +#derive[match] +record Pair (a) (b) { + constructor new + fst : a + snd : b +} + +#derive[match] +type String { + nil + cons (head: (Char)) (tail: (String)) +} + +#keep +Test (n: U60) : U60 +Test n = + let state = Pair.new "Teste" 0 + match Pair state { + new => + match String state.fst { + nil => + 1 + cons => + 2 + } + } + \ No newline at end of file