mirror of
https://github.com/janet-lang/janet
synced 2024-12-25 16:00:27 +00:00
More corrections to varargs.
This commit is contained in:
parent
57886db410
commit
f0545865a8
3
Makefile
3
Makefile
@ -16,8 +16,7 @@ GST_INTERNAL_HEADERS=$(addprefix core/, cache.h)
|
||||
GST_HEADERS=$(addprefix include/gst/, gst.h)
|
||||
|
||||
# Use gdb. On mac use lldb
|
||||
DEBUGGER=lldb
|
||||
CC=clang
|
||||
DEBUGGER=gdb
|
||||
|
||||
all: $(GST_TARGET)
|
||||
|
||||
|
@ -90,7 +90,7 @@ void gst_thread_pushnil(Gst *vm, GstThread *thread, uint32_t n) {
|
||||
void gst_thread_tuplepack(Gst *vm, GstThread *thread, uint32_t n) {
|
||||
GstValue *stack = thread->data + thread->count;
|
||||
uint32_t size = gst_frame_size(stack);
|
||||
if (n > size) {
|
||||
if (n >= size) {
|
||||
/* Push one extra nil to ensure space for tuple */
|
||||
gst_thread_pushnil(vm, thread, n - size + 1);
|
||||
stack = thread->data + thread->count;
|
||||
|
@ -102,6 +102,15 @@
|
||||
(assert (= 3 (tran t)) "return from thread")
|
||||
(assert (= (status t) "dead") "finished thread is dead")
|
||||
|
||||
# Var arg tests
|
||||
|
||||
(def vargf (fn [x &] (apply + (if x x 0) 100 &)))
|
||||
(assert (= 100 (vargf)) "var arg no arguments")
|
||||
(assert (= 101 (vargf 1)) "var arg no packed arguments")
|
||||
(assert (= 103 (vargf 1 2)) "var arg tuple size 1")
|
||||
(assert (= 110 (vargf 1 2 3 4)) "var arg tuple size 3")
|
||||
(assert (= 210 (vargf 1 2 3 4 10 10 10 10 10 10 10 10 10 10)) "var arg large tuple")
|
||||
|
||||
# report
|
||||
|
||||
(print "\n" num-tests-passed " of " num-tests-run " tests passed\n")
|
||||
|
@ -17,8 +17,8 @@
|
||||
(clear b))
|
||||
(parse-consume p)))
|
||||
|
||||
(def eval (fn [x]
|
||||
(apply (*compile* x) 123)))
|
||||
(def eval (fn [x &]
|
||||
(apply (*compile* x) &)))
|
||||
|
||||
(def t (thread (fn []
|
||||
(while true
|
||||
|
Loading…
Reference in New Issue
Block a user