-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - feat(testing): property based testing (basics) #3915
Conversation
A number of my comments on #2080 still apply here. I'm also not a fan of the name |
What would you rename it to? Maybe |
Yes, |
src/testing/slim_check/testable.lean
Outdated
test_result q := | ||
@add_to_counter_example (var ++ " := " ++ to_string x) _ _ h | ||
|
||
/-- gadget used to introspect the name of bound variables -/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain this more? I'm not seeing quickly what this gadget is doing.
that the goal should be satisfied with a proposition equivalent to `p` | ||
with added annotations. -/ | ||
@[reducible, nolint unused_arguments] | ||
def decorations_of (p : Prop) := Prop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still trying to sort out exactly what's going on with these decorations, but this seems odd to have in the tactic
namespace. (Note that you're still in slim_check
too. If you wanted mk_decorations
in _root_.tactic
, it isn't there right now.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, the instance testable (named_binder (some "x") (∀ x, p x))
generates samples for x
and, when the test fails, adds x := 37
to the error message that will be printed to the user. testable
is pure code and does not have access to the syntax tree (esp. the name of bound variables) of ∀ x, p x
so we use a gadget to make the name "x" available.
Co-authored-by: Rob Lewis <Rob.y.lewis@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
I think this looks great now! There's documentation on the tactic that starts from the beginning, and later documentation that explains how to use the advanced features. Shall we merge? |
I agree, the new bors r+ |
I agree, thanks Simon! |
Add `gen` monad, `sampleable` and `testable` type classes
Build failed: |
Ah, this needs to be updated for 3.19.0. |
bors merge |
👎 Rejected by label |
bors merge |
Add `gen` monad, `sampleable` and `testable` type classes
Pull request successfully merged into master. Build succeeded: |
Thank you all! Next step: smart generators for functions and testing for monadic programs (separate PRs) |
Add `gen` monad, `sampleable` and `testable` type classes
Add
gen
monad,sampleable
andtestable
type classesTaken from #2080