1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-24 09:17:17 +00:00

Add some extra functionality to tests.

This commit is contained in:
Calvin Rose 2017-06-25 19:29:38 -04:00
parent d6967a564d
commit a7a9ff7629
2 changed files with 18 additions and 2 deletions

View File

@ -306,11 +306,17 @@ static int string_state(GstParser *p, uint8_t c) {
case '"': next = '"'; break;
case '\'': next = '\''; break;
case 'z': next = '\0'; break;
case 'e': next = 27; break;
case 'h':
top->buf.string.state = STRING_STATE_ESCAPE_HEX;
top->buf.string.count = 0;
top->buf.string.accum = 0;
return 1;
case 'u':
top->buf.string.state = STRING_STATE_ESCAPE_HEX;
top->buf.string.count = 0;
top->buf.string.accum = 0;
return 1;
default:
p_error(p, "unknown string escape sequence");
return 1;

View File

@ -1,5 +1,14 @@
(print "Running basic tests...")
(def assert (fn [x e] (if x (do (write stdout ".") x) (do (print e) (exit 1)))))
(var numTestsPassed 0)
(def assert (fn [x e]
(if x
(do
(print " \e[32m✔\e[0m" e)
(varset numTestsPassed (+ 1 numTestsPassed)) x)
(do
(print e)
(exit 1)))))
(assert (= 10 (+ 1 2 3 4)) "addition")
(assert (= -8 (- 1 2 3 4)) "subtraction")
@ -15,5 +24,6 @@
(assert (= accum 65536) "loop")
(print)
(print "All" numTestsPassed "tests passed")
(exit 0)