138 lines
3.3 KiB
Plaintext
138 lines
3.3 KiB
Plaintext
?(?-) (This example tests various aspects of the implementation.)
|
|
|
|
?(?-) (Early Test Primitives)
|
|
|
|
<> (?x = ?x ?n test) (?(?: ?:) (#pass ?n\n))
|
|
|
|
<> (ghost) ()
|
|
|
|
?(?-) (Formatter)
|
|
|
|
?((?x ?y) two) aaa(bbb) = two (formatter 1) test
|
|
?((?x ?y) two) (bbb)aaa = two (formatter 2) test
|
|
(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
|
|
|
|
?(?-) (Empty replacements)
|
|
|
|
(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
|
|
|
|
(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) ()
|
|
|
|
(ab prefix/pop cd ef) = (ab ef) (empty 9) test
|
|
(ab cd suffix/pop ef) = (ab ef) (empty 10) 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)))
|
|
<> (unused ?x) ?y
|
|
|
|
(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
|
|
|
|
?(?-) (Substring registers)
|
|
|
|
<> (connect ?x ?y ?z) (?x-?y?z)
|
|
<> (prefix-?x) (?x-suffix)
|
|
|
|
connect foo bar baz = foo-barbaz (substring 1) test
|
|
prefix-anything = anything-suffix (substring 2) test
|
|
?(foo QQQ) foobar = foobar (substring 3) test
|
|
|
|
?(?-) (Lambdas)
|
|
|
|
(?(?x (?x ?x)) abc) = (abc abc) (lambda 1) test
|
|
abc ?(?x) def = abc (lambda 2) test
|
|
|
|
?(?-) (op: explode)
|
|
|
|
(?(?* ?*) cow) = (c (o (w ()))) (explode word) test
|
|
(?(?* ?*) (12 34 45)) = (12 (34 (45 ()))) (explode tuple) test
|
|
(?(?* ?*) ()) = () (explode empty) test
|
|
|
|
?(?-) (op: join)
|
|
|
|
?(?^ ?^) (b (a (t ()))) = bat (join 1) test
|
|
?(?^ ?^) (12 (34 (56 ()))) = 123456 (join 2) test
|
|
(?(?^ ?^) ()) = () (join empty) test
|
|
|
|
?(?-) (op: unwrap)
|
|
|
|
?(?. ?.) (abcd) = abcd (unwrap 1) test
|
|
(?(?. ?.) ()) = () (unwrap empty) test
|
|
|
|
?(?-) (List reversal)
|
|
|
|
<> (reverse List () ?^) (?^)
|
|
<> (reverse (?*)) (reverse List (?*) ())
|
|
<> (reverse List (?x ?y) ?z) (reverse List ?y (?x ?z))
|
|
|
|
reverse (modal) = ladom (reverse 1) test
|
|
|
|
?(?-) (Incomplete definitions)
|
|
|
|
<> <>
|
|
<> () ()
|
|
<> (incomplete-basic)
|
|
<> (incomplete-reg ?x)
|
|
<> (waste-rule) *
|
|
|
|
(incomplete-basic) = () (incomplete 1) test
|
|
(incomplete-reg abcdef) = () (incomplete 2) test
|
|
(?(?x) incomplete-lambda) = () (incomplete 3) test
|
|
(?() abc) = (abc) (incomplete 4) test
|
|
|
|
?(?-) (Inline rules)
|
|
|
|
<> ((?x -> ?y)) (<> ?x ?y)
|
|
(nap -> (tap =))
|
|
|
|
nap tap (inline 1) test
|
|
|
|
?(?-) (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
|
|
|
|
>< (undefine-unknown)
|
|
|
|
?(* (>< (undefine-me))) *
|
|
|
|
(undefine-me) = (undefine-me) (undefinition 3) test
|
|
|
|
?(?-) (Arithmetic)
|
|
|
|
?((?: ?0 ?1 ?2) (?:)) + 1 2 3 = 6 (Arithmetic 1) test
|
|
?((?0 ?: ?1) (?:)) 16 - 8 = 8 (Arithmetic 2) test
|
|
?((?0 ?1 ?:) (?:)) 12 10 * = 120 (Arithmetic 3) test
|
|
|
|
?(?-) (Late Test Primitives)
|
|
|
|
<> (?x = ?y ?n test) (?(?: ?:) (#fail ?n found: ?x expect: ?y\n))
|
|
|