modal/examples/tests.modal

146 lines
3.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
2024-05-10 16:39:01 -04:00
?((aaa (bbb)) ok) aaa(bbb) = ok (formatter 1/6) test
?(((bbb) aaa) ok) (bbb)aaa = ok (formatter 2/6) test
?(((?a ?b ?c)) ((?a ?b ?c))) (a b c ) = (a b c) (formatter 3/6) test
?(((?a ?b ?c)) ((?a ?b ?c))) ( a b c) = (a b c) (formatter 4/6) test
?(((?a ?b ?c)) ((?a ?b ?c))) ( a b c ) = (a b c) (formatter 5/6) test
?(((?a ?b ?c (?d ?e ?f))) ((?a ?b ?c (?d ?e ?f)))) (a b c ( a b c ) ) = (a b c (a b c)) (formatter 6/6) test
2024-04-15 23:39:25 -04:00
2024-04-15 22:47:11 -04:00
?(?-) (Empty replacements)
2024-05-10 16:39:01 -04:00
(ab cd () ghost) = (ab cd ()) (empty 1/10) test
(ab cd ghost ()) = (ab cd ()) (empty 2/10) test
(ab ghost cd ()) = (ab cd ()) (empty 3/10) test
(ghost ab cd ()) = (ab cd ()) (empty 4/10) test
(ghost) = () (empty 5/10) test
(q ?((?x ?y ?z) (?x ?y)) a b c) = (q a b) (empty 6/10) test
(q ?((?x ?y ?z) (?x ?z)) a b c) = (q a c) (empty 7/10) test
(q ?((?x ?y ?z) (?y ?z)) a b c) = (q b c) (empty 8/10) test
<> (prefix/pop ?x) ()
<> (?x suffix/pop) ()
2024-04-15 22:47:11 -04:00
2024-05-10 16:39:01 -04:00
(ab prefix/pop cd ef) = (ab ef) (empty 9/10) test
(ab cd suffix/pop ef) = (ab ef) (empty 10/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-05-10 16:39:01 -04:00
(dup (abc)) = (abc abc) (basic 1/5) test
(swap (abc def)) = (def abc) (basic 2/5) test
(compare (abc abc abc)) = (#t) (basic 3/5) test
(rotate (abc (def (ghi)))) = (def (ghi (abc))) (basic 4/5) test
(unused hey) = (?y) (basic 5/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-05-10 16:39:01 -04:00
connect foo bar baz = foo-barbaz (substring 1/3) test
prefix-anything = anything-suffix (substring 2/3) test
?(foo QQQ) foobar = foobar (substring 3/3) test
2024-04-20 15:38:05 -04:00
2024-04-15 20:18:18 -04:00
?(?-) (Lambdas)
2024-05-10 16:39:01 -04:00
(?(?x (?x ?x)) abc) = (abc abc) (lambda 1/2) test
abc ?(?x) def = abc (lambda 2/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-05-10 16:39:01 -04:00
(?(?* ?*) cow) = (c (o (w ()))) (explode word 1/3) test
(?(?* ?*) (12 34 45)) = (12 (34 (45 ()))) (explode tuple 2/3) test
(?(?* ?*) ()) = () (explode empty 3/3) test
2024-04-15 22:47:11 -04:00
?(?-) (op: join)
2024-04-04 20:15:16 -04:00
2024-05-10 16:39:01 -04:00
?(?^ ?^) (b (a (t ()))) = bat (join 1/3) test
?(?^ ?^) (12 (34 (56 ()))) = 123456 (join 2/3) test
(?(?^ ?^) ()) = () (join 3/3) test
2024-04-23 16:45:03 -04:00
?(?-) (op: unwrap)
2024-05-10 16:39:01 -04:00
?(?. ?.) (abcd) = abcd (unwrap 1/2) test
(?(?. ?.) ()) = () (unwrap 2/2) test
2024-04-23 16:29:30 -04:00
2024-04-27 14:55:32 -04:00
?(?-) (Incomplete definitions)
<> (incomplete-basic)
<> (incomplete-reg ?x)
2024-05-10 17:25:54 -04:00
<> <>
<> () ()
2024-04-27 14:55:32 -04:00
2024-05-10 16:39:01 -04:00
(incomplete-basic) = () (incomplete 1/4) test
(incomplete-reg abcdef) = () (incomplete 2/4) test
(?(?x) incomplete-lambda) = () (incomplete 3/4) test
(?() abc) = (abc) (incomplete 4/4) test
2024-04-27 14:55:32 -04:00
2024-04-23 16:29:30 -04:00
?(?-) (Inline rules)
<> ((?x -> ?y)) (<> ?x ?y)
(nap -> (tap =))
2024-05-10 19:26:40 -04:00
nap tap (inline 1/2) test
2024-04-23 16:29:30 -04:00
2024-05-10 19:26:40 -04:00
<> (?x -> ?y) (<> ?x ?y)
fruit_a -> apple
fruit_b -> banana
(apple banana) -> (fruit-salad)
(fruit_a fruit_b) = (fruit-salad) (inline 2/2) test
2024-04-23 16:29:30 -04:00
2024-04-27 14:24:00 -04:00
?(?-) (Undefinition)
<> (undefine-me) (abc)
<> (undefine-me) (def)
<> (undefine-me) (ghi)
>< (undefine-me)
2024-05-10 16:39:01 -04:00
(undefine-me) = (def) (undefinition 1/3) test
2024-04-27 14:24:00 -04:00
>< (undefine-me)
2024-05-10 16:39:01 -04:00
(undefine-me) = (ghi) (undefinition 2/3) test
2024-04-27 14:24:00 -04:00
2024-04-27 14:29:46 -04:00
>< (undefine-unknown)
?(* (>< (undefine-me))) *
2024-05-10 16:39:01 -04:00
(undefine-me) = (undefine-me) (undefinition 3/3) test
2024-04-27 14:29:46 -04:00
2024-04-29 00:15:56 -04:00
?(?-) (Arithmetic)
2024-05-10 16:39:01 -04:00
?((?: ?0 ?1 ?2) ?:) + 1 2 3 = 6 (Arithmetic 1/4) test
?((?0 ?: ?1) ?:) 16 - 8 = 8 (Arithmetic 2/4) test
?((?0 ?1 ?:) ?:) 12 10 * = 120 (Arithmetic 3/4) test
2024-04-29 12:46:27 -04:00
<> (?0 ?1 `?:) (?:)
2024-05-10 16:39:01 -04:00
(12 45 `+ -2 `+) = (55) (Arithmetic 4/4) test
?(?-) (List reversal)
<> (reverse List () ?^) (?^)
<> (reverse (?*)) (reverse List (?*) ())
<> (reverse List (?x ?y) ?z) (reverse List ?y (?x ?z))
reverse (modal) = ladom (reverse 1) test
2024-04-29 00:15:56 -04:00
2024-04-23 16:29:30 -04:00
?(?-) (Late Test Primitives)
2024-04-29 00:15:56 -04:00
<> (?x = ?y ?n test) (?(?: ?:) (#fail ?n found: ?x expect: ?y\n))