Skip to content

Commit

Permalink
Merge pull request #2 from leathekd/master
Browse files Browse the repository at this point in the history
Update table* to handle nil and empty list argument
  • Loading branch information
Joe Gallo committed Mar 15, 2012
2 parents cd3b543 + 6caafdf commit bc45e8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/doric/core.clj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@


(defn table* (defn table*
([rows] ([rows]
(table* (vary-meta (keys (first rows)) (table* (vary-meta (or (keys (first rows)) [])
merge (meta rows)) rows)) merge (meta rows)) rows))
([cols rows] ([cols rows]
(let [meta (meta cols) (let [meta (meta cols)
Expand Down
9 changes: 9 additions & 0 deletions test/doric/test/core.clj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -105,3 +105,12 @@
{:name :2 :format inc :width 0}] {:name :2 :format inc :width 0}]
[{:1 3 :2 4}])] [{:1 3 :2 4}])]
(is (= 0 @calls)))))) (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 bc45e8c

Please sign in to comment.