test.check

Calling defspecs as functions throws an NPE

Details

  • Type: Defect Defect
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

The following behavior was introduced in commit 3641146.

lein run -m clojure.main -e '(do (require (quote [clojure.test.check.test :as t])) (t/constant-generators))'
;; throws:
Reflection warning, /tmp/form-init17491131931397818849.clj:1:1038 - call to static method invokeStaticMethod on clojure.lang.Reflector can't be resolved (argument types: unknown, java.lang.String, unknown).
Exception in thread "main" java.lang.NullPointerException, compiling:(/tmp/form-init17491131931397818849.clj:1:74)
	at clojure.lang.Compiler.load(Compiler.java:7391)
	at clojure.lang.Compiler.loadFile(Compiler.java:7317)
	at clojure.main$load_script.invokeStatic(main.clj:275)
	at clojure.main$init_opt.invokeStatic(main.clj:277)
	at clojure.main$init_opt.invoke(main.clj:277)
	at clojure.main$initialize.invokeStatic(main.clj:308)
	at clojure.main$null_opt.invokeStatic(main.clj:342)
	at clojure.main$null_opt.invoke(main.clj:339)
	at clojure.main$main.invokeStatic(main.clj:421)
	at clojure.main$main.doInvoke(main.clj:384)
	at clojure.lang.RestFn.invoke(RestFn.java:421)
	at clojure.lang.Var.invoke(Var.java:383)
	at clojure.lang.AFn.applyToHelper(AFn.java:156)
	at clojure.lang.Var.applyTo(Var.java:700)
	at clojure.main.main(main.java:37)
Caused by: java.lang.NullPointerException
	at clojure.core$name.invokeStatic(core.clj:1546)
	at clojure.core$name.invoke(core.clj:1540)
	at clojure.test.check.clojure_test$default_reporter_fn.invokeStatic(clojure_test.cljc:35)
	at clojure.test.check.clojure_test$default_reporter_fn.invoke(clojure_test.cljc:28)
	at clojure.test.check$complete.invokeStatic(check.cljc:29)
	at clojure.test.check$complete.invoke(check.cljc:27)
	at clojure.test.check$quick_check.invokeStatic(check.cljc:91)
	at clojure.test.check$quick_check.doInvoke(check.cljc:37)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:650)
	at clojure.core$apply.invoke(core.clj:641)
	at clojure.test.check.test$constant_generators.invokeStatic(test.cljc:256)
	at clojure.test.check.test$constant_generators.doInvoke(test.cljc:256)
	at clojure.lang.RestFn.applyTo(RestFn.java:139)
	at clojure.core$apply.invokeStatic(core.clj:648)
	at clojure.core$apply.invoke(core.clj:641)
	at clojure.test.check.test$constant_generators.invokeStatic(test.cljc:256)
	at clojure.test.check.test$constant_generators.invoke(test.cljc:256)
	at user$eval2085.invokeStatic(form-init17491131931397818849.clj:1)
	at user$eval2085.invoke(form-init17491131931397818849.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:6927)
	at clojure.lang.Compiler.eval(Compiler.java:6917)
	at clojure.lang.Compiler.eval(Compiler.java:6890)
	at clojure.core$eval.invokeStatic(core.clj:3105)
	at clojure.main$eval_opt.invokeStatic(main.clj:288)
	at clojure.main$eval_opt.invoke(main.clj:282)
	at clojure.main$initialize.invokeStatic(main.clj:308)
	at clojure.main$null_opt.invokeStatic(main.clj:342)
	at clojure.main$null_opt.invoke(main.clj:339)
	at clojure.main$main.invokeStatic(main.clj:421)
	at clojure.main$main.doInvoke(main.clj:384)
	at clojure.lang.RestFn.invoke(RestFn.java:421)
	at clojure.lang.Var.invoke(Var.java:383)
	at clojure.lang.AFn.applyToHelper(AFn.java:156)
	at clojure.lang.Var.applyTo(Var.java:700)
	at clojure.main.main(main.java:37)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
	at clojure.lang.Reflector.invokeStaticMethod(Reflector.java:207)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
	at clojure.lang.Reflector.invokeStaticMethod(Reflector.java:207)
	at user$eval7.invokeStatic(form-init17491131931397818849.clj:1)
	at user$eval7.invoke(form-init17491131931397818849.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:6927)
	at clojure.lang.Compiler.eval(Compiler.java:6917)
	at clojure.lang.Compiler.load(Compiler.java:7379)
	... 14 more

Activity

Hide
Michael Glaesemann added a comment -

Remove testing prn.

Show
Michael Glaesemann added a comment - Remove testing prn.
Hide
Gary Fredericks added a comment -

I just tried the code snippet from the description on commit 3641146^ again (the one just before the bug was introduced) and noticed that it doesn't actually print anything, which is interesting.

The stack trace in the other versions must mean that this code is being run, but somehow not resulting in anything. I suppose clojure.test somehow disables test output when you're not in a normal test run.

I feel like that's not my daily experience, but I dunno. I'm not going to dig into it.

The v2 patch is on master; thanks!

Show
Gary Fredericks added a comment - I just tried the code snippet from the description on commit 3641146^ again (the one just before the bug was introduced) and noticed that it doesn't actually print anything, which is interesting. The stack trace in the other versions must mean that this code is being run, but somehow not resulting in anything. I suppose clojure.test somehow disables test output when you're not in a normal test run. I feel like that's not my daily experience, but I dunno. I'm not going to dig into it. The v2 patch is on master; thanks!
Hide
Gary Fredericks added a comment -

Oh I see it does print now that this has been applied. I'm apparently pretty confused and definitely not going to dig into it any further this time.

Show
Gary Fredericks added a comment - Oh I see it does print now that this has been applied. I'm apparently pretty confused and definitely not going to dig into it any further this time.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: