-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Pyret-style testing #85
Comments
One possibility: create a syntax parameter, say
The problem is, something will need to provide |
I just spoke with BenL (one of the major compiler writers) to clarify the semantics of nested tests in Pyret. A nested test is run every time the function is run (and apparently there is no way to turn those off). A top-level test is dealt with like something in module+-test. Library tests are thus ignored if code imports a library. What this means philosophically and technically is that these tests are contracts. In the past I have suggested to think of contracts as generalizations of predicate tests and of the latter as generalizations of unit tests. Of course when A generalizes B, A can express B (functionally at least, if not non-functional properties such as "only when module+ test is required"). I conjecture that we could compile nested tests into Racket contracts locally, possibly with a macro, with a good syntax design, and that should be done. ;; - - - It cannot work with test submodules for a number of reasons. The most important one is that the nested tests close over locally defined vars, including function parameters. So you would need some form of lambda lifting and protocol between tests and functions. So the "cannot" means, at a minimum, that this sounds way too expensive. Given the above analysis, I would say this should go into the contract package not the rackunit one. Finally this is the first time I see a reason to be able to run off contracts (partially). :-) ;; - - - |
In the Pyret language, tests may be included within the definition of a function using a
where
block:This runs the two
sum()
calls in thewhere
block as test cases. This even works for nested functions, with nested test cases run whenever the enclosing function's test cases result in a call to the enclosing function:example originally from this mailing list discussion
Here, the nested
result
function's test cases are run twice: once each whenmake-adder(3)
and
make-adder(4)
are called while testing the enclosingmake-adder
function. I'd like something like this for Racket, but there's a few things I'm unsure of:module+ test
avoids runtime dependencies on testing frameworks and I'd like a solution to this problem to preserve that feature.Discussion highly welcome, cc @mfelleisen
The text was updated successfully, but these errors were encountered: