add nil as synonym for None
This commit is contained in:
parent
b2bb161cb0
commit
55a7ab1667
@ -229,6 +229,7 @@ def t_identifier(p):
|
|||||||
table = {
|
table = {
|
||||||
"true": "True",
|
"true": "True",
|
||||||
"false": "False",
|
"false": "False",
|
||||||
|
"nil": "None",
|
||||||
"null": "None",
|
"null": "None",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,9 +86,10 @@
|
|||||||
|
|
||||||
(defn test-is []
|
(defn test-is []
|
||||||
"NATIVE: test is can deal with None"
|
"NATIVE: test is can deal with None"
|
||||||
(setv a null)
|
(setv a nil)
|
||||||
(assert (is a null))
|
(assert (is a nil))
|
||||||
(assert (is-not a "b")))
|
(assert (is-not a "b"))
|
||||||
|
(assert (none? a)))
|
||||||
|
|
||||||
|
|
||||||
(defn test-branching []
|
(defn test-branching []
|
||||||
|
@ -4,5 +4,7 @@
|
|||||||
(assert (= (unless false 1 2) 2))
|
(assert (= (unless false 1 2) 2))
|
||||||
(assert (= (unless false 1 3) 3))
|
(assert (= (unless false 1 3) 3))
|
||||||
(assert (= (unless true 2) null))
|
(assert (= (unless true 2) null))
|
||||||
|
(assert (= (unless true 2) nil))
|
||||||
(assert (= (unless (!= 1 2) 42) null))
|
(assert (= (unless (!= 1 2) 42) null))
|
||||||
|
(assert (= (unless (!= 1 2) 42) nil))
|
||||||
(assert (= (unless (!= 2 2) 42) 42)))
|
(assert (= (unless (!= 2 2) 42) 42)))
|
||||||
|
@ -5,4 +5,6 @@
|
|||||||
(assert (= (when true 1 3) 3))
|
(assert (= (when true 1 3) 3))
|
||||||
(assert (= (when false 2) null))
|
(assert (= (when false 2) null))
|
||||||
(assert (= (when (= 1 2) 42) null))
|
(assert (= (when (= 1 2) 42) null))
|
||||||
|
(assert (= (when false 2) nil))
|
||||||
|
(assert (= (when (= 1 2) 42) nil))
|
||||||
(assert (= (when (= 2 2) 42) 42)))
|
(assert (= (when (= 2 2) 42) 42)))
|
||||||
|
Loading…
Reference in New Issue
Block a user