Skip to content

Commit

Permalink
Fix for -equiv issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-healy committed Apr 14, 2018
1 parent 4d99f75 commit cb4d664
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/decimal/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,8 @@
(extend-type *decimal*
cljs.core/IEquiv
(-equiv [v other]
(.eq v other))
(and (not= other nil)
(.eq v other)))

cljs.core/ICloneable
(-clone [v]
Expand Down
12 changes: 7 additions & 5 deletions test/decimal/core_spec.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
(t/is (dc/< d1 d3))
(t/is (dc/>= d3 "10.99999"))
(t/is (dc/<= d3 "10.99999"))
))

(t/is (not (-equiv d1 nil)))))


(def ^:static +test-values+
["0", "-0", "-0.5", "-0.53", "-0.409325859"
Expand All @@ -50,8 +52,8 @@
(defn equal-or-both-NaN
[value1 value2]
(t/is (or
(= value1 value2)
(and (dc/NaN? value1) (dc/NaN? value2)))))
(= value1 value2)
(and (dc/NaN? value1) (dc/NaN? value2)))))

(t/deftest api-test
(doseq [v +test-values+]
Expand Down Expand Up @@ -140,8 +142,8 @@
(t/is (map = (dc/to-fraction v 1) (js->clj (.toFraction (dc/-decimal v) 1))))
(equal-or-both-NaN (dc/pow v 2) (.toPower (dc/-decimal v) 2))
(equal-or-both-NaN (dc/to-nearest v 1) (.toNearest (dc/-decimal v) 1))
(equal-or-both-NaN (dc/to-nearest v 1 2) (.toNearest (dc/-decimal v) 1 2))
))
(equal-or-both-NaN (dc/to-nearest v 1 2) (.toNearest (dc/-decimal v) 1 2))))


;; (t/deftest operations-test
;; (t/testing "abs"
Expand Down

0 comments on commit cb4d664

Please sign in to comment.