jqwik: Domains inject parameterized values incorrectly
Testing Problem
The setup like this:
@Domain(MyDomain.class)
@Domain(DomainContext.Global.class)
class TestTest {
@Property
boolean test(@ForAll Predicate<Number> p1, @ForAll Predicate<Number> p2, @ForAll Number n) {
return p1.or(p2).test(n) == (p1.test(n) || p2.test(n));
}
}
class MyThing implements Predicate<CharSequence> {
public boolean test(CharSequence cs) { return true; }
}
class MyDomain extends DomainContextBase {
@Provide
Arbitrary<MyThing> myThingArbitrary() {
return Arbitraries.just(new MyThing());
}
}
will produce:
java.lang.ClassCastException:
class java.lang.Long cannot be cast to class java.lang.CharSequence (java.lang.Long and java.lang.CharSequence are in module java.base of loader 'bootstrap')
but if you remove domain and provide MyThing
right in test class - no problem.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 25 (7 by maintainers)
pull request to solve most/all of the variance and assignment issues
Also available as 1.8.0-SNAPSHOT
Since a change to the behaviour of
canBeAssignedTo(..)
is relevant for a lot of hooks and domain implementations, I’ll move the current version to 1.8.0-SNAPSHOT.Provided a fix and released it as “1.7.5-SNAPSHOT”.
@SimY4 Maybe you can try if your use case now works.
@SimY4 , please read “1.” in https://github.com/jqwik-team/jqwik/issues/499#issuecomment-1625947469
It seems you missed it
IMO (and the opinion of the compiler) the assertions are wrong:
should be