Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make checking's options optional #58

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

DjebbZ
Copy link

@DjebbZ DjebbZ commented Apr 4, 2018

Details in issue #57.

@DjebbZ
Copy link
Author

DjebbZ commented Apr 4, 2018

Sorry not finished, I should update all documentation.

@DjebbZ
Copy link
Author

DjebbZ commented Apr 4, 2018

Documentation updated, but the options-test is failing in node.js with (of course) some useless error message from JS :

Testing com.gfredericks.test.chuck.clojure-test-test

ERROR in (options-test) (TypeError:NaN:NaN)
Uncaught exception, not in assertion.
expected: nil
  actual: #object[TypeError TypeError: Cannot read property 'call' of undefined]

I verified, the error doesn't happen in the master branch. It seems I broke something with options processing...

@DjebbZ
Copy link
Author

DjebbZ commented Apr 4, 2018

Can't find the problem with CLJS tests. And my knowledge of leiningen is very limited so I didn't find an easy way to launch a CLJS REPL to further investigate the problem. Hopefully I'm close to the solution. Now I gotta go back to work. If you're willing to have a look you're welcome.

Copy link
Owner

@gfredericks gfredericks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good start; thanks for working on it!

[name & check-decl]
(let [[num-tests-or-options bindings body] (cond
(and (or number? (first check-decl)
map? (first check-decl))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're missing parens around these calls, so this part will always be truthy; that could be your bug

(-report r#))))))
:arglists '([name bindings body] [name num-tests-or-options bindings body])}
[name & check-decl]
(let [[num-tests-or-options bindings body] (cond
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a line break before (cond so that this clause isn't so far off to the right

@@ -106,27 +105,44 @@
(ct/report reports))

(defmacro checking
"A macro intended to replace the testing macro in clojure.test with a
^{:doc "A macro intended to replace the testing macro in clojure.test with a
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this metadata will be effective unless you delete the ^ character on this line

;; empty map is OK, defaults to 100 tests
(checking "strings are strings" {} [s gen/string-ascii]
(is (string? s)))
(is (string? s)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try not to change existing indentation; I'd also prefer the checking call farther up to be indented 2 spaces as well

[nil (first check-decl) (next check-decl)]

:else (throw #?(:clj (IllegalArgumentException. "Arguments to `checking` must be either [name bindings body] or [name num-tests-or-options bindings body]")
:cljs (js/Error. "Arguments to `checking` must be either [name bindings body] or [name num-tests-or-options bindings body]"))))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can avoid the duplication here by pushing the #? down to just the IllegalArgumentException. and js/Error.

(swap! nb-runs inc)
(is (> 0)))
(swap! nb-runs inc)
(is (> 0)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't really core to the test, but I assume you meant (> i 0) or (pos? i) here?

@DjebbZ
Copy link
Author

DjebbZ commented Apr 5, 2018

  1. I fixed the node tests, I was missing testing in the :cljs conditional require.
  2. I also incorporated your second review.
  3. I've even tried to test that checking throws when called with a bad option, code doesn't even compile with java.lang.IllegalArgumentException: Arguments to checking must be either [name bindings & body] or [name num-tests-or-options bindings & body] -- with lein test only, lein doo node node-test works fine. The failing test is left in the code for you to review. I suspect something wrong with the reader conditional in the test but I've re-read the code so many times I don't understand what's wrong.
  4. lein doo node node-test is a bit unstable... I sometimes get different results whether run the command from scratch or when it re-runs after a code change. It seems reliable only when ran from scratch.

@gfredericks
Copy link
Owner

your exception is thrown at macroexpansion-time (which makes sense to me), so the fact that it "doesn't even compile" seems like the correct behavior, and I would question why it does anything different in other environments.


You can optionally pass in a map options instead of the number of tests,
You can optionally pass in a number of a map options,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"a number or a map of options"

you could perhaps also add "similar to defspec"

@gfredericks
Copy link
Owner

oh I didn't notice that you were trying to have an automated test that checks the compile-time error.

I think the only reasonable way to test this is by calling eval, and I don't think you can do that in cljs. I would just add a reader conditional for :clj and use eval there.

@DjebbZ
Copy link
Author

DjebbZ commented Apr 6, 2018

I fixed the docstring but I don't understand what you mean by calling eval... What ? Where ? When ? Why ? Haha

@gfredericks
Copy link
Owner

Something like (is (thrown? SomeException (eval '(checking ...))))

@DjebbZ
Copy link
Author

DjebbZ commented Apr 6, 2018

eval works with syntax-quote, not simple quote because it doesn't know checking symbol I think. With syntax-quote symbols are fully qualified so it worked.

PS: don't know how to display syntax-quote inside markdown code markers since they're back-quotes too !

@gfredericks
Copy link
Owner

You can do syntax-quote in markdown by using the multiline version: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code

e.g., `this`

Copy link
Owner

@gfredericks gfredericks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the slow response.

(prop/for-all ~bindings
(let [reports# (capture-reports ~@body)]
(swap! ~final-reports save-to-final-reports reports#)
(pass? reports#)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please maintain the 2-space indentation for for-all expressions

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

(let [reports# (capture-reports ~@body)]
(swap! ~final-reports save-to-final-reports reports#)
(pass? reports#)))
(apply concat (options ~num-tests-or-options)))))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason there was a let clause at the top in the old code is that it lets you use num-tests-or-options in two places without inserting the code twice. This is general good-practice when writing a macro because otherwise if users have a nontrivial expression, it will be evaluated twice.

E.g., compare the expansions of (doubler (inc 20)) with these two definitions:

(defmacro doubler
  [x]
  `(+ ~x ~x))

(defmacro doubler
  [x]
  `(let [x# ~x] (+ x# x#)))

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I look closer, have you actually changed anything in this code, other than inlining num-tests-or-options? If not, then you should be able to just revert to the original code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never thought of the double evaluation. Thanks for the tip.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code reverted by the way


:else (throw (#?(:clj IllegalArgumentException.
:cljs js/Error.) "Arguments to `checking` must be either [name bindings & body] or [name num-tests-or-options bindings & body]")))
num-tests-or-options (tc.clojure-test/process-options num-tests-or-options)]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the fact that you're calling process-options with the form at macroexpansion-time means that users can't have a non-literal expression; e.g., I think (checking "something" (assoc some-defaults :num-tests 40) ...) would fail (you could add a test for this).

Now that I think about that distinction, I believe your check for number? and map? farther up are not sufficient, since it could also be a symbol or sequence. I think the cleanest thing would just be to only check (vector? (second check-decl)) there.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, but... (read the comment below)

@DjebbZ
Copy link
Author

DjebbZ commented Apr 16, 2018

Ok, I had some trouble just with the commit "macro problems". My understanding was that since I moved the process-options call into the form returned from the macro so that it's used at run time, the test checking for bad option was expanding [i gen/int] into [com.gfredericks.test.chuck.clojure-test-test/i gen/int], which caused this error when running lein test : Caused by: java.lang.RuntimeException: Can't use qualified name as parameter: com.gfredericks.test.chuck.clojure-test-test/i.

The "quote binding" commit is an attempt to circumvent the problem but I'm not sure it's a good idea.

By the way at this point all tests (lein test and lein doo node node-test) pass.

@gfredericks
Copy link
Owner

The standard way of solving the problem you're describing is using i# for the local, in both places.

I'm shocked that the "quote binding" commit actually works. There must be something very strange going on.

@DjebbZ
Copy link
Author

DjebbZ commented Apr 26, 2018

I've just tried several things to be able to use i# :

(eval `(checking "numbers are numbers" "opts as string" [i# gen/int]
                          (is (int? i#))))
(eval `(checking "numbers are numbers" "opts as string" [i# gen/int]
                          (is ('int? i#))))
(eval `(checking "numbers are numbers" "opts as string" [i# gen/int]
                          (is (~'int? i#))))

Nothing works. I think I'm lost in macro-hell... haha

@gfredericks
Copy link
Owner

The first one should work. How does it fail?

@DjebbZ
Copy link
Author

DjebbZ commented Apr 26, 2018

Sorry I should have been more precise, apologies if you took it bad. Below the complete stacktrace from lein test. I think problem is that it thinks int? is from the test ns, not clojure.core.

ERROR in (options-test) (Compiler.java:6543)
bad option throws
expected: (thrown? IllegalArgumentException (eval (clojure.core/seq (clojure.core/concat (clojure.core/list (quote com.gfredericks.test.chuck.clojure-test/checking)) (clojure.core/list "numbers are numbers") (clojure.core/list "opts as string") (clojure.core/list (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list (quote i__3503__auto__)) (clojure.core/list (quote clojure.test.check.generators/int)))))) (clojure.core/list (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.test/is)) (clojure.core/list (clojure.core/seq (clojure.core/concat (clojure.core/list (quote com.gfredericks.test.chuck.clojure-test-test/int?)) (clojure.core/list (quote i__3503__auto__))))))))))))
  actual: clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: No such var: com.gfredericks.test.chuck.clojure-test-test/int?, compiling:(/tmp/form-init7863264923787511067.clj:1:6367)
 at clojure.lang.Compiler.analyze (Compiler.java:6543)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3737)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6725)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.access$300 (Compiler.java:38)
    clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6129)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6723)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$TryExpr$Parser.parse (Compiler.java:2261)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6723)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$FnMethod.parse (Compiler.java:5296)
    clojure.lang.Compiler$FnExpr.parse (Compiler.java:3925)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6721)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3791)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6725)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6179)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6723)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.access$300 (Compiler.java:38)
    clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6129)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6723)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6179)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6723)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$FnMethod.parse (Compiler.java:5296)
    clojure.lang.Compiler$FnExpr.parse (Compiler.java:3925)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6721)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3791)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6725)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3791)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6725)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6179)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6723)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3791)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6725)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6179)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6723)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$FnMethod.parse (Compiler.java:5296)
    clojure.lang.Compiler$FnExpr.parse (Compiler.java:3925)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6721)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3791)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6725)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$FnMethod.parse (Compiler.java:5296)
    clojure.lang.Compiler$FnExpr.parse (Compiler.java:3925)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6721)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.eval (Compiler.java:6779)
    clojure.lang.Compiler.eval (Compiler.java:6745)
    clojure.core$eval.invoke (core.clj:3081)
    com.gfredericks.test.chuck.clojure_test_test/fn (clojure_test_test.cljc:41)
    clojure.test$test_var$fn__7670.invoke (test.clj:704)
    clojure.test$test_var.invoke (test.clj:704)
    clojure.test$test_vars$fn__7692$fn__7697.invoke (test.clj:722)
    clojure.test$default_fixture.invoke (test.clj:674)
    clojure.test$test_vars$fn__7692.invoke (test.clj:722)
    clojure.test$default_fixture.invoke (test.clj:674)
    clojure.test$test_vars.invoke (test.clj:718)
    clojure.test$test_all_vars.invoke (test.clj:728)
    clojure.test$test_ns.invoke (test.clj:747)
    user$eval85$fn__136.invoke (form-init7863264923787511067.clj:1)
    clojure.lang.AFn.applyToHelper (AFn.java:156)
    clojure.lang.AFn.applyTo (AFn.java:144)
    clojure.core$apply.invoke (core.clj:632)
    leiningen.core.injected$compose_hooks$fn__19.doInvoke (form-init7863264923787511067.clj:1)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invoke (core.clj:630)
    leiningen.core.injected$run_hooks.invoke (form-init7863264923787511067.clj:1)
    leiningen.core.injected$prepare_for_hooks$fn__24$fn__25.doInvoke (form-init7863264923787511067.clj:1)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
    clojure.lang.RestFn.invoke (RestFn.java:408)
    clojure.core$map$fn__4553.invoke (core.clj:2624)
    clojure.lang.LazySeq.sval (LazySeq.java:40)
    clojure.lang.LazySeq.seq (LazySeq.java:49)
    clojure.lang.Cons.next (Cons.java:39)
    clojure.lang.RT.boundedLength (RT.java:1735)
    clojure.lang.RestFn.applyTo (RestFn.java:130)
    clojure.core$apply.invoke (core.clj:632)
    clojure.test$run_tests.doInvoke (test.clj:762)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invoke (core.clj:630)
    user$eval85$fn__148$fn__179.invoke (form-init7863264923787511067.clj:1)
    user$eval85$fn__148$fn__149.invoke (form-init7863264923787511067.clj:1)
    user$eval85$fn__148.invoke (form-init7863264923787511067.clj:1)
    user$eval85.invoke (form-init7863264923787511067.clj:1)
    clojure.lang.Compiler.eval (Compiler.java:6782)
    clojure.lang.Compiler.eval (Compiler.java:6772)
    clojure.lang.Compiler.load (Compiler.java:7227)
    clojure.lang.Compiler.loadFile (Compiler.java:7165)
    clojure.main$load_script.invoke (main.clj:275)
    clojure.main$init_opt.invoke (main.clj:280)
    clojure.main$initialize.invoke (main.clj:308)
    clojure.main$null_opt.invoke (main.clj:343)
    clojure.main$main.doInvoke (main.clj:421)
    clojure.lang.RestFn.invoke (RestFn.java:421)
    clojure.lang.Var.invoke (Var.java:383)
    clojure.lang.AFn.applyToHelper (AFn.java:156)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.main.main (main.java:37)
Caused by: java.lang.RuntimeException: No such var: com.gfredericks.test.chuck.clojure-test-test/int?
 at clojure.lang.Util.runtimeException (Util.java:221)
    clojure.lang.Compiler.resolveIn (Compiler.java:6993)
    clojure.lang.Compiler.resolve (Compiler.java:6963)
    clojure.lang.Compiler.analyzeSymbol (Compiler.java:6924)
    clojure.lang.Compiler.analyze (Compiler.java:6506)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3737)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6725)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.access$300 (Compiler.java:38)
    clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6129)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6723)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$TryExpr$Parser.parse (Compiler.java:2261)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6723)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$FnMethod.parse (Compiler.java:5296)
    clojure.lang.Compiler$FnExpr.parse (Compiler.java:3925)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6721)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3791)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6725)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6179)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6723)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.access$300 (Compiler.java:38)
    clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6129)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6723)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6179)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6723)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$FnMethod.parse (Compiler.java:5296)
    clojure.lang.Compiler$FnExpr.parse (Compiler.java:3925)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6721)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3791)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6725)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3791)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6725)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6179)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6723)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3791)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6725)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6179)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6723)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$FnMethod.parse (Compiler.java:5296)
    clojure.lang.Compiler$FnExpr.parse (Compiler.java:3925)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6721)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6711)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3791)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6725)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.analyze (Compiler.java:6485)
    clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:5861)
    clojure.lang.Compiler$FnMethod.parse (Compiler.java:5296)
    clojure.lang.Compiler$FnExpr.parse (Compiler.java:3925)
    clojure.lang.Compiler.analyzeSeq (Compiler.java:6721)
    clojure.lang.Compiler.analyze (Compiler.java:6524)
    clojure.lang.Compiler.eval (Compiler.java:6779)
    clojure.lang.Compiler.eval (Compiler.java:6745)
    clojure.core$eval.invoke (core.clj:3081)
    com.gfredericks.test.chuck.clojure_test_test/fn (clojure_test_test.cljc:41)
    clojure.test$test_var$fn__7670.invoke (test.clj:704)
    clojure.test$test_var.invoke (test.clj:704)
    clojure.test$test_vars$fn__7692$fn__7697.invoke (test.clj:722)
    clojure.test$default_fixture.invoke (test.clj:674)
    clojure.test$test_vars$fn__7692.invoke (test.clj:722)
    clojure.test$default_fixture.invoke (test.clj:674)
    clojure.test$test_vars.invoke (test.clj:718)
    clojure.test$test_all_vars.invoke (test.clj:728)
    clojure.test$test_ns.invoke (test.clj:747)
    user$eval85$fn__136.invoke (form-init7863264923787511067.clj:1)
    clojure.lang.AFn.applyToHelper (AFn.java:156)
    clojure.lang.AFn.applyTo (AFn.java:144)
    clojure.core$apply.invoke (core.clj:632)
    leiningen.core.injected$compose_hooks$fn__19.doInvoke (form-init7863264923787511067.clj:1)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invoke (core.clj:630)
    leiningen.core.injected$run_hooks.invoke (form-init7863264923787511067.clj:1)
    leiningen.core.injected$prepare_for_hooks$fn__24$fn__25.doInvoke (form-init7863264923787511067.clj:1)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
    clojure.lang.RestFn.invoke (RestFn.java:408)
    clojure.core$map$fn__4553.invoke (core.clj:2624)
    clojure.lang.LazySeq.sval (LazySeq.java:40)
    clojure.lang.LazySeq.seq (LazySeq.java:49)
    clojure.lang.Cons.next (Cons.java:39)
    clojure.lang.RT.boundedLength (RT.java:1735)
    clojure.lang.RestFn.applyTo (RestFn.java:130)
    clojure.core$apply.invoke (core.clj:632)
    clojure.test$run_tests.doInvoke (test.clj:762)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invoke (core.clj:630)
    user$eval85$fn__148$fn__179.invoke (form-init7863264923787511067.clj:1)
    user$eval85$fn__148$fn__149.invoke (form-init7863264923787511067.clj:1)
    user$eval85$fn__148.invoke (form-init7863264923787511067.clj:1)
    user$eval85.invoke (form-init7863264923787511067.clj:1)
    clojure.lang.Compiler.eval (Compiler.java:6782)
    clojure.lang.Compiler.eval (Compiler.java:6772)
    clojure.lang.Compiler.load (Compiler.java:7227)
    clojure.lang.Compiler.loadFile (Compiler.java:7165)
    clojure.main$load_script.invoke (main.clj:275)
    clojure.main$init_opt.invoke (main.clj:280)
    clojure.main$initialize.invoke (main.clj:308)
    clojure.main$null_opt.invoke (main.clj:343)
    clojure.main$main.doInvoke (main.clj:421)
    clojure.lang.RestFn.invoke (RestFn.java:421)
    clojure.lang.Var.invoke (Var.java:383)
    clojure.lang.AFn.applyToHelper (AFn.java:156)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.main.main (main.java:37)

@gfredericks
Copy link
Owner

I think that can happen if int? doesn't exist for some reason.

It looks like int? was added in 1.9, so maybe that's not the best function to be using in these tests

@gfredericks
Copy link
Owner

integer? has been in clojure.core since 1.0

@DjebbZ
Copy link
Author

DjebbZ commented May 16, 2018

Good catch, I changed to integer?. But the tests kept failing with actual: clojure.lang.ExceptionInfo: Invalid defspec options: "opts as string". So I "cheated" and caught any Exception instead, even if the macro throws IllegalArgumentException normally. I've just checked clojure.test, it doesn't re-throw an error of another type. So even if all tests pass now (clj and cljs), I'm not sure it really works...

@gfredericks
Copy link
Owner

The reason it's not throwing the exception you wanted is that your (vector? (second check-decl)) test is passing, and the exception is coming from the call to tc.clojure-test/process-options. So you either need to test a different form, or enhance your validation so that it catches that kind of problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants