beautify code
This commit is contained in:
1 parent
3ed03675dd
commit
70d4e9f47f
2 files changed
+64
-75
No files matched your search
+13
-13
@@ -7,28 +7,28 @@
|
||||
(testing "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-buy-order-in-sell-book sell-book order)]
|
||||
[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}]))))
|
||||
|
||||
(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-buy-order-in-sell-book sell-book order)]
|
||||
[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-buy-order-in-sell-book sell-book order)]
|
||||
[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-buy-order-in-sell-book sell-book order)]
|
||||
[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}]))))
|
||||
@@ -36,7 +36,7 @@
|
||||
(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-buy-order-in-sell-book sell-book order)]
|
||||
[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}]))))
|
||||
@@ -44,7 +44,7 @@
|
||||
(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-buy-order-in-sell-book sell-book order)]
|
||||
[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}]))
|
||||
@@ -53,7 +53,7 @@
|
||||
(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-buy-order-in-sell-book sell-book order)]
|
||||
[trades new-book leftover-order] (match-order-in-book sell-book order)]
|
||||
(is (= new-book sell-book))
|
||||
(is (= trades []))
|
||||
(is (= leftover-order order)))))
|
||||
@@ -63,21 +63,21 @@
|
||||
(testing "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-sell-order-in-buy-book buy-book order)]
|
||||
[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}]))))
|
||||
|
||||
(testing "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-sell-order-in-buy-book buy-book order)]
|
||||
[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}]))))
|
||||
|
||||
(testing "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-sell-order-in-buy-book buy-book order)]
|
||||
[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}]))))
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
(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-sell-order-in-buy-book buy-book order)]
|
||||
[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}]))))
|
||||
@@ -94,7 +94,7 @@
|
||||
(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-sell-order-in-buy-book buy-book order)]
|
||||
[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}]))))
|
||||
@@ -103,7 +103,7 @@
|
||||
(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-sell-order-in-buy-book sell-book order)]
|
||||
[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}]))
|
||||
|
||||
Reference in new issue
Block a user