Git Product home page Git Product logo

Comments (5)

Rewbert avatar Rewbert commented on May 26, 2024

There's no shrinking of expressions going on at all right now. I focused on shrinking statements, as that makes a program 'more' small ;) But expressions should be shrunk, absolutely. It's not something I will prioritize until after the paper deadline, I think. There are some other small things that I need to fix with the expression shrinker as well. Some programs are shrunk a lot, but could still be shrunk even more.

Just as a quick intro to something that confused me a bit now when I learned this myself recently:

QuickCheck shrinking is not of the form that e.g it turns 5 + 7 into the subexpression 12, but rather it turns 5 + 7 into the subexpressions 5 & 7. You could pattern match on this specific case of integer constants arithmetic, of course, and produce the subexpressions 5, 7 & 12, but it won't be the general case that expressions are normalized. It's a syntactical division of the tree into its immediate subtrees.

If you have (5 + 7) * (7 - 2) you turn that into the subexpressions 5 + 7 & 7 - 2. You don't recursively shrink them further yourself, as QuickCheck automatically does that for you if it needs to. Nothing will go wrong if you do it yourself, but it might slow down shrinking as you might test more mutations than you have to.

from scoria.

j-hui avatar j-hui commented on May 26, 2024

I suppose chopping expressions into bits and pieces works too, but is there no way to essentially pipe the example programs through a constant-folder sort of pass?

from scoria.

Rewbert avatar Rewbert commented on May 26, 2024

You could, yes. The shrink interface as seen by QuickCheck is the function shrink :: a -> [a], which in our case is shrink :: Program -> [Program]. The result could be the singleton list containing the folded program. What you are describing is not necessarily the way shrinking is usually done though. It's supposed to be a

E.g an expression such as 5 + 7 would presumable have been evaluated while being subjected to a test, so shrinking and then testing 12 would test the semantically equivalent program, even if it is syntactically smaller. If you perform this constant folding and the new program also fails, you can not shrink it further as it is now a single leaf node rather than a tree. Maybe the bug only appears if the number is odd? The arbitrary & shrink functions are supposed to be quite 'simple' in their operation.

from scoria.

j-hui avatar j-hui commented on May 26, 2024

from scoria.

j-hui avatar j-hui commented on May 26, 2024

Fixed by #39

from scoria.

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.