diff --git a/examples/sigaction.janet b/examples/sigaction.janet index 5887ffad..9267baa9 100644 --- a/examples/sigaction.janet +++ b/examples/sigaction.janet @@ -1,10 +1,11 @@ (defn action [] - (print "Handled SIGHUP!") - (flush)) + (print "cleanup") + (os/exit 1)) (defn main [_] # Set the interrupt-interpreter argument to `true` to allow # interrupting the busy loop `(forever)`. By default, will not # interrupt the interpreter. - (os/sigaction :hup action true) + (os/sigaction :term action true) + (os/sigaction :int action true) (forever)) diff --git a/src/boot/boot.janet b/src/boot/boot.janet index 7e877e21..e32f8aec 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -1584,7 +1584,7 @@ (defn keys "Get the keys of an associative data structure." [x] - (def arr (array/new-filled (length x))) + (def arr @[]) (var i 0) (eachk k x (put arr i k) @@ -1594,7 +1594,7 @@ (defn values "Get the values of an associative data structure." [x] - (def arr (array/new-filled (length x))) + (def arr @[]) (var i 0) (each v x (put arr i v) @@ -1604,7 +1604,7 @@ (defn pairs "Get the key-value pairs of an associative data structure." [x] - (def arr (array/new-filled (length x))) + (def arr @[]) (var i 0) (eachp p x (put arr i p) diff --git a/test/suite-corelib.janet b/test/suite-corelib.janet index 5107c555..e6fe0fea 100644 --- a/test/suite-corelib.janet +++ b/test/suite-corelib.janet @@ -172,5 +172,10 @@ (assert (= (length (range -10)) 0) "(range -10)") (assert (= (length (range 1 10)) 9) "(range 1 10)") +# iterating over generator +(assert-no-error "iterate over coro 1" (values (generate [x :range [0 10]] x))) +(assert-no-error "iterate over coro 2" (keys (generate [x :range [0 10]] x))) +(assert-no-error "iterate over coro 3" (pairs (generate [x :range [0 10]] x))) + (end-suite)