Skip to content
Browse files

Converting tests back to clojure.test and regenerating pom.xml to mat…

…ch leiningen project file
  • Loading branch information...
1 parent 7d98f37 commit 485629aefb2fbda7062abb11b2964b7d37e80c8d @abedra abedra committed Mar 29, 2011
View
72 pom.xml
@@ -3,49 +3,31 @@
<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>
</repository>
@@ -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>
@@ -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 -->
View
5 project.clj
@@ -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"]
@@ -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"]])
View
5 resources/log4j.properties
@@ -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
View
0 test/solutions/automaton_test.clj → spec/automaton_test.clj
File renamed without changes.
View
0 test/solutions/mini_browser_test.clj → spec/mini_browser_test.clj
File renamed without changes.
View
0 test/solutions/project_euler_test.clj → spec/project_euler_test.clj
File renamed without changes.
View
0 test/solutions/rock_paper_scissors_test.clj → spec/rock_paper_scissors_test.clj
File renamed without changes.
View
5 src/labs/names_and_places.clj
@@ -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]))
View
3 src/labs/project_euler.clj
@@ -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
[]
View
3 src/labs/rock_paper_scissors.clj
@@ -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
[]
View
38 test/solutions/accounts_1_test.clj
@@ -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))))))
View
33 test/solutions/accounts_2_test.clj
@@ -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)))))))
View
33 test/solutions/accounts_3_test.clj
@@ -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)))))))
View
16 test/solutions/atom_cache_test.clj
@@ -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} )))))
View
12 test/solutions/browser_mockup_test.clj
@@ -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]))))))
View
47 test/solutions/defstrict_test.clj
@@ -1,30 +1,31 @@
(ns solutions.defstrict-test
- (:use circumspec solutions.defstrict))
+ (:use clojure.test
+ solutions.defstrict))
-(describe "shouts"
- (testing shout-1
- (should (= "FOO" (shout-1 "foo")))
- (should (throws? NullPointerException (shout-1 nil)))
- (should (throws? IllegalArgumentException (shout-1 :foo))))
+(deftest test-shouts
+ (testing "shout-1"
+ (is (= "FOO" (shout-1 "foo")))
+ (is (thrown? NullPointerException (shout-1 nil)))
+ (is (thrown? IllegalArgumentException (shout-1 :foo))))
(testing "shout-2 casts to String for performance"
- (should (= "FOO" (shout-2 "foo")))
- (should (throws? NullPointerException (shout-2 nil)))
- (should (throws? ClassCastException (shout-2 :foo))))
+ (is (= "FOO" (shout-2 "foo")))
+ (is (thrown? NullPointerException (shout-2 nil)))
+ (is (thrown? ClassCastException (shout-2 :foo))))
(testing "shout-3 uses precondition to guarantee string input"
- (should (= "FOO" (shout-3 "foo")))
- (should (throws? Throwable #"Assert failed" (shout-3 nil)))
- (should (throws? Throwable #"Assert failed" (shout-3 :foo))))
+ (is (= "FOO" (shout-3 "foo")))
+ (is (thrown? Throwable #"Assert failed" (shout-3 nil)))
+ (is (thrown? Throwable #"Assert failed" (shout-3 :foo))))
(testing "shout-4 works like shout-3"
- (should (= "FOO" (shout-4 "foo")))
- (should (throws? Throwable #"Assert failed" (shout-4 :bar)))
- (should (throws? Throwable #"Assert failed" (shout-4 :foo)))))
+ (is (= "FOO" (shout-4 "foo")))
+ (is (thrown? Throwable #"Assert failed" (shout-4 :bar)))
+ (is (thrown? Throwable #"Assert failed" (shout-4 :foo)))))
-(testing instance-check
- (should (nil? (instance-check 'foo)))
- (should (= '(clojure.core/instance? String foo) (instance-check '^String foo))))
+(deftest test-instance-check
+ (is (nil? (instance-check 'foo)))
+ (is (= '(clojure.core/instance? String foo) (instance-check '^String foo))))
-(testing arg-type-preconditions
- (should (= '{:pre
+(deftest test-arg-type-preconditions
+ (is (= '{:pre
[(clojure.core/instance? String a)
(clojure.core/instance? Integer/TYPE b)]}
(arg-type-preconditions '[^String a ^Integer/TYPE b]))))
@@ -35,13 +36,13 @@
[var]
(map (partial map meta) (:arglists (meta var))))
-(testing "defstrict"
- (should (= '(clojure.core/defn shout
+(deftest test-defstrict
+ (is (= '(clojure.core/defn shout
[s]
{:pre [(clojure.core/instance? String s)]}
(.toUpperCase s))
(macroexpand-1
'(solutions.defstrict/defstrict shout [^String s]
(.toUpperCase s)))))
- (should (= '(({:tag String}))
+ (is (= '(({:tag String}))
(argument-metadata #'shout))))
View
71 test/solutions/looping_test.clj
@@ -1,33 +1,46 @@
(ns solutions.looping-test
- (:use circumspec solutions.looping))
+ (:use clojure.test
+ solutions.looping))
-(testing "zipm"
- (for-these [result keys vals]
- (should (= result
- (zipm-1 keys vals)
- (zipm-2 keys vals)
- (zipm-3 keys vals)
- (zipm-4 keys vals)
- (zipm-5 keys vals)
- (zipmap keys vals)))
- {} nil nil
- {:a 1} [:a] [1]))
+(deftest test-zipm
+ (are [result keys vals] (= result (zipm-1 keys vals))
+ {} nil nil
+ {:a 1} [:a] [1])
+ (are [result keys vals] (= result (zipm-2 keys vals))
+ {} nil nil
+ {:a 1} [:a] [1])
+ (are [result keys vals] (= result (zipm-3 keys vals))
+ {} nil nil
+ {:a 1} [:a] [1])
+ (are [result keys vals] (= result (zipm-4 keys vals))
+ {} nil nil
+ {:a 1} [:a] [1])
+ (are [result keys vals] (= result (zipm-5 keys vals))
+ {} nil nil
+ {:a 1} [:a] [1]))
-(testing "min"
- (for-these [result vals]
- (should (= result
- (apply min-1 vals)
- (apply min-2 vals)
- (apply min-3 vals)
- (apply min vals)))
- 2 [6 2 4]
- 2 [6 3 2 4]
- 0 [0]))
+(deftest test-min
+ (are [result vals] (= result (apply min-1 vals))
+ 2 [6 2 4]
+ 2 [6 3 2 4]
+ 0 [0])
+ (are [result vals] (= result (apply min-2 vals))
+ 2 [6 2 4]
+ 2 [6 3 2 4]
+ 0 [0])
+ (are [result vals] (= result (apply min-3 vals))
+ 2 [6 2 4]
+ 2 [6 3 2 4]
+ 0 [0])
+ (are [result vals] (= result (apply min vals))
+ 2 [6 2 4]
+ 2 [6 3 2 4]
+ 0 [0]))
-(testing "minmax"
- (for-these [result vals]
- (should (= result
- (apply minmax-1 vals)
- (apply minmax-2 vals)))
- {:min 2 :max 7} [7 2 4]
- {:min 0 :max 0} [0]))
+(deftest test-minmax
+ (are [result vals] (= result (apply minmax-1 vals))
+ {:min 2 :max 7} [7 2 4]
+ {:min 0 :max 0} [0])
+ (are [result vals] (= result (apply minmax-2 vals))
+ {:min 2 :max 7} [7 2 4]
+ {:min 0 :max 0} [0]))
View
12 test/solutions/ref_cache_test.clj
@@ -1,10 +1,10 @@
(ns solutions.ref-cache-test
- (:use circumspec)
+ (:use clojure.test)
(:require [solutions.ref-cache :as cache]))
-(testing "ref version"
+(deftest test-ref-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} )))
- (should (= {:foo :zap 1 3} (cache/fast-put cache {1 3})))))
+ (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} )))
+ (is (= {:foo :zap 1 3} (cache/fast-put cache {1 3})))))

0 comments on commit 485629a

Please sign in to comment.
Something went wrong with that request. Please try again.