May 2018
Beginner to intermediate
290 pages
6h 43m
English
Let’s begin our adventures in testing by building a brand-new book store inventory project:
$ lein new inventory
Now imagine we’re going to have a book inventory that looks like this:
| | [{:title "2001" :author "Clarke" :copies 21} |
| | {:title "Emma" :author "Austen" :copies 10} |
| | {:title "Misery" :author "King" :copies 101}]) |
And we write some functions to do useful things with it:
| | (ns inventory.core) |
| | |
| | (defn find-by-title |
| | "Search for a book by title, |
| | where title is a string and books is a collection |
| | of book maps, each of which must have a :title entry" |
| | [title books] |
| | (some #(when (= (:title %) title) %) books)) |
| | |
| | (defn number-of-copies-of |
| |
Read now
Unlock full access