Skip to content

Commit 9678110

Browse files
author
Jani Rahkola
committed
numbered tests
1 parent 32c6ed0 commit 9678110

File tree

3 files changed

+44
-54
lines changed

3 files changed

+44
-54
lines changed

README.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
# structured-data
22

3-
I'm an app. Or maybe I'm a library? I haven't decided yet.
4-
5-
The choice is up to you!
3+
I'm part of the [120 hour epic sax marathon](http://iloveponies.github.com/120-hour-epic-sax-marathon/).
64

75
## Usage
86

9-
FIXME
10-
11-
## License
12-
13-
Copyright © 2012 FIXME
14-
15-
Distributed under the Eclipse Public License, the same as Clojure.
7+
Make a fork of me!

project.clj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
(defproject structured-data "0.1.0-SNAPSHOT"
2-
:dependencies [[org.clojure/clojure "1.4.0"]]
3-
:profiles {:dev {:dependencies [[midje "1.4.0"]
4-
[com.stuartsierra/lazytest "1.2.3"]]
5-
:plugins [[lein-midje "2.0.0-SNAPSHOT"]]}}
6-
:repositories {"stuart" "http://stuartsierra.com/maven2"})
2+
:dependencies [[org.clojure/clojure "1.5.0"]]
3+
:profiles {:dev {:dependencies [[midje "1.5-RC1"]]
4+
:plugins [[lein-midje "3.0-RC1"]]}})
75

test/structured_data_test.clj

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,48 @@
22
(:use structured-data
33
midje.sweet))
44

5-
(facts "do-a-thing"
5+
(facts "1 do-a-thing"
66
(do-a-thing 3) => 46656.0
77
(do-a-thing 1) => 4.0
88
(do-a-thing 0) => 1.0)
99

10-
(facts "spiff"
10+
(facts "2 spiff"
1111
(spiff [1 2 3]) => 4
1212
(spiff [1 2 -34 4 5 6]) => -33)
1313

14-
(facts "cutify"
14+
(facts "3 cutify"
1515
(cutify []) => ["<3"]
1616
(cutify [1 2 3]) => [1 2 3 "<3"]
1717
(cutify ["a" "b"]) => ["a" "b" "<3"])
1818

19-
(facts "spiff-destructuring"
19+
(facts "4 spiff-destructuring"
2020
(spiff-destructuring [1 2 3]) => 4
2121
(spiff-destructuring [1 2 -34 4 5 6]) => -33)
2222

23-
(facts "width"
23+
(facts "5 width"
2424
(width (rectangle [1 1] [5 1])) => 4
2525
(width (rectangle [1 1] [1 1])) => 0
2626
(width (rectangle [3 1] [10 4])) => 7)
2727

28-
(facts "height"
28+
(facts "5 height"
2929
(height (rectangle [1 1] [5 1])) => 0
3030
(height (rectangle [1 1] [5 5])) => 4
3131
(height (rectangle [0 0] [2 3])) => 3)
3232

33-
(facts "square?"
33+
(facts "6 square?"
3434
(square? (rectangle [1 1] [2 2])) => true
3535
(square? (rectangle [1 1] [2 3])) => false
3636
(square? (rectangle [1 1] [1 1])) => true
3737
(square? (rectangle [3 2] [1 0])) => true
3838
(square? (rectangle [3 2] [1 1])) => false)
3939

40-
(facts "area"
40+
(facts "7 area"
4141
(area (rectangle [1 1] [5 1])) => 0
4242
(area (rectangle [0 0] [1 1])) => 1
4343
(area (rectangle [0 0] [4 3])) => 12
4444
(area (rectangle [3 1] [10 4])) => 21)
4545

46-
(facts "contains-point?"
46+
(facts "8 contains-point?"
4747
(contains-point? (rectangle [0 0] [2 2])
4848
(point 1 1)) => true
4949
(contains-point? (rectangle [0 0] [2 2])
@@ -57,7 +57,7 @@
5757
(contains-point? (rectangle [1 1] [1 1])
5858
(point 1 1)) => true)
5959

60-
(facts "contains-rectangle?"
60+
(facts "9 contains-rectangle?"
6161
(contains-rectangle? (rectangle [0 0] [3 3])
6262
(rectangle [1 1] [2 2])) => true
6363
(contains-rectangle? (rectangle [0 0] [2 2])
@@ -95,22 +95,22 @@
9595
:authors [friedman, felleisen]}
9696
books [cities, wild-seed, embassytown, little-schemer]]
9797

98-
(facts "title-length"
98+
(facts "10 title-length"
9999
(title-length cities) => 21
100100
(title-length wild-seed) => 9
101101
(title-length little-schemer) => 18)
102102

103-
(facts "author-count"
103+
(facts "11 author-count"
104104
(author-count cities) => 1
105105
(author-count wild-seed) => 1
106106
(author-count little-schemer) => 2)
107107

108-
(facts "multiple-authors?"
108+
(facts "12 multiple-authors?"
109109
(multiple-authors? cities) => false
110110
(multiple-authors? wild-seed) => false
111111
(multiple-authors? little-schemer) => true)
112112

113-
(facts "add-author"
113+
(facts "13 add-author"
114114
(add-author little-schemer {:name "Gerald J. Sussman"})
115115
=> {:title "The Little Schemer"
116116
:authors [{:birth-year 1944, :name "Daniel Friedman"}
@@ -119,48 +119,48 @@
119119
(add-author {:authors [{:name "Juhana"}]} {:name "Jani"})
120120
=> {:authors [{:name "Juhana"} {:name "Jani"}]})
121121

122-
(facts "alive?"
122+
(facts "14 alive?"
123123
(alive? china) => true
124124
(alive? octavia) => false)
125125

126-
(facts "element-lengths"
126+
(facts "15 element-lengths"
127127
(element-lengths ["foo" "bar" "" "quux"]) => [3 3 0 4]
128128
(element-lengths ["x" [:a :b :c] {:y 42}]) => [1 3 1])
129129

130-
(facts "second-elements"
130+
(facts "16 second-elements"
131131
(second-elements [[1 2] [2 3] [3 4]]) => [2 3 4]
132132
(second-elements [[1 2 3 4] [1] ["a" "s" "d" "f"]]) => [2 nil "s"])
133133

134-
(facts "titles"
134+
(facts "17 titles"
135135
(titles [cities]) => ["The City and the City"]
136136
(titles books) => (just ["The City and the City"
137137
"Wild Seed"
138138
"Embassytown"
139139
"The Little Schemer"]
140140
:in-any-order)))
141141

142-
(facts "monotonic?"
142+
(facts "18 stars"
143+
(stars 1) => "*"
144+
(stars 7) => "*******"
145+
(stars 3) => "***")
146+
147+
(facts "19 monotonic?"
143148
(monotonic? [1 2 3]) => true
144149
(monotonic? [0 1 10 11]) => true
145150
(monotonic? [3 2 0 -3]) => true
146151
(monotonic? [3 2 2]) => true
147152
(monotonic? [1 2 1 0]) => false)
148153

149-
(facts "stars"
150-
(stars 1) => "*"
151-
(stars 7) => "*******"
152-
(stars 3) => "***")
153-
154-
(facts "toggle"
154+
(facts "20 toggle"
155155
(toggle #{:a :b :c} :d) => #{:a :b :c :d}
156156
(toggle #{:a :b :c} :a) => #{:b :c})
157157

158-
(facts "contains-duplicates?"
158+
(facts "21 contains-duplicates?"
159159
(contains-duplicates? [1 1 2 3 -40]) => true
160160
(contains-duplicates? [1 2 3 -40]) => false
161161
(contains-duplicates? [1 2 3 "a" "a"]) => true)
162162

163-
(facts "old-book->new-book"
163+
(facts "22 old-book->new-book"
164164
(old-book->new-book {:title "The Little Schemer"
165165
:authors [friedman, felleisen]})
166166
=> {:title "The Little Schemer" :authors #{friedman, felleisen}}
@@ -193,31 +193,31 @@
193193

194194
books [cities, wild-seed, embassytown, little-schemer]]
195195

196-
(facts "has-author?"
196+
(facts "23 has-author?"
197197
(has-author? cities china) => true
198198
(has-author? cities felleisen) => false
199199
(has-author? little-schemer felleisen) => true
200200
(has-author? little-schemer friedman) => true
201201
(has-author? little-schemer octavia) => false)
202202

203-
(facts "authors"
203+
(facts "24 authors"
204204
(authors [cities, wild-seed]) => #{china, octavia}
205205
(authors [cities, wild-seed, embassytown]) => #{china, octavia}
206206
(authors [little-schemer, cities]) => #{china, friedman, felleisen})
207207

208-
(facts "all-author-names"
208+
(facts "25 all-author-names"
209209
(all-author-names []) => #{}
210210
(all-author-names [cities, wild-seed])
211211
=> #{"China Miéville" "Octavia E. Butler"}
212212
(all-author-names books)
213213
=> #{"Matthias Felleisen" "China Miéville"
214214
"Octavia E. Butler" "Daniel Friedman"})
215-
(facts "author->string"
215+
(facts "26 author->string"
216216
(author->string felleisen) => "Matthias Felleisen"
217217
(author->string friedman) => "Daniel Friedman (1944 - )"
218218
(author->string octavia) => "Octavia E. Butler (1947 - 2006)")
219219

220-
(facts "authors->string"
220+
(facts "27 authors->string"
221221
(authors->string (:authors little-schemer))
222222
=> (every-checker (contains "Daniel Friedman (1944 - )")
223223
(contains "Matthias Felleisen")
@@ -229,43 +229,43 @@
229229
(contains "Daniel Friedman (1944 - )")
230230
(contains ", ")))
231231

232-
(facts "book->string"
232+
(facts "28 book->string"
233233
(book->string wild-seed)
234234
=> "Wild Seed, written by Octavia E. Butler (1947 - 2006)"
235235
(book->string little-schemer)
236236
=> (every-checker (has-prefix "The Little Schemer, written by ")
237237
(has-suffix #"Daniel Friedman \(1944 - \), Matthias Felleisen|Matthias Felleisen, Daniel Friedman \(1944 - \)")))
238238

239-
(facts "books->string"
239+
(facts "29 books->string"
240240
(books->string []) => "No books."
241241
(books->string [cities])
242242
=> "1 book. The City and the City, written by China Miéville (1972 - )."
243243
(books->string [little-schemer, cities, wild-seed])
244244
=> #"3 books. The Little Schemer, written by (Daniel Friedman \(1944 - \), Matthias Felleisen|Matthias Felleisen, Daniel Friedman \(1944 - \)). The City and the City, written by China Miéville \(1972 - \). Wild Seed, written by Octavia E. Butler \(1947 - 2006\).")
245245

246-
(facts "books-by-author"
246+
(facts "30 books-by-author"
247247
(books-by-author china books) => (just [cities embassytown])
248248
(books-by-author octavia books) => (just [wild-seed]))
249249

250-
(facts "author-by-name"
250+
(facts "31 author-by-name"
251251
(author-by-name "Octavia E. Butler" authors-set) => octavia
252252
(author-by-name "Octavia E. Butler" #{felleisen, friedman}) => nil
253253
(author-by-name "China Miéville" authors-set) => china
254254
(author-by-name "Goerge R. R. Martin" authors-set) => nil)
255255

256-
(facts "living-authors"
256+
(facts "32 living-authors"
257257
(living-authors authors-set) => (just #{china, felleisen, friedman})
258258
(living-authors #{octavia}) => (just #{})
259259
(living-authors #{china, felleisen}) => (just #{china, felleisen}))
260260

261-
(facts "has-a-living-author?"
261+
(facts "33 has-a-living-author?"
262262
(has-a-living-author? wild-seed) => false
263263
(has-a-living-author? silmarillion) => true
264264
(has-a-living-author? little-schemer) => true
265265
(has-a-living-author? cities) => true
266266
(has-a-living-author? deus-irae) => false)
267267

268-
(facts "books-by-living-authors"
268+
(facts "34 books-by-living-authors"
269269
(books-by-living-authors books) => (just #{little-schemer cities embassytown})
270270
(books-by-living-authors (concat books [deus-irae, silmarillion]))
271271
=> (just #{little-schemer cities embassytown silmarillion})))

0 commit comments

Comments
 (0)