Permalink
Browse files

Update table* to handle nil and empty list arguments

Was throwing a NPE prior
  • Loading branch information...
1 parent cd3b543 commit 6caafdf28e55e27320cad5aa62d54244d871eafc David Leatherman committed Mar 14, 2012
Showing with 10 additions and 1 deletion.
  1. +1 −1 src/doric/core.clj
  2. +9 −0 test/doric/test/core.clj
View
@@ -130,7 +130,7 @@
(defn table*
([rows]
- (table* (vary-meta (keys (first rows))
+ (table* (vary-meta (or (keys (first rows)) [])
merge (meta rows)) rows))
([cols rows]
(let [meta (meta cols)
View
@@ -105,3 +105,12 @@
{:name :2 :format inc :width 0}]
[{:1 3 :2 4}])]
(is (= 0 @calls))))))
+
+(deftest test-empty-table
+ (let [empty-table "|--|\n| |\n|--|\n|--|"]
+ (is (= empty-table (table [])))
+ (is (= empty-table (table nil)))
+ (is (= empty-table (table [] [])))
+ (is (= empty-table (table [] nil)))
+ (is (= empty-table (table nil [])))
+ (is (= empty-table (table nil nil)))))

0 comments on commit 6caafdf

Please sign in to comment.