1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-19 15:14:48 +00:00

Merge branch 'master' of github.com:janet-lang/janet

This commit is contained in:
Calvin Rose 2019-11-30 21:34:38 -05:00
commit 474aed8cfe
2 changed files with 4 additions and 0 deletions

View File

@ -102,6 +102,7 @@
(defn indexed? "Check if x is an array or tuple." [x] (defn indexed? "Check if x is an array or tuple." [x]
(def t (type x)) (def t (type x))
(if (= t :array) true (= t :tuple))) (if (= t :array) true (= t :tuple)))
(defn truthy? "Check if x is truthy." [x] (if x true false))
(defn true? "Check if x is true." [x] (= x true)) (defn true? "Check if x is true." [x] (= x true))
(defn false? "Check if x is false." [x] (= x false)) (defn false? "Check if x is false." [x] (= x false))
(defn nil? "Check if x is nil." [x] (= x nil)) (defn nil? "Check if x is nil." [x] (= x nil))

View File

@ -314,5 +314,8 @@
(assert (= y 1) "regression #137 (5)") (assert (= y 1) "regression #137 (5)")
(assert (= z 2) "regression #137 (6)") (assert (= z 2) "regression #137 (6)")
(assert (= true ;(map truthy? [0 "" true @{} {} [] '()])) "truthy values")
(assert (= false ;(map truthy? [nil false])) "non-truthy values")
(end-suite) (end-suite)