modal/examples/tests.modal

149 lines
3.8 KiB
Plaintext

?(?-) (This example tests various aspects of the implementation.)
?(?-) (Early Test Primitives)
<> (?x = ?x ?n test) (?(?: ?:) (pass ?n\n))
<> (ghost) ()
?(?-) (Formatter)
?((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
?(?-) (Empty replacements)
(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) ()
(ab prefix/pop cd ef) = (ab ef) (empty 9/10) test
(ab cd suffix/pop ef) = (ab ef) (empty 10/10) test
?(?-) (Basic register setups)
<> (dup (?x)) (?x ?x)
<> (swap (?x ?y)) (?y ?x)
<> (compare (?x ?x ?x)) (@t)
<> (compare (?x ?y ?z)) (@f)
<> (rotate (?x (?y (?z)))) (?y (?z (?x)))
<> (unused ?x) ?y
(dup (abc)) = (abc abc) (basic 1/6) test
(swap (abc def)) = (def abc) (basic 2/6) test
(compare (abc abc abc)) = (@t) (basic 3/6) test
(compare (abc abc def)) = (@f) (basic 4/6) test
(rotate (abc (def (ghi)))) = (def (ghi (abc))) (basic 5/6) test
(unused hey) = (?y) (basic 6/6) test
?(?-) (Substring registers)
<> (connect ?x ?y ?z) (?x-?y?z)
<> (prefix-?x) (?x-suffix)
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
?(?-) (Lambdas)
(?(?x (?x ?x)) abc) = (abc abc) (lambda 1/2) test
abc ?(?x) def = abc (lambda 2/2) test
?(?-) (op: explode)
(?(?* ?*) 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
?(?-) (op: join)
?(?^ ?^) (b (a (t ()))) = bat (join 1/3) test
?(?^ ?^) (12 (34 (56 ()))) = 123456 (join 2/3) test
(?(?^ ?^) ()) = () (join 3/3) test
?(?-) (op: unwrap)
?(?. ?.) (abcd) = abcd (unwrap 1/2) test
(?(?. ?.) ()) = () (unwrap 2/2) test
?(?-) (Incomplete definitions)
<> (incomplete-basic) ()
<> (incomplete-reg ?x) ()
<> () ()
(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
?(?-) (Inline rules)
<> ((?x -> ?y)) (<> ?x ?y)
(nap -> (tap =))
nap tap (inline 1/2) test
<> (?x -> ?y) (<> ?x ?y)
fruit_a -> apple
fruit_b -> banana
(apple banana) -> (fruit-salad)
(fruit_a fruit_b) = (fruit-salad) (inline 2/2) test
?(?-) (Undefinition)
<> (undefine-me) (abc)
<> (undefine-me) (def)
<> (undefine-me) (ghi)
>< (undefine-me)
(undefine-me) = (def) (undefinition 1/3) test
>< (undefine-me)
(undefine-me) = (ghi) (undefinition 2/3) test
>< (undefine-unknown)
?(* (>< (undefine-me))) *
(undefine-me) = (undefine-me) (undefinition 3/3) test
?(?-) (Arithmetic)
?((?: ?0 ?1 ?2) ?:) + 1 2 3 = 6 (Arithmetic 1/6) test
?((?0 ?: ?1) ?:) 16 - 8 = 8 (Arithmetic 2/6) test
?((?0 ?1 ?:) ?:) 12 10 * = 120 (Arithmetic 3/6) test
<> (?0 ?1 `?:) (?:)
(12 45 `+ -2 `+) = (55) (Arithmetic 4/6) test
(#12 45 `+ -2 `+) = (#3d) (Arithmetic 5/6) test
(12 #45 `+ -2 `+) = (79) (Arithmetic 6/6) test
?(?-) (List reversal)
<> (reverse List () ?^) (?^)
<> (reverse (?*)) (reverse List (?*) ())
<> (reverse List (?x ?y) ?z) (reverse List ?y (?x ?z))
reverse (modal) = ladom (reverse 1) test
?(?-) (Late Test Primitives)
<> (?x = ?y ?n test) (?(?: ?:) (fail ?n found: ?x, expects: ?y\n))