Skip to content

Commit 992d301

Browse files
begin overhaul
1 parent 88e40f3 commit 992d301

18 files changed

Lines changed: 636 additions & 464 deletions

File tree

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Test data generation and execution harness. Very early days.
55
This API will change. You have been warned.
66

77

8-
98
Releases and Dependency Information
109
========================================
1110

@@ -28,7 +27,6 @@ Latest stable release: 0.1.4
2827
</dependency>
2928

3029

31-
3230
Example Usages
3331
========================================
3432

@@ -40,18 +38,13 @@ and a validator:
4038
[^long a ^long b] ;; input spec
4139
(assert (integer? %))) ;; 0 or more validator forms
4240

43-
Given a var, namespace, or directory, you can run the tests for it:
44-
45-
(test-vars #'integers-closed-over-addition)
46-
(test-namespaces 'clojure.test.generative-test)
47-
(test-dirs \"src/test/clojure\")
48-
49-
Succesful test output includes :iterations, :msec, and the :var for
50-
each test run:
41+
To generate test data, see the fns in the generators namespace.
5142

52-
{:iterations 44645, :msec 1429,
53-
:var #'clojure.test.generative-test/numbers-closed-over-addition}
43+
To integrate with clojure.test:
5444

45+
;; somewhere in your test suite
46+
(:require '[clojure.test.generative.clojure-test :as clojure-test])
47+
(clojure-test/run-generative-tests)
5548

5649
Developer Information
5750
========================================
@@ -69,6 +62,13 @@ Developer Information
6962
Change Log
7063
====================
7164

65+
* Release 0.1.5 (in development)
66+
* Can now run tests under clojure.test
67+
* Tests produce data events that can be consumed by arbitrary reporting tools
68+
* Example reporting integration with logback.
69+
* Added `is` macro with more detailed reporting than `clojure.test/is`
70+
* Removed collection based input generators. Input generators must be fns.
71+
* Removed duplicate input check. Tests can be called multiple times with same input.
7272
* Release 0.1.4 on 2012.01.03
7373
* Initial version
7474

File renamed without changes.

bin/repl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
# Note: First you must run mvn dependency:build-classpath -Dmdep.outputFile=bin/maven-classpath
3+
CLASSPATH=src/main/clojure:src/test/clojure:src/examples/clojure:`cat bin/maven-classpath`
4+
5+
java -server -Xmx2GB -cp $CLASSPATH clojure.main "$@"
6+
7+

pom.xml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,21 @@
5151
</repositories>
5252

5353
<properties>
54-
<clojure.version>1.3.0</clojure.version>
54+
<clojure.version>1.4.0</clojure.version>
5555
</properties>
5656

5757
<dependencies>
58-
<dependency>
59-
<groupId>org.clojure</groupId>
60-
<artifactId>clojure</artifactId>
61-
<version>1.3.0-beta1</version>
62-
</dependency>
6358
<dependency>
6459
<groupId>org.clojure</groupId>
6560
<artifactId>tools.namespace</artifactId>
6661
<version>0.1.1</version>
6762
</dependency>
63+
<dependency>
64+
<groupId>ch.qos.logback</groupId>
65+
<artifactId>logback-classic</artifactId>
66+
<version>1.0.6</version>
67+
<scope>provided</scope>
68+
</dependency>
6869
</dependencies>
6970

7071
<build>
@@ -94,7 +95,8 @@
9495
<artifactId>clojure-maven-plugin</artifactId>
9596
<version>1.3.7</version>
9697
<configuration>
97-
<testScript>script/test_runner.clj</testScript>
98+
<vmargs>-Dclojure.test.generative.runner=clojure.test</vmargs>
99+
<!-- <testScript>bin/test_runner.clj</testScript> -->
98100
<copiedNamespaces>
99101
<namespace>!.*</namespace>
100102
</copiedNamespaces>

script/examples

Lines changed: 0 additions & 7 deletions
This file was deleted.

script/examples.clj

Lines changed: 0 additions & 14 deletions
This file was deleted.

script/repl

Lines changed: 0 additions & 13 deletions
This file was deleted.

script/test_runner.clj

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
; Copyright (c) Rich Hickey, Stuart Halloway, and contributors.
2+
; All rights reserved.
3+
; The use and distribution terms for this software are covered by the
4+
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
5+
; which can be found in the file epl-v10.html at the root of this distribution.
6+
; By using this software in any fashion, you are agreeing to be bound by
7+
; the terms of this license.
8+
; You must not remove this notice, or any other, from this software.
9+
10+
(ns clojure.test.array-test
11+
(:use clojure.test.generative)
12+
(:require [clojure.test.generative.generators :as gen]
13+
[clojure.test.generative.clojure-test :as clojure-test]))
14+
15+
(clojure-test/run-generative-tests)
16+
17+
(defn nan-or-=
18+
[a b]
19+
(or (= a b)
20+
(and (Double/isNaN a)
21+
(Double/isNaN b))))
22+
23+
(defmacro array-access-specs
24+
[pdescs]
25+
`(do
26+
~@(map
27+
(fn [[prim comp]]
28+
`(defspec ~(symbol (str prim "-array-access"))
29+
vec
30+
[~(with-meta 'arr {:tag (list (symbol (str prim "-array")) prim)})]
31+
(assert (= (alength ~'arr) (count ~'%)))
32+
(dotimes [~'i (count ~'arr)]
33+
(assert (~comp (aget ~'arr ~'i) (get ~'% ~'i))))))
34+
pdescs)))
35+
36+
(defmacro copy-array-fns
37+
[& types]
38+
`(do
39+
~@(map
40+
(fn [t]
41+
`(defn ~(symbol (str "copy-" t "-array"))
42+
[~'a]
43+
(let [~'copy ~(list (symbol (str t "-array")) 'a)]
44+
(dotimes [~'i (alength ~'a)]
45+
(aset ~'copy ~'i ~(with-meta `(aget ~'a ~'i)
46+
{:tag (symbol (str t "s"))})))
47+
~'copy)))
48+
types)))
49+
50+
(copy-array-fns boolean byte char short int long float double object)
51+
52+
(defmacro aset-specs
53+
[pdescs]
54+
`(do
55+
~@(map
56+
(fn [[prim comp]]
57+
`(defspec ~(symbol (str prim "-aset-spec"))
58+
copy-object-array
59+
[~(with-meta 'arr {:tag (list (symbol (str prim "-array")) prim)})]
60+
(assert (= (alength ~'arr) (alength ~'%)))
61+
(dotimes [~'i (count ~'arr)]
62+
(assert (~comp (aget ~'arr ~'i) (aget ~'% ~'i))))))
63+
pdescs)))
64+
65+
(array-access-specs {int =
66+
long =
67+
float nan-or-=
68+
double nan-or-=
69+
short =
70+
byte =
71+
char =
72+
boolean =})
73+
74+
(aset-specs {int =
75+
long =
76+
float nan-or-=
77+
double nan-or-=
78+
short =
79+
byte =
80+
char =
81+
boolean =})
82+
83+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
; Copyright (c) Rich Hickey, Stuart Halloway, and contributors.
2+
; All rights reserved.
3+
; The use and distribution terms for this software are covered by the
4+
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
5+
; which can be found in the file epl-v10.html at the root of this distribution.
6+
; By using this software in any fashion, you are agreeing to be bound by
7+
; the terms of this license.
8+
; You must not remove this notice, or any other, from this software.
9+
10+
(ns clojure.test.java-test
11+
(:use clojure.test.generative))
12+
13+
(set! *warn-on-reflection* true)
14+
15+
(defspec entry-set-keys-always-have-values
16+
#(java.util.concurrent.ConcurrentHashMap. ^java.util.Map %)
17+
[^{:tag (hash-map #(uniform 0 1e7) long #(uniform 1 20000))} m]
18+
(let [ks (keys m)]
19+
(dotimes [_ 5]
20+
(future
21+
(doseq [k (shuffle ks)]
22+
(.remove ^java.util.Map % k)
23+
(Thread/sleep 1)))))
24+
(loop [it (-> ^java.util.Map % (.entrySet) (.iterator))]
25+
(Thread/sleep 1)
26+
(when (.hasNext it)
27+
(let [[k v] (.next it)]
28+
(when (nil? v) (throw (RuntimeException. "Nil value for " k)))
29+
(recur it)))))

0 commit comments

Comments
 (0)