modal/examples/tests.modal

111 lines
2.7 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 16:29:30 -04:00
?(?-) (Early Test Primitives)
2024-04-23 11:21:35 -04:00
2024-04-23 16:29:30 -04:00
<> (?x = ?x ?n test) (?(?: ?:) (#pass ?n\n))
2024-04-23 11:21:35 -04:00
2024-04-23 16:29:30 -04:00
<> (ghost) ()
2024-04-15 23:39:25 -04:00
2024-04-26 14:06:30 -04:00
?(?-) (Formatter)
2024-04-15 23:39:25 -04:00
?((?x ?y) two) aaa(bbb) = two (formatter 1) test
?((?x ?y) two) (bbb)aaa = two (formatter 2) test
2024-04-26 14:06:30 -04:00
(a b c ) = (a b c) (formatter 3) test
( a b c) = (a b c) (formatter 4) test
( a b c ) = (a b c) (formatter 5) test
(a b c ( a b c ) ) = (a b c (a b c)) (formatter 6) test
2024-04-15 23:39:25 -04:00
2024-04-15 22:47:11 -04:00
?(?-) (Empty replacements)
2024-04-23 16:29:30 -04:00
(ab cd () ghost) = (ab cd ()) (empty 1) test
(ab cd ghost ()) = (ab cd ()) (empty 2) test
(ab ghost cd ()) = (ab cd ()) (empty 3) test
(ghost ab cd ()) = (ab cd ()) (empty 4) test
(ghost) = () (empty 5) test
2024-04-23 16:29:30 -04:00
(q ?((?x ?y ?z) (?x ?y)) a b c) = (q a b) (empty 6) test
(q ?((?x ?y ?z) (?x ?z)) a b c) = (q a c) (empty 7) test
(q ?((?x ?y ?z) (?y ?z)) a b c) = (q b c) (empty 8) test
<> (prefix/pop ?x) ()
<> (?x suffix/pop) ()
2024-04-15 22:47:11 -04:00
2024-04-23 16:29:30 -04:00
(ab prefix/pop cd ef) = (ab ef) (empty 9) test
(ab cd suffix/pop ef) = (ab ef) (empty 10) test
2024-04-15 22:47:11 -04:00
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-23 16:29:30 -04:00
<> (unused ?x) ?y
2024-04-15 20:18:18 -04:00
2024-04-23 16:29:30 -04:00
(dup (abc)) = (abc abc) (basic 1) test
(swap (abc def)) = (def abc) (basic 2) test
(compare (abc abc abc)) = (#t) (basic 3) test
(rotate (abc (def (ghi)))) = (def (ghi (abc))) (basic 4) test
(unused hey) = (?y) (basic 5) test
2024-04-15 23:13:08 -04:00
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
2024-04-23 16:29:30 -04:00
connect foo bar baz = foo-barbaz (substring 1) test
prefix-anything = anything-suffix (substring 2) test
2024-04-26 01:35:15 -04:00
?(foo QQQ) foobar = foobar (substring 3) test
2024-04-20 15:38:05 -04:00
2024-04-15 20:18:18 -04:00
?(?-) (Lambdas)
2024-04-23 16:29:30 -04:00
(?(?x (?x ?x)) abc) = (abc abc) (lambda 1) test
abc ?(?x) def = abc (lambda 2) test
2024-04-15 22:47:11 -04:00
2024-04-23 16:45:03 -04:00
?(?-) (op: explode)
2024-04-15 22:47:11 -04:00
2024-04-23 16:45:03 -04:00
(?(?* ?*) cow) = (c (o (w ()))) (explode word) test
(?(?* ?*) (12 34 45)) = (12 (34 (45 ()))) (explode tuple) test
(?(?* ?*) ()) = () (explode empty) test
2024-04-15 22:47:11 -04:00
?(?-) (op: join)
2024-04-04 20:15:16 -04:00
2024-04-23 16:29:30 -04:00
?(?^ ?^) (b (a (t ()))) = bat (join 1) test
?(?^ ?^) (12 (34 (56 ()))) = 123456 (join 2) test
2024-04-23 16:45:03 -04:00
(?(?^ ?^) ()) = () (join empty) test
?(?-) (op: unwrap)
?(?. ?.) (abcd) = abcd (unwrap 1) test
(?(?. ?.) ()) = () (unwrap empty) test
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 16:29:30 -04:00
reverse (modal) = ladom (reverse 1) test
?(?-) (Inline rules)
<> ((?x -> ?y)) (<> ?x ?y)
(nap -> (tap =))
nap tap (inline 1) test
2024-04-27 14:24:00 -04:00
?(?-) (Undefinition)
<> (undefine-me) (abc)
<> (undefine-me) (def)
<> (undefine-me) (ghi)
>< (undefine-me)
(undefine-me) = (def) (undefinition 1) test
>< (undefine-me)
(undefine-me) = (ghi) (undefinition 2) test
2024-04-23 16:29:30 -04:00
?(?-) (Late Test Primitives)
<> (?x = ?y ?n test) (?(?: ?:) (#fail ?n found: ?x expect: ?y\n))