modal/examples/tests.modal

81 lines
1.4 KiB
Plaintext

?(?-) (This example tests various aspects of the implementation.)
?(?-) (Inline rules)
<> ((?x -> ?y)) (<> ?x ?y)
(nap -> (tap =))
nap tap test
?(?-) (Empty replacements)
<> (?x pop-plain)
<> (?x pop) ()
<> (ghost) ()
abc def pop-plain = abc test
abc def pop = abc test
(ghost) = () 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
?(?-) (Test Primitives)
<> (?: print) (?:)
<> (?x = ?x test) (#ok)
<> (?x = ?y test) (#fail)
?(?-) (List reversal)
<> (reverse List () ?^) (?^)
<> (reverse (?*)) (reverse List (?*) ())
<> (reverse List (?x ?y) ?z) (reverse List ?y (?x ?z))
reverse (modal) = ladom test