modal/examples/tests.modal

94 lines
1.7 KiB
Plaintext

?(?-) (This example tests various aspects of the implementation.)
?(?-) (Inline rules)
<> ((?x -> ?y)) (<> ?x ?y)
(nap -> (tap =))
nap tap test
?(?-) (Empty replacements)
<> (?x rightless/pop)
<> (?x pop) ()
<> (ghost) ()
<> (prefix/pop ?x) (ok)
<> (?x suffix/pop) (ok)
(abc rightless/pop) = () test
(prefix/pop foo) = (ok) test
(foo suffix/pop) = (ok) 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)
<> (rotate (?x (?y (?z)))) (?y (?z (?x)))
(dup (abc)) = (abc abc) test
(swap (abc def)) = (def abc) test
compare (abc abc abc) = #t test
(rotate (abc (def (ghi)))) = (def (ghi (abc))) test
?(?-) (Empty register replacement)
<> (replace-empty ?x) (?y)
replace-empty abc = ?y test
?(?-) (Substring registers)
<> (connect ?x ?y ?z) (?x-?y?z)
<> (prefix-?x) (?x-suffix)
connect foo bar baz = foo-barbaz test
prefix-anything = anything-suffix 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\n print)
<> (?x = ?y test) (#fail\n print)
?(?-) (List reversal)
<> (reverse List () ?^) (?^)
<> (reverse (?*)) (reverse List (?*) ())
<> (reverse List (?x ?y) ?z) (reverse List ?y (?x ?z))
reverse (modal) = ladom test