File tree Expand file tree Collapse file tree 2 files changed +30
-9
lines changed
Expand file tree Collapse file tree 2 files changed +30
-9
lines changed Original file line number Diff line number Diff line change 447447 (when-not (= :statement (:context env))
448448 (emit-wrap env (emit-constant form))))
449449
450- (defn truthy-constant? [{:keys [op form]}]
451- (and (= op :constant )
452- form
453- (not (or (and (string? form) (= form " " ))
454- (and (number? form) (zero? form))))))
455-
456- (defn falsey-constant? [{:keys [op form]}]
457- (and (= op :constant )
458- (or (false ? form) (nil? form))))
450+ (defn truthy-constant? [{:keys [op form const-expr]}]
451+ (or (and (= op :constant )
452+ form
453+ (not (or (and (string? form) (= form " " ))
454+ (and (number? form) (zero? form)))))
455+ (and (some? const-expr)
456+ (truthy-constant? const-expr))))
457+
458+ (defn falsey-constant? [{:keys [op form const-expr]}]
459+ (or (and (= op :constant )
460+ (or (false ? form) (nil? form)))
461+ (and (some? const-expr)
462+ (false y-constant? const-expr))))
459463
460464(defn safe-test? [env e]
461465 (let [tag (ana/infer-tag env e)]
Original file line number Diff line number Diff line change 14111411 (is (= " #js {:foo/bar 33}" (pr-str (doto (js-obj ) (gobject/set " foo/bar" 33 )))))
14121412 (is (= " #js {:foo/bar #:var{:quux 66}}" (pr-str (doto (js-obj ) (gobject/set " foo/bar" {:var/quux 66 }))))))))
14131413
1414+ (def ^:const true-2267 true )
1415+ (def ^:const false-2267 false )
1416+ (def ^:const nil-2267 nil )
1417+ (def ^:const empty-string-2267 " " )
1418+ (def ^:const non-empty-string-2267 " x" )
1419+ (def ^:const zero-2267 0 )
1420+ (def ^:const non-zero-2267 1 )
1421+
1422+ (deftest test-cljs-2267
1423+ (is (= :then (if true -2267 :then :else )))
1424+ (is (= :else (if false -2267 :then :else )))
1425+ (is (= :else (if nil-2267 :then :else )))
1426+ (is (= :then (if empty-string-2267 :then :else )))
1427+ (is (= :then (if non-empty-string-2267 :then :else )))
1428+ (is (= :then (if zero-2267 :then :else )))
1429+ (is (= :then (if non-zero-2267 :then :else ))))
1430+
14141431(comment
14151432 ; ; ObjMap
14161433 ; ; (let [ks (map (partial str "foo") (range 500))
You can’t perform that action at this time.
0 commit comments