File tree Expand file tree Collapse file tree 3 files changed +42
-3
lines changed Expand file tree Collapse file tree 3 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
20
20
* Fix a bug where the core functions ` symbol ` and ` keyword ` would not accept non-string data types (#911 )
21
21
* Fix a bug where the compiler would emit warnings on when a Var was redef'ed even if that Var was initially defined with ` ^:redef ` metadata (#916 )
22
22
* Fix a bug where reader column offset numbering began at 1, rather than 0 (#905 )
23
+ * Fix a bug where ` basilisp.core/boolean ` was returning the boolean coercions like Python rather than like Basilisp (#928 )
23
24
24
25
### Other
25
26
* Add several sections to Concepts documentation module (#666 )
Original file line number Diff line number Diff line change 478
478
(recur (rest s))
479
479
(first s)))
480
480
481
- (defn ^:inline nil?
481
+ (defn ^:inline nil?
482
482
"Return ``true`` if ``x`` is ``nil``\\, otherwise ``false``\\."
483
483
[x]
484
484
(operator/is- x nil))
1578
1578
(python/int x))
1579
1579
1580
1580
(defn ^:inline boolean
1581
- "Coerce ``x`` to a boolean."
1581
+ "Coerce ``x`` to a boolean.
1582
+
1583
+ Only ``false`` and ``nil`` are logical false and will return ``false``\\. All
1584
+ other values will return ``true``\\."
1582
1585
[x]
1583
- (python/bool x))
1586
+ (if (or (nil? x) (false? x))
1587
+ false
1588
+ true))
1584
1589
1585
1590
(defn byte
1586
1591
"Coerce ``x`` to a byte."
2088
2093
;;;;;;;;;;;;;;;;;;;;;;;;;;
2089
2094
2090
2095
(defn bounded-count
2096
+ "Return the count (as by :lpy:fn:`count`) of any ``coll`` for which ``counted?``
2097
+ returns ``true``, otherwise return the lesser of ``n`` and the length of
2098
+ ``coll``\\."
2091
2099
[n coll]
2092
2100
(if (counted? coll)
2093
2101
(count coll)
Original file line number Diff line number Diff line change 126
126
(is (= v1 v2))
127
127
(is (= {:tag vector} (meta v2))))))))
128
128
129
+ (deftest boolean-test
130
+ (testing "logical false values"
131
+ (are [v] (false? (boolean v))
132
+ false
133
+ nil))
134
+
135
+ (testing "logical true values"
136
+ (are [v] (true? (boolean v))
137
+ true
138
+ 1
139
+ 0
140
+ -1
141
+ 1.0
142
+ 0.0
143
+ -1.0
144
+ ""
145
+ "false"
146
+ []
147
+ [false]
148
+ #{}
149
+ #{false}
150
+ {}
151
+ {false false}
152
+ '()
153
+ '(false false)
154
+ :kw
155
+ :ns/kw
156
+ 'sym
157
+ 'ns/sym)))
158
+
129
159
(deftest compare-test
130
160
(testing "nil"
131
161
(are [res x y] (= res (compare x y))
You can’t perform that action at this time.
0 commit comments