Skip to content

Commit

Permalink
Converting tests back to clojure.test and regenerating pom.xml to mat…
Browse files Browse the repository at this point in the history
…ch leiningen project file
  • Loading branch information
abedra committed Mar 29, 2011
1 parent 7d98f37 commit 485629a
Show file tree
Hide file tree
Showing 18 changed files with 176 additions and 179 deletions.
72 changes: 22 additions & 50 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,30 @@
<modelVersion>4.0.0</modelVersion>
<groupId>labrepl</groupId>
<artifactId>labrepl</artifactId>
<version>0.0.1</version>
<version>0.0.2-SNAPSHOT</version>
<name>labrepl</name>
<description>Clojure exercises, with integrated repl and webapp</description>
<scm>
<connection>scm:git:git://github.com/relevance/labrepl.git</connection>
<developerConnection>scm:git:ssh://git@github.com/relevance/labrepl.git</developerConnection>
<tag>e00d79f1431656cf081a9ae9ec9f3cce7be68b5c</tag>
<url>http://github.com/relevance/labrepl</url>
<tag>7d98f37340e0966ac86c100f5082570e9b8af170</tag>
<url>https://github.com/relevance/labrepl</url>
</scm>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>com.theoryinpractise</groupId>
<artifactId>clojure-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<sourceDirectories>
<sourceDirectory>src</sourceDirectory>
</sourceDirectories>
<clojureOptions>-Xmx1G</clojureOptions>
<replScript>script/run.clj</replScript>
<testScript>script/test.clj</testScript>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>test-resources</directory>
</testResource>
</testResources>
</build>
<repositories>
<repository>
<id>clojure-releases</id>
<url>http://build.clojure.org/releases</url>
</repository>
<repository>
<id>central</id>
<url>http://repo1.maven.org/maven2</url>
Expand All @@ -66,42 +48,37 @@
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure-contrib</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>compojure</groupId>
<artifactId>compojure</artifactId>
<version>0.4.0</version>
<version>0.6.2</version>
</dependency>
<dependency>
<groupId>ring</groupId>
<artifactId>ring-jetty-adapter</artifactId>
<version>0.2.3</version>
<version>0.3.7</version>
</dependency>
<dependency>
<groupId>hiccup</groupId>
<artifactId>hiccup</artifactId>
<version>0.2.6</version>
<version>0.3.4</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.4-701.jdbc4</version>
<version>9.0-801.jdbc4</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>incanter</groupId>
<artifactId>incanter</artifactId>
<version>1.2.3-SNAPSHOT</version>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>antlr</groupId>
Expand All @@ -116,22 +93,17 @@
<dependency>
<groupId>swank-clojure</groupId>
<artifactId>swank-clojure</artifactId>
<version>1.2.0</version>
<version>1.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>0.9.94</version>
</dependency>
<dependency>
<groupId>circumspec</groupId>
<artifactId>circumspec</artifactId>
<version>0.0.13</version>
</dependency>
</dependencies>
</project>

<!-- This file was autogenerated by the Leiningen build tool.
Please do not edit it directly; instead edit project.clj and regenerate it.
It should not be considered canonical data. For more information see
http://github.com/technomancy/leiningen -->
https://github.com/technomancy/leiningen -->
5 changes: 2 additions & 3 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject labrepl "0.0.2"
(defproject labrepl "0.0.2-SNAPSHOT"
:description "Clojure exercises, with integrated repl and webapp"
:dependencies [[org.clojure/clojure "1.2.1"]
[compojure "0.6.2"]
Expand All @@ -10,6 +10,5 @@
[antlr/stringtemplate "2.2"]
[clojure-http-client "1.0.0-SNAPSHOT"]
[swank-clojure "1.3.0-SNAPSHOT"]
[jline "0.9.94"]
[mycroft "0.0.2"]]
[jline "0.9.94"]]
:dev-dependencies [[swank-clojure "1.3.0-SNAPSHOT"]])
5 changes: 5 additions & 0 deletions resources/log4j.properties
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.
5 changes: 4 additions & 1 deletion src/labs/names_and_places.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
(ns ^{:skip-wiki true} labs.names-and-places
(:use labrepl.util clojure.contrib.math clojure.contrib.with-ns solutions.dialect)
(:use clojure.contrib.math
clojure.contrib.with-ns
labrepl.util
solutions.dialect)
(:require [clojure.contrib.math :as m])
(:import [java.util Date Random]))

Expand Down
3 changes: 2 additions & 1 deletion src/labs/project_euler.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns ^{:skip-wiki true} labs.project-euler
(:use labrepl.util solutions.project-euler))
(:use labrepl.util
solutions.project-euler))

(defn overview
[]
Expand Down
3 changes: 2 additions & 1 deletion src/labs/rock_paper_scissors.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns ^{:skip-wiki true} labs.rock-paper-scissors
(:use labrepl.util solutions.rock-paper-scissors))
(:use labrepl.util
solutions.rock-paper-scissors))

(defn overview
[]
Expand Down
38 changes: 19 additions & 19 deletions test/solutions/accounts_1_test.clj
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))))))
33 changes: 17 additions & 16 deletions test/solutions/accounts_2_test.clj
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)))))))
33 changes: 17 additions & 16 deletions test/solutions/accounts_3_test.clj
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)))))))
16 changes: 8 additions & 8 deletions test/solutions/atom_cache_test.clj
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} )))))
12 changes: 6 additions & 6 deletions test/solutions/browser_mockup_test.clj
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]))))))
Loading

0 comments on commit 485629a

Please sign in to comment.