Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use test.generative's runner, add a few generative tests

Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information...
commit 7f69246f17a559119fbad8747100bb7586ff6e92 1 parent a61a703
Stuart Halloway stuarthalloway authored
Showing with 79 additions and 64 deletions.
  1. +2 −63 src/script/run_tests.clj
  2. +77 −1 test/clojure/test_clojure/numbers.clj
65 src/script/run_tests.clj
View
@@ -1,63 +1,2 @@
-(ns clojure.test-clojure (:require clojure.test))
-
-(def test-namespaces '[
-clojure.test-clojure.agents
-clojure.test-clojure.annotations
-clojure.test-clojure.atoms
-clojure.test-clojure.clojure-set
-clojure.test-clojure.clojure-walk
-clojure.test-clojure.clojure-xml
-clojure.test-clojure.clojure-zip
-clojure.test-clojure.compilation
-clojure.test-clojure.control
-clojure.test-clojure.data
-clojure.test-clojure.data-structures
-clojure.test-clojure.def
-clojure.test-clojure.errors
-clojure.test-clojure.evaluation
-clojure.test-clojure.fn
-clojure.test-clojure.for
-clojure.test-clojure.genclass.examples
-clojure.test-clojure.genclass
-clojure.test-clojure.java.io
-clojure.test-clojure.java.javadoc
-clojure.test-clojure.java.shell
-clojure.test-clojure.java-interop
-clojure.test-clojure.keywords
-clojure.test-clojure.load
-clojure.test-clojure.logic
-clojure.test-clojure.macros
-clojure.test-clojure.main
-clojure.test-clojure.metadata
-clojure.test-clojure.multimethods
-clojure.test-clojure.ns-libs
-clojure.test-clojure.numbers
-clojure.test-clojure.other-functions
-clojure.test-clojure.parallel
-clojure.test-clojure.pprint
-clojure.test-clojure.predicates
-clojure.test-clojure.printer
-clojure.test-clojure.protocols
-clojure.test-clojure.protocols.hash-collisions
-clojure.test-clojure.reader
-clojure.test-clojure.reducers
-clojure.test-clojure.reflect
-clojure.test-clojure.refs
-clojure.test-clojure.repl
-clojure.test-clojure.rt
-clojure.test-clojure.sequences
-clojure.test-clojure.serialization
-clojure.test-clojure.special
-clojure.test-clojure.string
-clojure.test-clojure.test
-clojure.test-clojure.test-fixtures
-clojure.test-clojure.transients
-clojure.test-clojure.try-catch
-clojure.test-clojure.vars
-clojure.test-clojure.vectors
-])
-
-(apply require test-namespaces)
-
-(let [results (apply clojure.test/run-tests test-namespaces)]
- (System/exit (+ (:error results) (:fail results))))
+(require '[clojure.test.generative.runner :as runner])

where is this runner.clj ? seems to be not in repo? or something
because:
Buildfile: S:\workspace2013\clojure\build.xml
compile-tests:
[java] Compiling clojure.test-clojure.protocols.examples to S:\workspace2013\clojure\target\test-classes
[java] Compiling clojure.test-clojure.genclass.examples to S:\workspace2013\clojure\target\test-classes
[java] Compiling clojure.test-clojure.annotations to S:\workspace2013\clojure\target\test-classes
test:
[java] Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/test/generative/runner__init.class
or clojure/test/generative/runner.clj on classpath:
[java] at clojure.lang.RT.load(RT.java:443)
[java] at clojure.lang.RT.load(RT.java:411)
[java] at clojure.core$load$fn__5043.invoke(core.clj:5530)
[java] at clojure.core$load.doInvoke(core.clj:5529)
[java] at clojure.lang.RestFn.invoke(RestFn.java:408)
[java] at clojure.core$load_one.invoke(core.clj:5336)
[java] at clojure.core$load_lib$fn__4992.invoke(core.clj:5375)
[java] at clojure.core$load_lib.doInvoke(core.clj:5374)
[java] at clojure.lang.RestFn.applyTo(RestFn.java:142)
[java] at clojure.core$apply.invoke(core.clj:619)
[java] at clojure.core$load_libs.doInvoke(core.clj:5413)
[java] at clojure.lang.RestFn.applyTo(RestFn.java:137)
[java] at clojure.core$apply.invoke(core.clj:619)
[java] at clojure.core$require.doInvoke(core.clj:5496)
[java] at clojure.lang.RestFn.invoke(RestFn.java:408)
[java] at user$eval3.invoke(run_tests.clj:2)
[java] at clojure.lang.Compiler.eval(Compiler.java:6619)
[java] at clojure.lang.Compiler.load(Compiler.java:7064)
[java] at clojure.lang.Compiler.loadFile(Compiler.java:7020)
[java] at clojure.main$load_script.invoke(main.clj:288)
[java] at clojure.main$script_opt.invoke(main.clj:350)
[java] at clojure.main$main$fn__6686.invoke(main.clj:434)
[java] at clojure.main$main.doInvoke(main.clj:431)
[java] at clojure.lang.RestFn.invoke(RestFn.java:408)
[java] at clojure.lang.Var.invoke(Var.java:415)
[java] at clojure.lang.AFn.applyToHelper(AFn.java:161)
[java] at clojure.lang.Var.applyTo(Var.java:532)
[java] at clojure.main.main(main.java:37)

BUILD FAILED
S:\workspace2013\clojure\build.xml:104: Java returned: 1

Total time: 6 seconds

Nicola Mometto
Bronsa added a note

https://github.com/clojure/test.generative/blob/master/src/main/clojure/clojure/test/generative/runner.clj

I may be wrong but it looks to me like you're using ant.
You should use maven to compile clojure.

that's true ant, I'll try maven, thank you sir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+(runner/-main "test")
78 test/clojure/test_clojure/numbers.clj
View
@@ -13,7 +13,9 @@
(ns clojure.test-clojure.numbers
(:use clojure.test
- clojure.template))
+ [clojure.test.generative :exclude (is)]
+ clojure.template)
+ (:require [clojure.test.generative.generators :as gen]))
; TODO:
@@ -563,3 +565,77 @@ Math/pow overflows to Infinity."
min
max))))
+(defn integer
+ "Distribution of integers biased towards the small, but
+ including all longs."
+ []
+ (gen/one-of #(gen/uniform -1 32) gen/byte gen/short gen/int gen/long))
+
+(defn longable?
+ [n]
+ (try
+ (long n)
+ true
+ (catch Exception _)))
+
+(defspec integer-commutative-laws
+ (partial map identity)
+ [^{:tag `integer} a ^{:tag `integer} b]
+ (if (longable? (+' a b))
+ (assert (= (+ a b) (+ b a)
+ (+' a b) (+' b a)
+ (unchecked-add a b) (unchecked-add b a)))
+ (assert (= (+' a b) (+' b a))))
+ (if (longable? (*' a b))
+ (assert (= (* a b) (* b a)
+ (*' a b) (*' b a)
+ (unchecked-multiply a b) (unchecked-multiply b a)))
+ (assert (= (*' a b) (*' b a)))))
+
+(defspec integer-associative-laws
+ (partial map identity)
+ [^{:tag `integer} a ^{:tag `integer} b ^{:tag `integer} c]
+ (if (every? longable? [(+' a b) (+' b c) (+' a b c)])
+ (assert (= (+ (+ a b) c) (+ a (+ b c))
+ (+' (+' a b) c) (+' a (+' b c))
+ (unchecked-add (unchecked-add a b) c) (unchecked-add a (unchecked-add b c))))
+ (assert (= (+' (+' a b) c) (+' a (+' b c))
+ (+ (+ (bigint a) b) c) (+ a (+ (bigint b) c)))))
+ (if (every? longable? [(*' a b) (*' b c) (*' a b c)])
+ (assert (= (* (* a b) c) (* a (* b c))
+ (*' (*' a b) c) (*' a (*' b c))
+ (unchecked-multiply (unchecked-multiply a b) c) (unchecked-multiply a (unchecked-multiply b c))))
+ (assert (= (*' (*' a b) c) (*' a (*' b c))
+ (* (* (bigint a) b) c) (* a (* (bigint b) c))))))
+
+(defspec integer-distributive-laws
+ (partial map identity)
+ [^{:tag `integer} a ^{:tag `integer} b ^{:tag `integer} c]
+ (if (every? longable? [(*' a (+' b c)) (+' (*' a b) (*' a c))
+ (*' a b) (*' a c) (+' b c)])
+ (assert (= (* a (+ b c)) (+ (* a b) (* a c))
+ (*' a (+' b c)) (+' (*' a b) (*' a c))
+ (unchecked-multiply a (+' b c)) (+' (unchecked-multiply a b) (unchecked-multiply a c))))
+ (assert (= (*' a (+' b c)) (+' (*' a b) (*' a c))
+ (* a (+ (bigint b) c)) (+ (* (bigint a) b) (* (bigint a) c))))))
+
+(defspec addition-undoes-subtraction
+ (partial map identity)
+ [^{:tag `integer} a ^{:tag `integer} b]
+ (if (longable? (-' a b))
+ (assert (= a
+ (-> a (- b) (+ b))
+ (-> a (unchecked-subtract b) (unchecked-add b)))))
+ (assert (= a
+ (-> a (-' b) (+' b)))))
+
+(defspec quotient-and-remainder
+ (fn [a b] (sort [a b]))
+ [^{:tag `integer} a ^{:tag `integer} b]
+ (when-not (zero? (second %))
+ (let [[a d] %
+ q (quot a d)
+ r (rem a d)]
+ (assert (= a
+ (+ (* q d) r)
+ (unchecked-add (unchecked-multiply q d) r))))))
faqindeletethisalready

where is this runner.clj ? seems to be not in repo? or something
because:
Buildfile: S:\workspace2013\clojure\build.xml
compile-tests:
[java] Compiling clojure.test-clojure.protocols.examples to S:\workspace2013\clojure\target\test-classes
[java] Compiling clojure.test-clojure.genclass.examples to S:\workspace2013\clojure\target\test-classes
[java] Compiling clojure.test-clojure.annotations to S:\workspace2013\clojure\target\test-classes
test:
[java] Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/test/generative/runner__init.class
or clojure/test/generative/runner.clj on classpath:
[java] at clojure.lang.RT.load(RT.java:443)
[java] at clojure.lang.RT.load(RT.java:411)
[java] at clojure.core$load$fn__5043.invoke(core.clj:5530)
[java] at clojure.core$load.doInvoke(core.clj:5529)
[java] at clojure.lang.RestFn.invoke(RestFn.java:408)
[java] at clojure.core$load_one.invoke(core.clj:5336)
[java] at clojure.core$load_lib$fn__4992.invoke(core.clj:5375)
[java] at clojure.core$load_lib.doInvoke(core.clj:5374)
[java] at clojure.lang.RestFn.applyTo(RestFn.java:142)
[java] at clojure.core$apply.invoke(core.clj:619)
[java] at clojure.core$load_libs.doInvoke(core.clj:5413)
[java] at clojure.lang.RestFn.applyTo(RestFn.java:137)
[java] at clojure.core$apply.invoke(core.clj:619)
[java] at clojure.core$require.doInvoke(core.clj:5496)
[java] at clojure.lang.RestFn.invoke(RestFn.java:408)
[java] at user$eval3.invoke(run_tests.clj:2)
[java] at clojure.lang.Compiler.eval(Compiler.java:6619)
[java] at clojure.lang.Compiler.load(Compiler.java:7064)
[java] at clojure.lang.Compiler.loadFile(Compiler.java:7020)
[java] at clojure.main$load_script.invoke(main.clj:288)
[java] at clojure.main$script_opt.invoke(main.clj:350)
[java] at clojure.main$main$fn__6686.invoke(main.clj:434)
[java] at clojure.main$main.doInvoke(main.clj:431)
[java] at clojure.lang.RestFn.invoke(RestFn.java:408)
[java] at clojure.lang.Var.invoke(Var.java:415)
[java] at clojure.lang.AFn.applyToHelper(AFn.java:161)
[java] at clojure.lang.Var.applyTo(Var.java:532)
[java] at clojure.main.main(main.java:37)

BUILD FAILED
S:\workspace2013\clojure\build.xml:104: Java returned: 1

Total time: 6 seconds

Nicola Mometto

https://github.com/clojure/test.generative/blob/master/src/main/clojure/clojure/test/generative/runner.clj

I may be wrong but it looks to me like you're using ant.
You should use maven to compile clojure.

faqindeletethisalready

that's true ant, I'll try maven, thank you sir

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