Use midje for testing
This commit is contained in:
1 parent
c099924a89
commit
516cccf4cd
5 files changed
+161
-122
No files matched your search
@@ -15,18 +15,45 @@
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Leiningen: clj-time:0.14.2" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: clj-tuple:0.2.2" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: clojure-complete:0.2.4" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: colorize:0.1.1" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: com.rpl/specter:1.0.4" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: commons-codec:1.10" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: environ:1.1.0" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: fipp:0.6.10" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: flare:0.2.9" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: io.aviso/pretty:0.1.34" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: joda-time:2.9.7" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: marick/clojure-commons:3.0.0" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: marick/suchwow:6.0.0" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: midje:1.9.1" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: mvxcvi/arrangement:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: mvxcvi/puget:1.0.2" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojars.brenton/google-diff-match-patch:0.1" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/clojure:1.9.0" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/core.async:0.4.474" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/core.cache:0.6.5" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/core.memoize:0.5.9" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/core.rrb-vector:0.0.11" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/core.specs.alpha:0.1.24" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/core.unify:0.5.7" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/data.priority-map:0.0.7" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/math.combinatorics:0.1.4" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/spec.alpha:0.1.143" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/test.check:0.9.0" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/tools.analyzer.jvm:0.7.0" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/tools.analyzer:0.6.9" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/tools.macro:0.1.5" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/tools.namespace:0.2.11" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/tools.nrepl:0.2.12" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.clojure/tools.reader:1.0.0-beta4" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.ow2.asm/asm-all:4.2" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: org.tcrawley/dynapath:1.0.0" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: potemkin:0.4.3" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: riddley:0.1.12" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: slingshot:0.12.2" level="project" />
|
||||
<orderEntry type="library" name="Leiningen: swiss-arrows:1.0.0" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
+5
-1
@@ -8,4 +8,8 @@
|
||||
:java-source-paths ["src/java"]
|
||||
:main ^:skip-aot book.core
|
||||
:target-path "target/%s"
|
||||
:profiles {:uberjar {:aot :all}})
|
||||
:plugins [[lein-midje "3.2.1"]]
|
||||
:profiles {
|
||||
:uberjar {:aot :all}
|
||||
:dev {:dependencies [[midje "1.9.1"]]}})
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
(ns book.core-test
|
||||
(:require [midje.sweet :refer :all]))
|
||||
|
||||
(facts "big fact"
|
||||
(fact "about trivialities"
|
||||
(let [expt 3]
|
||||
(inc 2) => expt
|
||||
(inc 2) => expt))
|
||||
|
||||
(fact "about trivialities 2"
|
||||
(let [expt 3]
|
||||
(inc 2) => expt
|
||||
(inc 2) => expt)))
|
||||
+69
-75
@@ -1,110 +1,104 @@
|
||||
(ns book.match-test
|
||||
(:require [clojure.test :refer :all]
|
||||
(:require [midje.sweet :refer :all]
|
||||
[book.match :refer :all]))
|
||||
|
||||
|
||||
(deftest test-match-buy-order-in-sell-book
|
||||
(testing "Simplest case I."
|
||||
(facts "matching buy order in sell book"
|
||||
(fact "Simplest case I."
|
||||
(let [sell-book (create-sell-book {:type :sell :quantity 10 :price 2 :book.order/id 101})
|
||||
order {:type :buy :quantity 10 :price 2 :book.order/id 102}
|
||||
[trades new-book] (match-order-in-book sell-book order)]
|
||||
(is (empty? new-book))
|
||||
(is (= trades [#:book.order{:quantity 10 :price 2 :book-id 101 :order-id 102 :type :sell}]))))
|
||||
new-book => empty?
|
||||
trades => [#:book.order{:quantity 10 :price 2 :book-id 101 :order-id 102 :type :sell}]))
|
||||
|
||||
(testing "Simplest case II."
|
||||
(let [sell-book (create-sell-book {:type :sell :quantity 10 :price 2 :book.order/id 103})
|
||||
order {:type :buy :quantity 10 :price 3 :book.order/id 104}
|
||||
[trades new-book] (match-order-in-book sell-book order)]
|
||||
(is (empty? new-book))
|
||||
(is (= trades [#:book.order{:quantity 10 :price 2 :book-id 103 :order-id 104 :type :sell}]))))
|
||||
|
||||
(testing "Simplest case III."
|
||||
(let [sell-book (create-sell-book {:type :sell :quantity 10 :price 2 :book.order/id 105})
|
||||
order {:type :buy :quantity 8 :price 2 :book.order/id 106}
|
||||
[trades new-book] (match-order-in-book sell-book order)]
|
||||
(is (= new-book [{:type :sell :quantity 2 :price 2 :book.order/id 105}]))
|
||||
(is (= trades [#:book.order{:quantity 8 :price 2 :book-id 105 :order-id 106 :type :sell}]))))
|
||||
|
||||
(testing "Simplest case IV."
|
||||
(let [sell-book (create-sell-book {:type :sell :quantity 2 :price 12 :book.order/id 107} {:type :sell :quantity 8 :price 13 :book.order/id 108})
|
||||
order {:type :buy :quantity 10 :price 13 :book.order/id 109}
|
||||
[trades new-book] (match-order-in-book sell-book order)]
|
||||
(is (empty? new-book))
|
||||
(is (= trades [#:book.order{:quantity 2 :price 12 :book-id 107 :order-id 109 :type :sell}
|
||||
#:book.order{:quantity 8 :price 13 :book-id 108 :order-id 109 :type :sell}]))))
|
||||
|
||||
(testing "Simplest case V."
|
||||
(let [sell-book (create-sell-book {:type :sell :quantity 2 :price 12 :book.order/id 113} {:type :sell :quantity 8 :price 13 :book.order/id 114})
|
||||
order {:type :buy :quantity 9 :price 13 :book.order/id 115}
|
||||
[trades new-book] (match-order-in-book sell-book order)]
|
||||
(is (= new-book (create-sell-book {:type :sell :quantity 1 :price 13 :book.order/id 114})))
|
||||
(is (= trades [#:book.order{:quantity 2 :price 12 :book-id 113 :order-id 115 :type :sell}
|
||||
#:book.order{:quantity 7 :price 13 :book-id 114 :order-id 115 :type :sell}]))))
|
||||
|
||||
(testing "Simplest case VI."
|
||||
(let [sell-book (create-sell-book {:type :sell :quantity 2 :price 12 :book.order/id 116} {:type :sell :quantity 8 :price 13 :book.order/id 117})
|
||||
order {:type :buy :quantity 21 :price 13 :book.order/id 118}
|
||||
[trades new-book leftover-order] (match-order-in-book sell-book order)]
|
||||
(is (empty? new-book))
|
||||
(is (= trades [#:book.order{:quantity 2 :price 12 :book-id 116 :order-id 118 :type :sell}
|
||||
#:book.order{:quantity 8 :price 13 :book-id 117 :order-id 118 :type :sell}]))
|
||||
(is (= leftover-order {:type :buy :quantity 11 :price 13 :book.order/id 118}))))
|
||||
|
||||
(testing "Simplest case VII."
|
||||
(let [sell-book (create-sell-book {:type :sell :quantity 2 :price 12 :book.order/id 116} {:type :sell :quantity 8 :price 13 :book.order/id 117})
|
||||
order {:type :buy :quantity 21 :price 10 :book.order/id 118}
|
||||
[trades new-book leftover-order] (match-order-in-book sell-book order)]
|
||||
(is (= new-book sell-book))
|
||||
(is (= trades []))
|
||||
(is (= leftover-order order)))))
|
||||
(fact "Simplest case II."
|
||||
(let [sell-book (create-sell-book {:type :sell :quantity 10 :price 2 :book.order/id 103})
|
||||
order {:type :buy :quantity 10 :price 3 :book.order/id 104}
|
||||
[trades new-book] (match-order-in-book sell-book order)]
|
||||
new-book => empty?
|
||||
trades => [#:book.order{:quantity 10 :price 2 :book-id 103 :order-id 104 :type :sell}]))
|
||||
(fact "Simplest case III."
|
||||
(let [sell-book (create-sell-book {:type :sell :quantity 10 :price 2 :book.order/id 105})
|
||||
order {:type :buy :quantity 8 :price 2 :book.order/id 106}
|
||||
[trades new-book] (match-order-in-book sell-book order)]
|
||||
new-book => [{:type :sell :quantity 2 :price 2 :book.order/id 105}]
|
||||
trades => [#:book.order{:quantity 8 :price 2 :book-id 105 :order-id 106 :type :sell}]))
|
||||
(fact "Simplest case IV."
|
||||
(let [sell-book (create-sell-book {:type :sell :quantity 2 :price 12 :book.order/id 107} {:type :sell :quantity 8 :price 13 :book.order/id 108})
|
||||
order {:type :buy :quantity 10 :price 13 :book.order/id 109}
|
||||
[trades new-book] (match-order-in-book sell-book order)]
|
||||
new-book => empty?
|
||||
trades => [#:book.order{:quantity 2 :price 12 :book-id 107 :order-id 109 :type :sell}
|
||||
#:book.order{:quantity 8 :price 13 :book-id 108 :order-id 109 :type :sell}]))
|
||||
(fact "Simplest case V."
|
||||
(let [sell-book (create-sell-book {:type :sell :quantity 2 :price 12 :book.order/id 113} {:type :sell :quantity 8 :price 13 :book.order/id 114})
|
||||
order {:type :buy :quantity 9 :price 13 :book.order/id 115}
|
||||
[trades new-book] (match-order-in-book sell-book order)]
|
||||
new-book => (create-sell-book {:type :sell :quantity 1 :price 13 :book.order/id 114})
|
||||
trades => [#:book.order{:quantity 2 :price 12 :book-id 113 :order-id 115 :type :sell}
|
||||
#:book.order{:quantity 7 :price 13 :book-id 114 :order-id 115 :type :sell}]))
|
||||
(fact "Simplest case VI."
|
||||
(let [sell-book (create-sell-book {:type :sell :quantity 2 :price 12 :book.order/id 116} {:type :sell :quantity 8 :price 13 :book.order/id 117})
|
||||
order {:type :buy :quantity 21 :price 13 :book.order/id 118}
|
||||
[trades new-book leftover-order] (match-order-in-book sell-book order)]
|
||||
new-book => empty?
|
||||
trades => [#:book.order{:quantity 2 :price 12 :book-id 116 :order-id 118 :type :sell}
|
||||
#:book.order{:quantity 8 :price 13 :book-id 117 :order-id 118 :type :sell}]
|
||||
leftover-order => {:type :buy :quantity 11 :price 13 :book.order/id 118}))
|
||||
(fact "Simplest case VII."
|
||||
(let [sell-book (create-sell-book {:type :sell :quantity 2 :price 12 :book.order/id 116} {:type :sell :quantity 8 :price 13 :book.order/id 117})
|
||||
order {:type :buy :quantity 21 :price 10 :book.order/id 118}
|
||||
[trades new-book leftover-order] (match-order-in-book sell-book order)]
|
||||
new-book => sell-book
|
||||
trades => empty?
|
||||
leftover-order => order)))
|
||||
|
||||
|
||||
(deftest test-match-sell-order-in-buy-book
|
||||
(testing "Simplest case I."
|
||||
(facts "matching sell order in buy book"
|
||||
(fact "Simplest case I."
|
||||
(let [buy-book (create-buy-book {:type :buy :quantity 10 :price 2 :book.order/id 101})
|
||||
order {:type :sell :quantity 10 :price 2 :book.order/id 102}
|
||||
[trades new-book] (match-order-in-book buy-book order)]
|
||||
(is (= new-book []))
|
||||
(is (= trades [#:book.order{:quantity 10 :price 2 :book-id 101 :order-id 102 :type :buy}]))))
|
||||
new-book => empty?
|
||||
trades => [#:book.order{:quantity 10 :price 2 :book-id 101 :order-id 102 :type :buy}]))
|
||||
|
||||
(testing "Simplest case II."
|
||||
(fact "Simplest case II."
|
||||
(let [buy-book (create-buy-book {:type :buy :quantity 10 :price 4 :book.order/id 103})
|
||||
order {:type :sell :quantity 10 :price 3 :book.order/id 104}
|
||||
[trades new-book] (match-order-in-book buy-book order)]
|
||||
(is (= new-book []))
|
||||
(is (= trades [#:book.order{:quantity 10 :price 4 :book-id 103 :order-id 104 :type :buy}]))))
|
||||
new-book => []
|
||||
trades => [#:book.order{:quantity 10 :price 4 :book-id 103 :order-id 104 :type :buy}]))
|
||||
|
||||
(testing "Simplest case III."
|
||||
(fact "Simplest case III."
|
||||
(let [buy-book (create-buy-book {:type :buy :quantity 10 :price 2 :book.order/id 105})
|
||||
order {:type :sell :quantity 8 :price 2 :book.order/id 106}
|
||||
[trades new-book] (match-order-in-book buy-book order)]
|
||||
(is (= new-book [{:type :buy :quantity 2 :price 2 :book.order/id 105}]))
|
||||
(is (= trades [#:book.order{:quantity 8 :price 2 :book-id 105 :order-id 106 :type :buy}]))))
|
||||
new-book => [{:type :buy :quantity 2 :price 2 :book.order/id 105}]
|
||||
trades => [#:book.order{:quantity 8 :price 2 :book-id 105 :order-id 106 :type :buy}]))
|
||||
|
||||
(testing "Simplest case IV."
|
||||
(fact "Simplest case IV."
|
||||
(let [buy-book (create-buy-book {:type :buy :quantity 2 :price 14 :book.order/id 107}
|
||||
{:type :buy :quantity 8 :price 13 :book.order/id 108})
|
||||
order {:type :sell :quantity 10 :price 13 :book.order/id 109}
|
||||
[trades new-book] (match-order-in-book buy-book order)]
|
||||
(is (= new-book []))
|
||||
(is (= trades [#:book.order{:quantity 2 :price 14 :book-id 107 :order-id 109 :type :buy}
|
||||
#:book.order{:quantity 8 :price 13 :book-id 108 :order-id 109 :type :buy}]))))
|
||||
new-book => []
|
||||
trades => [#:book.order{:quantity 2 :price 14 :book-id 107 :order-id 109 :type :buy}
|
||||
#:book.order{:quantity 8 :price 13 :book-id 108 :order-id 109 :type :buy}]))
|
||||
|
||||
(testing "Simplest case V."
|
||||
(fact "Simplest case V."
|
||||
(let [buy-book (create-buy-book {:type :buy :quantity 2 :price 14 :book.order/id 113}
|
||||
{:type :buy :quantity 8 :price 13 :book.order/id 114})
|
||||
order {:type :sell :quantity 9 :price 13 :book.order/id 115}
|
||||
[trades new-book] (match-order-in-book buy-book order)]
|
||||
(= new-book (create-buy-book {:type :buy :quantity 1 :price 13 :book.order/id 114}))
|
||||
(is (= trades [#:book.order{:quantity 2 :price 14 :book-id 113 :order-id 115 :type :buy}
|
||||
#:book.order{:quantity 7 :price 13 :book-id 114 :order-id 115 :type :buy}]))))
|
||||
new-book => (create-buy-book {:type :buy :quantity 1 :price 13 :book.order/id 114})
|
||||
trades => [#:book.order{:quantity 2 :price 14 :book-id 113 :order-id 115 :type :buy}
|
||||
#:book.order{:quantity 7 :price 13 :book-id 114 :order-id 115 :type :buy}]))
|
||||
|
||||
(testing "Simplest case VI."
|
||||
(fact "Simplest case VI."
|
||||
(let [sell-book (create-buy-book {:type :buy :quantity 2 :price 14 :book.order/id 116}
|
||||
{:type :buy :quantity 8 :price 13 :book.order/id 117})
|
||||
order {:type :sell :quantity 21 :price 13 :book.order/id 118}
|
||||
[trades new-book leftover-order] (match-order-in-book sell-book order)]
|
||||
(is (empty? new-book))
|
||||
(is (= trades [#:book.order{:quantity 2 :price 14 :book-id 116 :order-id 118 :type :buy}
|
||||
#:book.order{:quantity 8 :price 13 :book-id 117 :order-id 118 :type :buy}]))
|
||||
(is (= leftover-order {:type :sell :quantity 11 :price 13 :book.order/id 118})))))
|
||||
new-book => empty?
|
||||
trades => [#:book.order{:quantity 2 :price 14 :book-id 116 :order-id 118 :type :buy}
|
||||
#:book.order{:quantity 8 :price 13 :book-id 117 :order-id 118 :type :buy}]
|
||||
leftover-order => {:type :sell :quantity 11 :price 13 :book.order/id 118})))
|
||||
@@ -1,52 +1,53 @@
|
||||
(ns book.test-PersistentSortedList
|
||||
(:require [clojure.test :refer :all]
|
||||
(:require [midje.sweet :refer :all]
|
||||
[book.util :refer [sorted-list sorted-list-by]]))
|
||||
|
||||
|
||||
|
||||
(deftest test-match-buy-order-in-sell-book
|
||||
(testing "constructing"
|
||||
(is (empty? (map nil? (sorted-list)))))
|
||||
(facts "test-match-buy-order-in-sell-book"
|
||||
(fact "constructing"
|
||||
(map nil? (sorted-list)) => empty?)
|
||||
;; The following are tests that fails...
|
||||
;(is (empty? (vec (sorted-list)))))
|
||||
(testing "Test ordering."
|
||||
(is (= (sorted-list 1 2 3) (sorted-list 3 2 1)))
|
||||
(is (= (sorted-list 1 2 2 3) (sorted-list 3 2 1 2))))
|
||||
(testing "count"
|
||||
(is (= (count (sorted-list)) 0))
|
||||
(is (= (count (sorted-list 1 2 3)) 3))
|
||||
(is (= (count (sorted-list 1 2 3 2)) 4)))
|
||||
(testing "rest"
|
||||
(is (= (rest (sorted-list 1 2 3)) (sorted-list 2 3)))
|
||||
(is (= (rest (sorted-list 1 2 3 2)) (sorted-list 2 2 3)))
|
||||
(is (= (rest (sorted-list 1)) (list)))
|
||||
(is (empty? (rest (sorted-list))))
|
||||
(is (= (str (type (rest (sorted-list)))) "class book.PersistentSortedList")))
|
||||
(testing "next"
|
||||
(is (= (next (sorted-list 1 2 3)) (sorted-list 2 3)))
|
||||
(is (= (next (sorted-list 1 2 3 2)) (sorted-list 2 2 3)))
|
||||
(is (= (next (sorted-list 1)) nil))
|
||||
(is (= (next (sorted-list)) nil)))
|
||||
(testing "drop"
|
||||
(is (= (drop 2 (sorted-list 1 2 3)) (sorted-list 3)))
|
||||
(is (= (drop 3 (sorted-list 1 2 3)) (list))))
|
||||
(testing "reduce"
|
||||
(is (= (reduce + (sorted-list 1 2 3)) 6))
|
||||
(is (= (reduce + 10 (sorted-list 1 2 3)) 16)))
|
||||
(testing "peek/pop"
|
||||
(is (= (peek (sorted-list 1 2 3)) 1))
|
||||
(is (= (peek (sorted-list 1 1 1 2 3)) 1))
|
||||
(is (= (peek (sorted-list)) nil))
|
||||
(is (= (pop (sorted-list 1 2 3)) (sorted-list 2 3)))
|
||||
(is (= (pop (sorted-list 1 1 2 3)) (sorted-list 1 2 3)))
|
||||
(is (= (pop (sorted-list 1 1 1 2 3)) (sorted-list 1 1 2 3)))
|
||||
(is (thrown? IllegalStateException (pop (sorted-list)) nil)))
|
||||
(testing "count after change"
|
||||
(let [l (sorted-list 1 2 3)]
|
||||
(is (= (count (conj l 4)) 4))
|
||||
(is (= (count (conj l 3)) 4))
|
||||
(is (= (count (cons 3 l)) 4))
|
||||
(is (= (count (rest l)) 2))
|
||||
(is (= (count (pop l)) 2))))
|
||||
(testing "sorted-list-by"
|
||||
(is (= (sorted-list-by > 1 2 3) [3 2 1]))))
|
||||
;(vec (sorted-list)) => empty?)
|
||||
(fact "Test ordering."
|
||||
(sorted-list 1 2 3) => (sorted-list 3 2 1)
|
||||
(sorted-list 1 2 2 3) => (sorted-list 3 2 1 2))
|
||||
(fact "count"
|
||||
(count (sorted-list)) => 0
|
||||
(count (sorted-list 1 2 3)) => 3
|
||||
(count (sorted-list 1 2 3 2)) => 4)
|
||||
(fact "rest"
|
||||
(rest (sorted-list 1 2 3)) => (sorted-list 2 3)
|
||||
(rest (sorted-list 1 2 3 2)) => (sorted-list 2 2 3)
|
||||
(rest (sorted-list 1)) => (sorted-list)
|
||||
(rest (sorted-list)) => empty?
|
||||
(str (type (rest (sorted-list)))) => "class book.PersistentSortedList")
|
||||
(fact "next"
|
||||
(next (sorted-list 1 2 3)) => (sorted-list 2 3)
|
||||
(next (sorted-list 1 2 3 2)) => (sorted-list 2 2 3)
|
||||
(next (sorted-list 1)) => nil
|
||||
(next (sorted-list)) => nil)
|
||||
(fact "drop"
|
||||
(drop 2 (sorted-list 1 2 3)) => (sorted-list 3)
|
||||
(drop 3 (sorted-list 1 2 3)) => (list))
|
||||
(fact "reduce"
|
||||
(reduce + (sorted-list 1 2 3)) => 6
|
||||
(reduce + 10 (sorted-list 1 2 3)) => 16)
|
||||
(fact "peek/pop"
|
||||
(peek (sorted-list 1 2 3)) => 1
|
||||
(peek (sorted-list 1 1 1 2 3)) => 1
|
||||
(peek (sorted-list)) => nil
|
||||
(pop (sorted-list 1 2 3)) => (sorted-list 2 3)
|
||||
(pop (sorted-list 1 1 2 3)) => (sorted-list 1 2 3)
|
||||
(pop (sorted-list 1 1 1 2 3)) => (sorted-list 1 1 2 3)
|
||||
(pop (sorted-list)) => (throws IllegalStateException))
|
||||
|
||||
(fact "count after change"
|
||||
(let [l (sorted-list 1 2 3)]
|
||||
(count (conj l 4)) => 4
|
||||
(count (conj l 3)) => 4
|
||||
(count (cons 3 l)) => 4
|
||||
(count (rest l)) => 2
|
||||
(count (pop l)) => 2))
|
||||
(fact "sorted-list-by"
|
||||
(sorted-list-by > 1 2 3) => [3 2 1]))
|
||||
Reference in new issue
Block a user