Permalink
Browse files

fixed a subtle bug in fj-equal?

  • Loading branch information...
1 parent 1c8a536 commit ed015e55167c0634420ea885dc053e7739d4f385 @martintrojer committed Mar 14, 2012
Showing with 11 additions and 2 deletions.
  1. +5 −0 CHANGES.md
  2. +1 −1 project.clj
  3. +1 −1 src/frinj/core.clj
  4. +4 −0 test/frinj/test/core.clj
View
@@ -7,6 +7,11 @@ Features
* Live unit feeds
* frinj.repl namespace
+Fixes
+---
+
+* bug in fj-equal?
+
0.1.2
====
View
@@ -1,4 +1,4 @@
-(defproject frinj "0.1.4-SNAPSHOT"
+(defproject frinj "0.1.3"
:description "Practical unit-of-measure calculator DSL for Clojure"
:url "https://github.com/martintrojer/frinj"
:dependencies [[org.clojure/clojure "1.3.0"]])
View
@@ -196,7 +196,7 @@
(loop [[fst & rst] fjs]
(if (nil? fst)
true
- (if-not (= 0 (:v (fj-sub fst-fjv fst)))
+ (if-not (zero? (:v (fj-sub fst-fjv fst)))
false
(recur rst)))))
View
@@ -147,6 +147,10 @@
(is (fj-equal? one one one))
(is (not (fj-equal? one zero)))
(is (not (fj-equal? one one zero)))
+ (is (fj-equal? (fjv. 1 {:m 1}) (fjv. 1 {:m 1})))
+ (is (fj-equal? (fjv. 1.1 {:m 1}) (fjv. 1.1 {:m 1})))
+ (is (fj-equal? (fjv. 1/2 {:s -1 :m 1}) (fjv. 1/2 {:m 1 :s -1})))
+ (is (fj-equal? (fjv. 1 {:m 1}) (fjv. 1 {:m 1 :s 0})))
)
(deftest less

0 comments on commit ed015e5

Please sign in to comment.