test: added test

This commit is contained in:
felipegchi 2023-02-06 10:57:25 -03:00
parent be8b8aa1c7
commit 92bd9b4be2
2 changed files with 49 additions and 0 deletions

View File

@ -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)
}

View File

@ -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
}
}