Giter Club home page Giter Club logo

Comments (10)

rkraneis avatar rkraneis commented on July 20, 2024

Using @ForAll BigRange(min="0",max="0") WithNull(0.5) BigDecimal bd seems equivalent to nullOrZero3 and cannot be done exhaustively.

from jqwik.

rkraneis avatar rkraneis commented on July 20, 2024

Minimal test for failing combination:

public class NullOrZeroTest {
  
  Object ZERO = new Object();

  @Property @Report(Reporting.GENERATED)
  boolean nullOrZero2(@ForAll("nullOrZero2") Object bd1, @ForAll("nullOrZero2") Object bd2) {
    return bd1 == null || bd1 == ZERO || bd2 == null || bd2 == ZERO;
  }

  @Provide Arbitrary<Object> nullOrZero2() {
    return Arbitraries.of(ZERO, null);
  }
}

from jqwik.

jlink avatar jlink commented on July 20, 2024

I'm just starting to try understanding what you want to do so bear with me...

Your last example NullOrZeroTest succeeds when I try it:

timestamp = 2019-12-13T10:46:34.003, generated = [java.lang.Object@1e9e725a, java.lang.Object@1e9e725a]

timestamp = 2019-12-13T10:46:34.006, generated = [java.lang.Object@1e9e725a, null]

timestamp = 2019-12-13T10:46:34.006, generated = [null, java.lang.Object@1e9e725a]

timestamp = 2019-12-13T10:46:34.016, NullOrZeroTest:nullOrZero2 = 
                              |-------------------jqwik-------------------
tries = 3                     | # of calls to property
checks = 3                    | # of not rejected calls
generation-mode = EXHAUSTIVE  | parameters are exhaustively generated
after-failure = PREVIOUS_SEED | use the previous seed
seed = -5796249568264761713   | random seed to reproduce generated values

This is almost what I'd expect. I'm just wondering why [null, null] does not show up as 4th example and I will look into this. Is that your point?

When I switch on randomized generation with @Property(generation = GenerationMode.RANDOMIZED) it does show up, though.

from jqwik.

jlink avatar jlink commented on July 20, 2024
@Provide Arbitrary<BigDecimal> nullOrZero3() {
    return Arbitraries.bigDecimals().between(BigDecimal.ZERO, BigDecimal.ZERO)
        .withSamples((BigDecimal) null);
  }

should also be able to be used in an exhaustive generation context. I'll have a look at that as well.

from jqwik.

rkraneis avatar rkraneis commented on July 20, 2024

Ah yes, sorry, that might have been too much information with too little explanation ;-)
Given Arbitraries.of(null, ZERO)

  • it creates null as the only value when used in exhaustive mode for a single parameter

Given Arbitraries.of(ZERO, null)

  • it creates ZERO and null as values when used in exhaustive mode for a single parameter
  • it creates all permutations but [null, null] when used in exhaustive mode for two parameters

Randomized generation is fine in all cases, but must be selected manually.

from jqwik.

jlink avatar jlink commented on July 20, 2024

Understood. I'm going to examine that.

from jqwik.

jlink avatar jlink commented on July 20, 2024

Bug concerning handling of null values in exhaustive generation has been fixed. Already available in version 1.2.2-SNAPSHOT. See 24ff64c

Exhaustive generation of Arbitraries.bigDecimals().between(BigDecimal.ZERO, BigDecimal.ZERO) is a different beast, which I will tackle next.

from jqwik.

rkraneis avatar rkraneis commented on July 20, 2024

Thank you for the quick response!

from jqwik.

jlink avatar jlink commented on July 20, 2024

The exhaustive generation of single big decimal range is now also possible (1e4cc24) and available in 1.2.2-SNAPSHOT

All of your examples above should now hopefully work as expected.

Thanks for catching two glitches in a single go!

from jqwik.

rkraneis avatar rkraneis commented on July 20, 2024

Great, thank you!

from jqwik.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.