tests/lang.min
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
@test #test "lang" describe "Total Symbols: " print! symbols size put! " Total Sigils: " print! sigils size put! (symbols size 181 ==) assert (sigils size 12 ==) assert (debug? false ==) assert (2 'a define (3 a + (5 'a define a) -> +) -> a + 12 ==) assert (symbols "a" contains false ==) assert 5 :five (symbols "five" contains) assert ~five (symbols "five" contains false ==) assert ( ( (+) :myplus ) =mymath ) :defmod (defmod symbols "mymath" contains) assert (defmod #mymath 2 3 myplus 5 ==) assert ; Extend an existing scope (defmod (#mymath (-) :myminus) => .mymath 5 2 mymath %myminus 3 ==) assert (defmod mymath inspect ("myplus") ==) assert ((":mysigil" concat) ', sigil ,test "test:mysigil" ==) assert ("3 4 +" eval 7 ==) assert ("2 2 +" "tests/testload.min" fwrite @testload 4 ==) assert "tests/testload.min" rm (defmod 2 2 mymath %myplus 4 ==) assert (1 2 3 4 getstack (1 2 3 4) ==) assert ((1 2 3) setstack getstack (1 2 3) ==) assert ((1 2) (3 4) concat (1 2 3 4) ==) assert ((1 2 3) first 1 ==) assert ((1 2 3) rest (2 3) ==) assert (2 quote (2) ==) assert ((2 3) unquote getstack (2 3) ==) assert (4 (1 2 3) append (1 2 3 4) ==) assert (1 (2 3) cons (1 2 3) ==) assert ((1 2 3 4) 2 at 3 ==) assert ((1 2 3) size 3 ==) assert ((1 2 3 4) 5 contains false ==) assert ((1 2 3 4) 2 contains) assert ((1 2 3 4) (2 +) map (3 4 5 6) ==) assert (3 (succ) 3 times 6 ==) assert ((2 3 >) ("YES") ("NO") ifte "NO" ==) assert ((2 3 <) ("YES") ("NO") ifte "YES" ==) assert (0 :c (c 10 <) (c succ .c) while c 10 ==) assert ((1 2 3 4 5) (even?) filter (2 4) ==) assert (5 (dup 0 ==) (1 +) (dup 1 -) ( * ) linrec 120 ==) assert ;factorial of 5 ( ( (pop) (first) ("Caught a " swap concat) ) try "Caught a MinEmptyStackError" ==) assert ( ( (("TestError" "Test Message") raise) (1 at) ) try "Test Message" ==) assert ( (("test" (1 2) :)) try getstack ("test" (1 2)) ==) assert ( ( (() 1 at) (1) ) try 1 ==) assert ( ((dup 0 ==) (1 +) (dup 1 -) ( * ) linrec) :factorial ( (8 factorial) (12 factorial) (9 factorial) ) ->> (40320 479001600 362880) ==) assert ((a b +) (4 :a 5 :b) with 9 ==) assert ((4 :four 5 :five) ^myobject type "myobject" ==) assert (("test" :test) =test1 test1 object?) assert (("test" :test) =test2 test2 module?) assert report ; Tidy up ~defmod clear |