mirror of
https://github.com/janet-lang/janet
synced 2025-10-17 16:57:40 +00:00
More work on renaming functions. Change long string syntax to use
backticks. Allow custom masks in fibers for custom error and debug handling.
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
(assert (>= 6.0 5.0 4.0 4.0 3.0 2.0 1.0) "greater than or equal to reals")
|
||||
|
||||
(assert (order< nil false true
|
||||
(fiber (fn [x] x))
|
||||
(fiber.new (fn [x] x))
|
||||
1 1.0 "hi"
|
||||
(quote hello)
|
||||
(array 1 2 3)
|
||||
@@ -145,21 +145,21 @@
|
||||
|
||||
# Fiber tests
|
||||
|
||||
(def afiber (fiber (fn [x]
|
||||
(def afiber (fiber.new (fn [x]
|
||||
(error (string "hello, " x)))))
|
||||
|
||||
(def afiber-result (resume afiber "world!"))
|
||||
(def afiber-result (fiber.resume afiber "world!"))
|
||||
|
||||
(assert (= afiber-result "hello, world!") "fiber error result")
|
||||
(assert (= (fiber.status afiber) :error) "fiber error status")
|
||||
|
||||
# yield tests
|
||||
|
||||
(def t (fiber (fn [] (yield 1) (yield 2) 3)))
|
||||
(def t (fiber.new (fn [] (fiber.yield 1) (fiber.yield 2) 3)))
|
||||
|
||||
(assert (= 1 (resume t)) "initial transfer to new fiber")
|
||||
(assert (= 2 (resume t)) "second transfer to fiber")
|
||||
(assert (= 3 (resume t)) "return from fiber")
|
||||
(assert (= 1 (fiber.resume t)) "initial transfer to new fiber")
|
||||
(assert (= 2 (fiber.resume t)) "second transfer to fiber")
|
||||
(assert (= 3 (fiber.resume t)) "return from fiber")
|
||||
(assert (= (fiber.status t) :dead) "finished fiber is dead")
|
||||
|
||||
# Var arg tests
|
||||
|
@@ -62,15 +62,15 @@
|
||||
|
||||
(table.setproto childtab roottab)
|
||||
|
||||
(assert (= 123 (get roottab :parentprop)), "table get 1")
|
||||
(assert (= 123 (get childtab :parentprop)), "table get proto")
|
||||
(assert (= nil (get roottab :childprop)), "table get 2")
|
||||
(assert (= 456 (get childtab :childprop)), "proto no effect")
|
||||
(assert (= 123 (get roottab :parentprop)) "table get 1")
|
||||
(assert (= 123 (get childtab :parentprop)) "table get proto")
|
||||
(assert (= nil (get roottab :childprop)) "table get 2")
|
||||
(assert (= 456 (get childtab :childprop)) "proto no effect")
|
||||
|
||||
# Long strings
|
||||
|
||||
(assert (= "hello, world" \==\hello, world\==\), "simple long string")
|
||||
(assert (= "hello, \"world\"" \\hello, "world"\\), "long string with embedded quotes")
|
||||
(assert (= "hello, \\\\\\ \"world\"" \=\hello, \\\ "world"\=\), "long string with embedded quotes and backslashes")
|
||||
(assert (= "hello, world" `hello, world`) "simple long string")
|
||||
(assert (= "hello, \"world\"" `hello, "world"`) "long string with embedded quotes")
|
||||
(assert (= "hello, \\\\\\ \"world\"" `hello, \\\ "world"`), "long string with embedded quotes and backslashes")
|
||||
|
||||
(end-suite)
|
||||
|
Reference in New Issue
Block a user