Fixed many bugs.
This commit is contained in:
1 parent
ad924ca5c7
commit
174319293c
10 files changed
+227
-94
No files matched your search
@@ -2,6 +2,9 @@
|
||||
(:require [midje.sweet :refer :all]
|
||||
[book.match :refer :all]))
|
||||
|
||||
(def PersistentSortedList? (comp #(= % book.PersistentSortedList) type))
|
||||
|
||||
|
||||
(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})
|
||||
@@ -101,4 +104,21 @@
|
||||
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})))
|
||||
leftover-order => {:type :sell :quantity 11 :price 13 :book.order/id 118})))
|
||||
|
||||
(facts "We should write tests for each bug found"
|
||||
(fact "book type should always be book.PersistentSortedList"
|
||||
(let [book (create-buy-book)
|
||||
order {:type :sell :quantity 21 :price 13 :book.order/id 118}
|
||||
[_ new-book _] (match-order-in-book book order)]
|
||||
(count new-book) => 0
|
||||
(type new-book) => book.PersistentSortedList)))
|
||||
;(fact "should not fuck up"
|
||||
; (let [order-1 {:type :buy :quantity 4 :price 4 :book.order/id 5}
|
||||
; order-2 {:type :sell :quantity 2 :price 3 :book.order/id 6}
|
||||
; book (create-buy-book order-1)
|
||||
; expt-trade #:book.order{}
|
||||
; [trades new-book new-order] (match-order-in-book book order-2)]
|
||||
; trades => 1
|
||||
; new-order => nil?
|
||||
; new-book => {})))
|
||||
Reference in new issue
Block a user