Browse files

fixed corner case in c.c.profile print-summary

  • Loading branch information...
1 parent ebf0d21 commit 6dd033d9e12337f6630faa3d3f5c2e901a28c4f4 @stuarthalloway stuarthalloway committed Apr 13, 2010
2 src/main/clojure/clojure/contrib/profile.clj
@@ -95,7 +95,7 @@ profiling code."} *enable-profiling* true)
(defn print-summary
"Prints a table of the results returned by summarize."
- (let [name-width (apply max (map (comp count name) (keys profile-summary)))
+ (let [name-width (apply max 1 (map (comp count name) (keys profile-summary)))
fmt-string (str "%" name-width "s %8d %8d %8d %8d %8d%n")]
(printf (.replace fmt-string \d \s)
"Name" "mean" "min" "max" "count" "sum")
8 src/test/clojure/clojure/contrib/test_profile.clj
@@ -0,0 +1,8 @@
+(ns clojure.contrib.test-profile
+ (:use clojure.test
+ clojure.contrib.profile))
+(deftest test-print-summary
+ (testing "doesn't blow up with no data (assembla #31)"
+ (is (= "Name mean min max count sum\n"
+ (with-out-str (print-summary {}))))))

0 comments on commit 6dd033d

Please sign in to comment.