2023-02-01 08:39:24 +00:00
|
|
|
# test *debug* flags
|
|
|
|
|
|
|
|
(import ./helper :prefix "" :exit true)
|
|
|
|
(start-suite 15)
|
|
|
|
|
2023-02-03 23:24:06 +00:00
|
|
|
(assert (deep= (in (disasm (defn a [] (def x 10) x)) :symbolmap)
|
2023-05-29 21:10:48 +00:00
|
|
|
@[[0 2 0 'a] [0 2 1 'x]])
|
2023-02-03 23:24:06 +00:00
|
|
|
"symbolslots when *debug* is true")
|
2023-02-01 08:39:24 +00:00
|
|
|
|
2023-02-01 20:12:42 +00:00
|
|
|
(defn a [arg]
|
2023-02-03 23:24:06 +00:00
|
|
|
(def x 10)
|
|
|
|
(do
|
|
|
|
(def y 20)
|
|
|
|
(def z 30)
|
|
|
|
(+ x y z)))
|
2023-02-01 20:12:42 +00:00
|
|
|
(def symbolslots (in (disasm a) :symbolslots))
|
|
|
|
(def f (asm (disasm a)))
|
|
|
|
(assert (deep= (in (disasm f) :symbolslots)
|
2023-02-03 23:24:06 +00:00
|
|
|
symbolslots)
|
|
|
|
"symbolslots survive disasm/asm")
|
2023-02-01 10:06:33 +00:00
|
|
|
|
2023-02-01 20:26:29 +00:00
|
|
|
(comment
|
|
|
|
(setdyn *debug* true)
|
|
|
|
(setdyn :pretty-format "%.40M")
|
2023-02-03 23:24:06 +00:00
|
|
|
(def f (fn [x] (fn [y] (+ x y))))
|
|
|
|
(assert (deep= (map last (in (disasm (f 10)) :symbolmap))
|
|
|
|
@['x 'y])
|
|
|
|
"symbolslots upvalues"))
|
2023-02-01 20:26:29 +00:00
|
|
|
|
2023-02-01 10:06:33 +00:00
|
|
|
(assert (deep= (in (disasm (defn a [arg]
|
2023-02-03 23:24:06 +00:00
|
|
|
(def x 10)
|
|
|
|
(do
|
|
|
|
(def y 20)
|
|
|
|
(def z 30)
|
|
|
|
(+ x y z)))) :symbolmap)
|
2023-05-29 21:10:48 +00:00
|
|
|
@[[0 6 0 'arg]
|
|
|
|
[0 6 1 'a]
|
|
|
|
[0 6 2 'x]
|
|
|
|
[1 6 3 'y]
|
|
|
|
[2 6 4 'z]])
|
2023-02-03 23:24:06 +00:00
|
|
|
"arg & inner symbolslots")
|
2023-02-01 08:39:24 +00:00
|
|
|
|
2023-02-12 17:19:09 +00:00
|
|
|
# buffer/push-at
|
|
|
|
(assert (deep= @"abc456" (buffer/push-at @"abc123" 3 "456")) "buffer/push-at 1")
|
|
|
|
(assert (deep= @"abc456789" (buffer/push-at @"abc123" 3 "456789")) "buffer/push-at 2")
|
|
|
|
(assert (deep= @"abc423" (buffer/push-at @"abc123" 3 "4")) "buffer/push-at 3")
|
|
|
|
|
2023-05-29 21:10:48 +00:00
|
|
|
(assert (= 10 (do (var x 10) (def y x) (++ x) y)) "no invalid aliasing")
|
|
|
|
|
2023-06-01 18:01:59 +00:00
|
|
|
# Crash issue #1174 - bad debug info
|
|
|
|
(defn crash []
|
|
|
|
(debug/stack (fiber/current)))
|
|
|
|
(do
|
|
|
|
(math/random)
|
|
|
|
(defn foo [_]
|
|
|
|
(crash)
|
|
|
|
1)
|
|
|
|
(foo 0)
|
|
|
|
10)
|
|
|
|
|
2023-02-01 08:39:24 +00:00
|
|
|
(end-suite)
|