modal/examples/tests.modal

96 lines
1.9 KiB
Plaintext
Raw Normal View History

2024-04-15 19:26:25 -04:00
?(?-) (This example tests various aspects of the implementation.)
2024-04-23 11:37:40 -04:00
<> (ghost) ()
2024-04-23 11:21:35 -04:00
?(?-) (Whitespace)
(a b c ) = (a b c) test
( a b c) = (a b c) test
( a b c ) = (a b c) test
(a b c ( a b c ) ) = (a b c (a b c)) test
2024-04-15 23:39:25 -04:00
?(?-) (Inline rules)
<> ((?x -> ?y)) (<> ?x ?y)
(nap -> (tap =))
nap tap test
2024-04-15 22:47:11 -04:00
?(?-) (Empty replacements)
(ab cd () ghost) = (ab cd ()) test
(ab cd ghost ()) = (ab cd ()) test
(ab ghost cd ()) = (ab cd ()) test
(ghost ab cd ()) = (ab cd ()) test
(ghost) = () test
(q ?((?x ?y ?z) (?x ?y)) a b c) = (q a b) test
(q ?((?x ?y ?z) (?x ?z)) a b c) = (q a c) test
(q ?((?x ?y ?z) (?y ?z)) a b c) = (q b c) test
<> (prefix/pop ?x) ()
<> (?x suffix/pop) ()
2024-04-15 22:47:11 -04:00
2024-04-21 12:43:00 -04:00
(prefix/pop foo) = (ok) test
(foo suffix/pop) = (ok) test
2024-04-15 22:47:11 -04:00
?(?-) (Basic replacements)
<> (replace-name (foo)) ((bar) =)
replace-name (foo) (bar) test
2024-04-15 20:18:18 -04:00
?(?-) (Basic register setups)
2024-04-21 12:43:00 -04:00
<> (dup (?x)) (?x ?x)
<> (swap (?x ?y)) (?y ?x)
<> (compare (?x ?x ?x)) (#t)
<> (rotate (?x (?y (?z)))) (?y (?z (?x)))
2024-04-15 20:18:18 -04:00
2024-04-21 12:43:00 -04:00
(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
2024-04-15 20:18:18 -04:00
2024-04-15 23:13:08 -04:00
?(?-) (Empty register replacement)
<> (replace-empty ?x) (?y)
replace-empty abc = ?y test
2024-04-20 21:56:04 -04:00
?(?-) (Substring registers)
2024-04-20 15:38:05 -04:00
<> (connect ?x ?y ?z) (?x-?y?z)
2024-04-20 21:56:04 -04:00
<> (prefix-?x) (?x-suffix)
2024-04-20 15:38:05 -04:00
connect foo bar baz = foo-barbaz test
2024-04-20 21:56:04 -04:00
prefix-anything = anything-suffix test
2024-04-20 15:38:05 -04:00
2024-04-15 20:18:18 -04:00
?(?-) (Lambdas)
?(?x (?x ?x)) abc = (abc abc) test
2024-04-15 22:47:11 -04:00
abc ?(?x) def = abc test
?(?-) (Explode)
?(?* ?*) cow = (c (o (w ()))) test
?(?* ?*) (12 34 45) = (12 (34 (45 ()))) test
2024-04-15 22:47:11 -04:00
?(?-) (op: join)
2024-04-04 20:15:16 -04:00
?(?^ ?^) (b (a (t ()))) = bat test
?(?^ ?^) (12 (34 (56 ()))) = 123456 test
2024-04-15 23:39:25 -04:00
2024-04-17 14:49:32 -04:00
?(?-) (Test Primitives)
<> (?: print) (?:)
2024-04-18 14:45:32 -04:00
<> (?x = ?x test) (#ok\n print)
<> (?x = ?y test) (#fail\n print)
2024-04-17 14:49:32 -04:00
2024-04-15 23:39:25 -04:00
?(?-) (List reversal)
2024-04-17 13:56:51 -04:00
<> (reverse List () ?^) (?^)
2024-04-15 23:39:25 -04:00
<> (reverse (?*)) (reverse List (?*) ())
<> (reverse List (?x ?y) ?z) (reverse List ?y (?x ?z))
2024-04-23 11:21:35 -04:00
reverse (modal) = ladom test