mirror of
https://github.com/janet-lang/janet
synced 2025-10-05 02:52:28 +00:00
Add a few more tests.
This commit is contained in:
@@ -69,6 +69,11 @@
|
|||||||
(var plus +)
|
(var plus +)
|
||||||
(assert (= 22 (plus one (plus 1 2 two) (plus 8 (plus zero 1) 4 three))) "nested function calls")
|
(assert (= 22 (plus one (plus 1 2 two) (plus 8 (plus zero 1) 4 three))) "nested function calls")
|
||||||
|
|
||||||
|
# String literals
|
||||||
|
(assert (= "abcd" "\x61\x62\x63\x64") "hex escapes")
|
||||||
|
(assert (= "\e" "\x1B") "escape character")
|
||||||
|
(assert (= "\x09" "\t") "tab character")
|
||||||
|
|
||||||
# Mcarthy's 91 function
|
# Mcarthy's 91 function
|
||||||
(var f91 nil)
|
(var f91 nil)
|
||||||
(:= f91 (fn [n] (if (> n 100) (- n 10) (f91 (f91 (+ n 11))))))
|
(:= f91 (fn [n] (if (> n 100) (- n 10) (f91 (f91 (+ n 11))))))
|
||||||
|
@@ -39,5 +39,12 @@
|
|||||||
|
|
||||||
(assert (= (length @"abcdef") 6) "buffer length")
|
(assert (= (length @"abcdef") 6) "buffer length")
|
||||||
|
|
||||||
|
# Looping idea
|
||||||
|
(def xs
|
||||||
|
(for [x :in '[-1 0 1], y :in '[-1 0 1] :when (not= x y 0)] (tuple x y)))
|
||||||
|
(def txs (apply1 tuple xs))
|
||||||
|
|
||||||
|
(assert (= txs '[[-1 -1] [-1 0] [-1 1] [0 -1] [0 1] [1 -1] [1 0] [1 1]]) "nested for")
|
||||||
|
|
||||||
(end-suite)
|
(end-suite)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user