1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-21 18:57:41 +00:00

Merge pull request #914 from pyrmont/feature.missing-symbols

Support looking up missing symbols during compilation
This commit is contained in:
Calvin Rose
2022-01-24 18:16:53 -06:00
committed by GitHub
5 changed files with 83 additions and 14 deletions

View File

@@ -123,12 +123,12 @@
(defer (:close outstream)
(:write outstream "123\n")
(:write outstream "456\n"))
(def outstream (os/open "unique.txt" :r))
(defer (:close outstream)
(assert (= "123\n456\n" (string (:read outstream :all))) "File reading 1.2"))
(os/rm "unique.txt")))
# ev/gather
(assert (deep= @[1 2 3] (ev/gather 1 2 3)) "ev/gather 1")
@@ -266,4 +266,13 @@
(ev/rselect c2)
(assert (= (slice arr) (slice (range 100))) "ev/chan-close 3")
# threaded channels
(def ch (ev/thread-chan 2))
(def att (ev/thread-chan 109))
(assert att "`att` was nil after creation")
(ev/give ch att)
(ev/do-thread
(assert (ev/take ch) "channel packing bug for threaded abstracts on threaded channels."))
(end-suite)

View File

@@ -21,18 +21,23 @@
(import ./helper :prefix "" :exit true)
(start-suite 11)
(assert (< 11899423.08 (math/gamma 11.5) 11899423.085)
"math/gamma")
# math gamma
(assert (< 2605.1158 (math/log-gamma 500) 2605.1159)
"math/log-gamma")
(assert (< 11899423.08 (math/gamma 11.5) 11899423.085) "math/gamma")
(assert (< 2605.1158 (math/log-gamma 500) 2605.1159) "math/log-gamma")
(def ch (ev/thread-chan 2))
(def att (ev/thread-chan 109))
(assert att "`att` was nil after creation")
(ev/give ch att)
(ev/do-thread
(assert (ev/take ch) "channel packing bug for threaded abstracts on threaded channels."))
# missing symbols
(def replacement 10)
(defn lookup-symbol [sym env] (dyn 'replacement))
(setdyn :missing-symbol lookup-symbol)
(assert (= (eval-string "(+ a 5)") 15) "lookup missing symbol")
(setdyn :missing-symbol nil)
(assert-error "compile error" (eval-string "(+ a 5)"))
(end-suite)