mirror of
https://github.com/janet-lang/janet
synced 2024-11-28 02:59:54 +00:00
Add some extra functionality to tests.
This commit is contained in:
parent
d6967a564d
commit
a7a9ff7629
@ -306,11 +306,17 @@ static int string_state(GstParser *p, uint8_t c) {
|
|||||||
case '"': next = '"'; break;
|
case '"': next = '"'; break;
|
||||||
case '\'': next = '\''; break;
|
case '\'': next = '\''; break;
|
||||||
case 'z': next = '\0'; break;
|
case 'z': next = '\0'; break;
|
||||||
|
case 'e': next = 27; break;
|
||||||
case 'h':
|
case 'h':
|
||||||
top->buf.string.state = STRING_STATE_ESCAPE_HEX;
|
top->buf.string.state = STRING_STATE_ESCAPE_HEX;
|
||||||
top->buf.string.count = 0;
|
top->buf.string.count = 0;
|
||||||
top->buf.string.accum = 0;
|
top->buf.string.accum = 0;
|
||||||
return 1;
|
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:
|
default:
|
||||||
p_error(p, "unknown string escape sequence");
|
p_error(p, "unknown string escape sequence");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
(print "Running basic tests...")
|
(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 (= 10 (+ 1 2 3 4)) "addition")
|
||||||
(assert (= -8 (- 1 2 3 4)) "subtraction")
|
(assert (= -8 (- 1 2 3 4)) "subtraction")
|
||||||
@ -15,5 +24,6 @@
|
|||||||
|
|
||||||
(assert (= accum 65536) "loop")
|
(assert (= accum 65536) "loop")
|
||||||
|
|
||||||
(print)
|
(print "All" numTestsPassed "tests passed")
|
||||||
|
|
||||||
(exit 0)
|
(exit 0)
|
Loading…
Reference in New Issue
Block a user