modal/examples/tests.modal

76 lines
1.3 KiB
Plaintext

?(?-) (This example tests various aspects of the implementation.)
<> (?: print) (?:)
<> (?x = ?x test) (#ok)
<> (?x = ?y test) (#fail)
?(?-) (Inline rules)
<> ((?x -> ?y)) (<> ?x ?y)
(nap -> (tap =))
nap tap test
?(?-) (Empty replacements)
<> (?x pop-plain)
<> (?x pop) ()
abc def pop-plain = abc test
abc def pop = abc test
?(?-) (Basic replacements)
<> (replace-name (foo)) ((bar) =)
replace-name (foo) (bar) test
?(?-) (Basic register setups)
<> (dup (?x)) ((?x ?x) =)
<> (swap (?x ?y)) ((?y ?x) =)
<> (compare (?x ?x ?x)) ((#t) =)
dup (abc) (abc abc) test
swap (abc def) (def abc) test
compare (abc abc abc) (#t) test
?(?-) (Empty register replacement)
<> (replace-empty ?x) (?y)
replace-empty abc = ?y test
?(?-) (Guards setups)
<> (join (String ?x) (String ?y)) ((?x ?y) =)
join (String abc) (String def) (abc def) test
?(?-) (Lambdas)
?((?x) ((?x ?x) =)) abc (abc abc) test
abc ?(?x) def = abc test
?(?-) (Explode)
<> (explode ?*) ((?*) =)
explode cow (c (o (w ()))) test
explode (12 34 45) (12 (34 (45 ()))) test
?(?-) (Implode)
<> (implode ?^) (?^ =)
implode (b (a (t ()))) bat test
implode (12 (34 (56 ()))) 123456 test
?(?-) (List reversal)
<> (reverse List () ?^) (?^)
<> (reverse (?*)) (reverse List (?*) ())
<> (reverse List (?x ?y) ?z) (reverse List ?y (?x ?z))
reverse (modal) = ladom test