forked from relevance/labrepl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converting tests back to clojure.test and regenerating pom.xml to mat…
…ch leiningen project file
- Loading branch information
Showing
18 changed files
with
176 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
log4j.rootLogger=WARN, A1 | ||
log4j.logger.user=DEBUG | ||
log4j.appender.A1=org.apache.log4j.ConsoleAppender | ||
log4j.appender.A1.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.A1.layout.ConversionPattern=%d %-5p %c: %m%n |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
(ns solutions.accounts-1-test | ||
(:use circumspec solutions.accounts-1)) | ||
(:use clojure.test | ||
solutions.accounts-1)) | ||
|
||
(testing "transfers" | ||
(deftest test-transfers | ||
(let [accounts (make-accounts {:initial-balance 100 | ||
:count 2})] | ||
(transfer {:accounts accounts :from 0 :to 1 :amount 25}) | ||
(should (= 75 (balance accounts 0))) | ||
(should (= 125 (balance accounts 1))))) | ||
(is (= 75 (balance accounts 0))) | ||
(is (= 125 (balance accounts 1))))) | ||
|
||
(testing "total balance is maintined when running in isolation" | ||
(let [accounts (make-accounts {:initial-balance 100 | ||
:count 10})] | ||
(should (= 1000 (total-balance accounts)) "balance before") | ||
(dotimes [_ 10] (random-transfer accounts)) | ||
(should (= 1000 (total-balance accounts)) "balance after"))) | ||
|
||
;; statistically this could fail | ||
(testing "total balance is *not* maintained across threads" | ||
(let [accounts (make-accounts {:initial-balance 100 | ||
:count 10})] | ||
(should (throws? | ||
Throwable | ||
#"Assert failed: \(= expected-balance \(total-balance accounts\)\)" | ||
(trial))))) | ||
(deftest test-balance | ||
(testing "total balance is maintined when running in isolation" | ||
(let [accounts (make-accounts {:initial-balance 100 | ||
:count 10})] | ||
(is (= 1000 (total-balance accounts)) "balance before") | ||
(dotimes [_ 10] (random-transfer accounts)) | ||
(is (= 1000 (total-balance accounts)) "balance after"))) | ||
(testing "total balance is *not* maintained across threads" | ||
(let [accounts (make-accounts {:initial-balance 100 | ||
:count 10})] | ||
(is (thrown? | ||
Throwable | ||
#"Assert failed: \(= expected-balance \(total-balance accounts\)\)" | ||
(trial)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
(ns solutions.accounts-2-test | ||
(:use circumspec solutions.accounts-2)) | ||
(:use clojure.test | ||
solutions.accounts-2)) | ||
|
||
(testing "transfers" | ||
(deftest test-transfers | ||
(let [accounts (make-accounts {:initial-balance 100 | ||
:count 2})] | ||
(transfer {:accounts accounts :from 0 :to 1 :amount 25}) | ||
(should (= 75 (balance accounts 0))) | ||
(should (= 125 (balance accounts 1))))) | ||
(is (= 75 (balance accounts 0))) | ||
(is (= 125 (balance accounts 1))))) | ||
|
||
(testing "total balance is maintined when running in isolation" | ||
(let [accounts (make-accounts {:initial-balance 100 | ||
:count 10})] | ||
(should (= 1000 (total-balance accounts)) "balance before") | ||
(dotimes [_ 10] (random-transfer accounts)) | ||
(should (= 1000 (total-balance accounts)) "balance after"))) | ||
|
||
(testing "total balance is maintained across threads" | ||
(let [accounts (make-accounts {:initial-balance 100 | ||
:count 10}) | ||
trial-results (trial)] | ||
(should (= 1000 (total-balance (:accounts trial-results)))))) | ||
(deftest test-balance | ||
(testing "total balance is maintined when running in isolation" | ||
(let [accounts (make-accounts {:initial-balance 100 | ||
:count 10})] | ||
(is (= 1000 (total-balance accounts)) "balance before") | ||
(dotimes [_ 10] (random-transfer accounts)) | ||
(is (= 1000 (total-balance accounts)) "balance after"))) | ||
(testing "total balance is maintained across threads" | ||
(let [accounts (make-accounts {:initial-balance 100 | ||
:count 10}) | ||
trial-results (trial)] | ||
(is (= 1000 (total-balance (:accounts trial-results))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
(ns solutions.accounts-3-test | ||
(:use circumspec solutions.accounts-3)) | ||
(:use clojure.test | ||
solutions.accounts-3)) | ||
|
||
(testing "transfers" | ||
(deftest test-transfers | ||
(let [accounts (make-accounts {:initial-balance 100 | ||
:count 2})] | ||
(transfer {:accounts accounts :from 0 :to 1 :amount 25}) | ||
(should (= 75 (balance accounts 0))) | ||
(should (= 125 (balance accounts 1))))) | ||
(is (= 75 (balance accounts 0))) | ||
(is (= 125 (balance accounts 1))))) | ||
|
||
(testing "total balance is maintined when running in isolation" | ||
(let [accounts (make-accounts {:initial-balance 100 | ||
:count 10})] | ||
(should (= 1000 (total-balance accounts)) "balance before") | ||
(dotimes [_ 10] (random-transfer accounts)) | ||
(should (= 1000 (total-balance accounts)) "balance after"))) | ||
|
||
(testing "total balance is maintained across threads" | ||
(let [accounts (make-accounts {:initial-balance 100 | ||
:count 10}) | ||
trial-results (trial)] | ||
(should (= 1000 (total-balance (:accounts trial-results)))))) | ||
(deftest test-balance | ||
(testing "total balance is maintined when running in isolation" | ||
(let [accounts (make-accounts {:initial-balance 100 | ||
:count 10})] | ||
(is (= 1000 (total-balance accounts)) "balance before") | ||
(dotimes [_ 10] (random-transfer accounts)) | ||
(is (= 1000 (total-balance accounts)) "balance after"))) | ||
(testing "total balance is maintained across threads" | ||
(let [accounts (make-accounts {:initial-balance 100 | ||
:count 10}) | ||
trial-results (trial)] | ||
(is (= 1000 (total-balance (:accounts trial-results))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
(ns solutions.atom-cache-test | ||
(:use circumspec) | ||
(:use clojure.test) | ||
(:require [solutions.atom-cache :as cache])) | ||
|
||
(testing "initial version" | ||
(deftest test-version | ||
(let [cache (cache/create-1)] | ||
(should (nil? (cache/get cache :foo))) | ||
(should (= {:foo :bar} (cache/put-1 cache :foo :bar))))) | ||
(is (nil? (cache/get cache :foo))) | ||
(is (= {:foo :bar} (cache/put-1 cache :foo :bar))))) | ||
|
||
(testing "improved version" | ||
(deftest test-improved-version | ||
(let [cache (cache/create {1 2})] | ||
(should (nil? (cache/get cache :foo))) | ||
(should (= {:foo :bar 1 2} (cache/put cache :foo :bar))) | ||
(should (= {:foo :zap 1 2} (cache/put cache {:foo :zap} ))))) | ||
(is (nil? (cache/get cache :foo))) | ||
(is (= {:foo :bar 1 2} (cache/put cache :foo :bar))) | ||
(is (= {:foo :zap 1 2} (cache/put cache {:foo :zap} ))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
(ns solutions.browser-mockup-test | ||
(:use solutions.browser-mockup circumspec)) | ||
(:use clojure.test | ||
solutions.browser-mockup)) | ||
|
||
(testing "rendering the mockups" | ||
(doseq [url ["/m1" "/m2" "/m3" "/m4"]] | ||
(deftest test-mockups | ||
(doseq [url ["/m1" "/m2" "/m3" "/m4"]] | ||
(let [resp (mockup-routes {:request-method :get :uri url})] | ||
(should (= {:status 200 :headers {"Content-Type" "text/html"}} | ||
(select-keys resp [:status :headers])))))) | ||
|
||
(is (= {:status 200 :headers {"Content-Type" "text/html"}} | ||
(select-keys resp [:status :headers])))))) |
Oops, something went wrong.