diff --git a/examples/tests.modal b/examples/tests.modal index bceb0cb..822a8dc 100644 --- a/examples/tests.modal +++ b/examples/tests.modal @@ -1,44 +1,35 @@ ?(?-) (This example tests various aspects of the implementation.) +?(?-) (Early Test Primitives) + +<> (?x = ?x ?n test) (?(?: ?:) (#pass ?n\n)) + <> (ghost) () ?(?-) (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 - -?(?-) (Inline rules) - -<> ((?x -> ?y)) (<> ?x ?y) -(nap -> (tap =)) - -nap tap test +(a b c ) = (a b c) (whitespace 1) test +( a b c) = (a b c) (whitespace 2) test +( a b c ) = (a b c) (whitespace 3) test +(a b c ( a b c ) ) = (a b c (a b c)) (whitespace 4) test ?(?-) (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 +(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) 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 +(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) () -(prefix/pop foo) = (ok) test -(foo suffix/pop) = (ok) test - -?(?-) (Basic replacements) - -<> (replace-name (foo)) ((bar) =) - -replace-name (foo) (bar) test +(ab prefix/pop cd ef) = (ab ef) (empty 9) test +(ab cd suffix/pop ef) = (ab ef) (empty 10) test ?(?-) (Basic register setups) @@ -46,46 +37,36 @@ replace-name (foo) (bar) test <> (swap (?x ?y)) (?y ?x) <> (compare (?x ?x ?x)) (#t) <> (rotate (?x (?y (?z)))) (?y (?z (?x))) +<> (unused ?x) ?y -(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 - -?(?-) (Empty register replacement) - -<> (replace-empty ?x) (?y) - -replace-empty abc = ?y test +(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 test -prefix-anything = anything-suffix test +connect foo bar baz = foo-barbaz (substring 1) test +prefix-anything = anything-suffix (substring 2) test ?(?-) (Lambdas) -?(?x (?x ?x)) abc = (abc abc) test -abc ?(?x) def = abc test +(?(?x (?x ?x)) abc) = (abc abc) (lambda 1) test +abc ?(?x) def = abc (lambda 2) test ?(?-) (Explode) -?(?* ?*) cow = (c (o (w ()))) test -?(?* ?*) (12 34 45) = (12 (34 (45 ()))) test +(?(?* ?*) cow) = (c (o (w ()))) (explode 1) test +(?(?* ?*) (12 34 45)) = (12 (34 (45 ()))) (explode 2) test ?(?-) (op: join) -?(?^ ?^) (b (a (t ()))) = bat test -?(?^ ?^) (12 (34 (56 ()))) = 123456 test - -?(?-) (Test Primitives) - -<> (?: print) (?:) -<> (?x = ?x test) (#ok\n print) -<> (?x = ?y test) (#fail\n print) +?(?^ ?^) (b (a (t ()))) = bat (join 1) test +?(?^ ?^) (12 (34 (56 ()))) = 123456 (join 2) test ?(?-) (List reversal) @@ -93,4 +74,15 @@ abc ?(?x) def = abc test <> (reverse (?*)) (reverse List (?*) ()) <> (reverse List (?x ?y) ?z) (reverse List ?y (?x ?z)) -reverse (modal) = ladom test \ No newline at end of file +reverse (modal) = ladom (reverse 1) test + +?(?-) (Inline rules) + +<> ((?x -> ?y)) (<> ?x ?y) +(nap -> (tap =)) + +nap tap (inline 1) test + +?(?-) (Late Test Primitives) + +<> (?x = ?y ?n test) (?(?: ?:) (#fail ?n found: ?x expect: ?y\n)) \ No newline at end of file