test.hex
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 |
0x0 "test-count" store 0x0 "successes" store 0x0 "failures" store () "errors" store ( "current-test" store test-count 0x1 + "test-count" store ( (current-test i) ( "." print successes 0x1 + "successes" store ) ( "x" print failures 0x1 + "failures" store ) if ) ( ; Store error errors " - Test #" test-count dec cat ": " cat error cat q cat "errors" store "x" print failures 0x1 + "failures" store ) try ) "test" store ; --- Define tests ( (0x1 "a" store a 0x1 ==) ("a" free 0x1) ("aaa" type "string" == 0x1 type "integer" == () type "quotation" == and and) ((0x1 0x2 +) i 0x3 ==) ;4 ("0x2 0x2 -" eval 0x0 ==) (0x4 0x5 + 0x9 ==) (0x5 0x3 - 0x2 ==) (0x5 0x2 * 0xa ==) ;8 (0x5 0x2 / 0x2 ==) (0x4 0x2 % 0x0 ==) (0x10101 0x01010 & 0x0 ==) (0x10111 0x01000 | 0x11111 ==) ;12 (0x1 0x1 ^ 0x0 ==) (0x1 ~ 0xfffffffe ==) (0x1 0x4 << 0x10 ==) (0x10 0x4 >> 0x1 ==) ;16 ("10" int 0x10 ==) (0x10 str "10" ==) (0xa dec "10" ==) ("10" hex 0xa ==) ;20 ("aaa" "aaa" ==) (0x20 0x20 ==) (0x21 0x22 !=) ("abba" "aaa" !=) ;24 (0x2 0x1 >) (0x2 0x2 >=) (0x2 0x3 <) (0x3 0x3 <=) ;28 (0x2 0x3 and) (0x1 0x0 or) (0x1 0x0 xor) (0x1 0x1 xor not) ;32 ("hello" " world" cat "hello world" ==) ((0x1 "a") ("b") cat (0x1 "a" "b") ==) ((0x1 0x2 0x3) 0x1 0x2 slice (0x2 0x3) ==) ("hello" 0x0 0x3 slice "hell" ==) ;36 ("aaaaa" len 0x5 ==) ((0x1 0x3 puts "aaa") len 0x4 ==) ((0x2 0x3 0x4) 0x2 get 0x4 ==) ("abcde" 0x1 get "b" ==) ;40 ("abdef" "c" 0x2 insert "abcdef" ==) ("bcdef" "a" 0x0 insert "abcdef" ==) ("abcde" "f" 0x5 insert "abcdef" ==) ((0x1 0x2 0x3) 0x4 0x3 insert (0x1 0x2 0x3 0x4) ==) ;44 ("this is a test" "is" index 0x2 ==) (("a" 0x1 "b") "b" index 0x2) ("abc" "d" index 0xffffffff ==) (("0" "0" "0" "0") "." join "0.0.0.0"==) ;48 ("0.0.0.0" "." split ("0" "0" "0" "0") ==) ("Hello, World!" "Hello" "Goodbye" replace "Goodbye, World!" ==) ("test" "test.txt" write "test.txt" read "test" ==) ("!" "test.txt" append "test.txt" read "test!" ==) ;52 ("rm test.txt" exec 0x1) ) "tests" store ; --- Run tests tests (test i) each ; --- Report "\nSuccessful Tests: " print successes dec print "/" print successes failures + dec puts (errors len 0x0 >) ( "Errors:" warn errors (warn) each 0x1 exit ) when 0x0 exit |