Giter Club home page Giter Club logo

Comments (3)

Zac-HD avatar Zac-HD commented on May 29, 2024 3

You know what would be amazing? Symbolically executing tests written for Hypothesis! For example:

@given(st.integers(min_value=0))
def test(x):
    assert x ** 2 >= x

# could be equivalent to

def test(x: int):
    """pre: x >= 0"""
    assert x ** 2 >= x

this is particularly interesting to me because (a) I'm a core dev of Hypothesis 😜, (b) Hypothesis tests have to precisely describe the domain of valid inputs, and (c) they have a high density of assertions about error-prone behaviour!

I don't have time to write this myself (at least in the next few months), but would be delighted to help anyone who wants to have a go.

from crosshair.

pschanely avatar pschanely commented on May 29, 2024 1

An update: at present we support: PEP316, icontract, deal, an assert-based mode, and hypothesis. See these docs for details.

from crosshair.

pschanely avatar pschanely commented on May 29, 2024

Love this idea.

And it might not be all that difficult to do; the stuff we'd need to change is relatively well encapsulated in get_fn_conditions and get_class_conditions in condition_parser.py. There are some details to consider, however, like whether it's ok for exceptions can be thrown and what kind of copy happens for previous/old value comparisons. I think class invariants also have some subtle behaviors that might vary between contract implementations.

If someone wanted to make this happen for their favorite syntax, I would be completely happy to shepherd it along.

Otherwise, internet, please post or thumbs-up your favorite tools: with enough votes, I could probably prioritize some of my own time to try and get an implementation out.

from crosshair.

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.