jqwik-team / jqwik

Property-Based Testing on the JUnit Platform
http://jqwik.net
Eclipse Public License 2.0
578 stars 64 forks source link

Regress from 1.5.5 to 1.5.6 and still present in 1.7.1: Cannot inject List<Consumer<T>> #446

Closed kepakiano closed 1 year ago

kepakiano commented 1 year ago

I'd like to inject a List<Consumer<Integer>> into a test like so:

    @Property
    void foo(@ForAll @Size(min = 1) List<Consumer<Integer>> integerConsumers){

    }

This worked in 1.5.5, broke in 1.5.6 and is still broken in 1.7.1.

StackTrace I'm getting:

java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "constant" is null
    at net.jqwik.engine.properties.arbitraries.randomized.AbstractFunctionGenerator.lambda$constantFunction$0(AbstractFunctionGenerator.java:46)
    at jdk.proxy1/jdk.proxy1.$Proxy11.hashCode(Unknown Source)
    at java.base/java.util.HashMap.hash(HashMap.java:338)
    at java.base/java.util.HashMap.put(HashMap.java:610)

I'm using a Java 17 runtime.

If making injecting a List<Consumer<Integer>> impossible was a deliberate decision for 1.5.6, please feel free to ignore this issue :)

Thank you for this amazing library!

jlink commented 1 year ago

@kepakiano Thanks for the catch. Does look like a bug at first glance. Will check.

jlink commented 1 year ago

Fix released in 1.7.2-SNAPSHOT

jlink commented 1 year ago

1.7.2 has been released

kepakiano commented 1 year ago

Thank you! We were able to upgrade to the latest version with this fix :)