Comments (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.
An update: at present we support: PEP316, icontract, deal, an assert-based mode, and hypothesis. See these docs for details.
from crosshair.
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)
- Support atomic grouping and possessive quantifiers
- Support correct and compilable representation of enum values in the cover/pytest mode HOT 7
- Support pytest.raises Assertion / Exception match parameter when there is a message in exception HOT 1
- Produce the correct import statements for pytest output on cover command HOT 1
- CrossHair is missing symbolic support for `str.split` without arguments
- Support Python 3.12 HOT 1
- Implement true floating point semantics
- Unexpected checking results for functions with/without type annotations HOT 4
- Generic objects, when realized to strings, raise TypeError on concatenation.
- CrosshairInternal error raised when attempting to use symbolic integer as a function HOT 1
- Ensure all isinstance checks account for undecided types
- cover command error: (AttributeError("'AlgebraicNumRef' object has no attribute 'as_fraction'") HOT 2
- Unexpectedly long run times on a short example containing floats HOT 2
- Improve premature realization heuristics
- Heuristics for lengths of sequence-like symbolics
- Update Z3 version HOT 1
- Implement pluggable smtlib2 backends
- Can I use a seed to start exploration when using cover command? HOT 1
- Confusing findings for dictionary constructors HOT 5
- Add support for NewType HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crosshair.