mirror of
https://github.com/janet-lang/janet
synced 2025-10-17 08:47:39 +00:00
Add quick asm for adding apply and error to the stl.
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
(def outerfun (fn [x y]
|
||||
(def c (do
|
||||
#(+ 1 2 3 4)
|
||||
(def someval (+ x y))
|
||||
(def ctemp (if x (fn [] someval) (fn [] y)))
|
||||
ctemp
|
||||
))
|
||||
#(+ 1 2 3 4 5 6 7 8 9 10)
|
||||
c))
|
@@ -141,17 +141,18 @@
|
||||
(varset! count (+ 1 count)))
|
||||
(assert (= accum 65536) "loop globally")
|
||||
|
||||
(assert (= (struct 1 2 3 4 5 6 7 8) (struct 7 8 5 6 3 4 1 2)) "struct order does not matter")
|
||||
(assert (= (struct 1 2 3 4 5 6 7 8) (struct 7 8 5 6 3 4 1 2)) "struct order does not matter 1")
|
||||
(assert (= (struct
|
||||
:apple 1
|
||||
6 :bork
|
||||
'(1 2 3) 5)
|
||||
(struct
|
||||
6 :bork
|
||||
'(1 2 3) 5
|
||||
:apple 1)) "struct order does not matter 2")
|
||||
|
||||
# Fiber tests
|
||||
|
||||
(def error (asm '{
|
||||
arity 1
|
||||
bytecode [
|
||||
(error 0)
|
||||
]
|
||||
}))
|
||||
|
||||
(def afiber (fiber (fn [x]
|
||||
(error (string "hello, " x)))))
|
||||
|
||||
@@ -171,14 +172,6 @@
|
||||
|
||||
# Var arg tests
|
||||
|
||||
(def apply (asm '{
|
||||
arity 2
|
||||
bytecode [
|
||||
(push-array 1)
|
||||
(tailcall 0)
|
||||
]
|
||||
}))
|
||||
|
||||
(def vargf (fn [more] (apply + more)))
|
||||
|
||||
(assert (= 0 (vargf [])) "var arg no arguments")
|
||||
|
Reference in New Issue
Block a user