Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Housekeeping
  • Loading branch information
ptaoussanis committed Oct 4, 2012
1 parent 1ea6f4c commit 1fb4799
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/taoensso/tower.clj
Expand Up @@ -456,4 +456,4 @@
(recur (conj v partition) (drop (count partition) remaining)))))]
`(str/join " " (map #(apply t %) ~partitions)))))

(comment (with-locale :en-ZA (tstr :example/greeting "Steve" :example/foo )))
(comment (with-locale :en-ZA (tstr :example/greeting "Steve" :example/foo)))
56 changes: 28 additions & 28 deletions test/test_tower/main.clj
Expand Up @@ -4,8 +4,6 @@
(:use [clojure.test]
[taoensso.tower :as tower :only (with-locale with-scope parse-number t)]))

;; TODO Tests

(defmacro wza [& body] `(with-locale :en_ZA ~@body))
(defmacro wus [& body] `(with-locale :en_US ~@body))
(defmacro wde [& body] `(with-locale :de_DE ~@body))
Expand All @@ -28,15 +26,13 @@
"100.000.000,1" 100000000.10
"1.000" 1000)

(wus
(is (= "1,000.1" (tower/format-number 1000.10)))
(is (= "1,000" (tower/format-integer 1000)))
(is (= "$1,000.10" (tower/format-currency 1000.10))))
(wus (is (= "1,000.1" (tower/format-number 1000.10)))
(is (= "1,000" (tower/format-integer 1000)))
(is (= "$1,000.10" (tower/format-currency 1000.10))))

(wde
(is (= "1.000,1" (tower/format-number 1000.10)))
(is (= "1.000" (tower/format-integer 1000)))
(is (= "1.000,10 €" (tower/format-currency 1000.10)))))
(wde (is (= "1.000,1" (tower/format-number 1000.10)))
(is (= "1.000" (tower/format-integer 1000)))
(is (= "1.000,10 €" (tower/format-currency 1000.10)))))

(deftest format-percent
(are [expected actual] (is (= expected (wza (tower/format-percent actual))))
Expand All @@ -47,20 +43,20 @@

(deftest format-currency
(are [expected actual] (is (= expected (wza (tower/format-currency actual))))
"R 123.45" 123.45
"R 12,345.00" 12345
"R 123.45" 123.45
"R 12,345.00" 12345
"R 123,456,789.00" 123456789
"R 123,456,789.20" 123456789.20)

(are [expected actual] (is (= expected (wus (tower/format-currency actual))))
"$123.45" 123.45
"$12,345.00" 12345
"$123.45" 123.45
"$12,345.00" 12345
"$123,456,789.00" 123456789
"$123,456,789.20" 123456789.20)

(are [expected actual] (is (= expected (wde (tower/format-currency actual))))
"123,45 €" 123.45
"12.345,00 €" 12345
"123,45 €" 123.45
"12.345,00 €" 12345
"123.456.789,00 €" 123456789
"123.456.789,20 €" 123456789.20))

Expand Down Expand Up @@ -97,29 +93,33 @@
123456789.01 "$123,456,789.01")

(are [expected actual] (is (= expected (wde (tower/parse-currency actual))))
123.45 "123,45 €"
12345 "123.45 €"
123456.01 "123.456,01 €"
123456789.01 "123.456.789,01 €"))
123.45 "123,45 €"
12345 "123.45 €"
123456.01 "123.456,01 €"
123456789.01 "123.456.789,01 €"))

(deftest test-dt-formatting
;; Please refer to http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Date.html to see why we substract 1900 from year and 1 from month
;; that's JDK format.
(are [expected y m d] (is (= expected (wus (tower/format-date (Date. (Date/UTC (- y 1900) (- m 1) d 0 0 0))))))
;; Ref. http://goo.gl/rVaBX to see why we subtract 1900 from years and 1 from
;; months
(are [expected y m d]
(is (= expected (wus (tower/format-date
(Date. (Date/UTC (- y 1900) (- m 1) d 0 0 0))))))
"Feb 1, 2012" 2012 2 1
"Mar 25, 2012" 2012 3 25)

(are [expected y m d] (is (= expected (wza (tower/format-date (Date. (Date/UTC (- y 1900) (- m 1) d 0 0 0))))))
(are [expected y m d]
(is (= expected (wza (tower/format-date
(Date. (Date/UTC (- y 1900) (- m 1) d 0 0 0))))))
"01 Feb 2012" 2012 2 1
"25 Mar 2012" 2012 3 25)

(are [expected y m d] (is (= expected (wde (tower/format-date (Date. (Date/UTC (- y 1900) (- m 1) d 0 0 0))))))
(are [expected y m d]
(is (= expected (wde (tower/format-date
(Date. (Date/UTC (- y 1900) (- m 1) d 0 0 0))))))
"01.02.2012" 2012 2 1
"25.03.2012" 2012 3 25))

(deftest test-dt-parsing)
(deftest test-text-formatting)
(deftest test-dictionary-compiler)
(deftest test-dt-parsing) ; TODO

(deftest test-translations

Expand Down

0 comments on commit 1fb4799

Please sign in to comment.