Repository navigation
check-random-within - #95
Merged
Merged
Conversation
Contributor
|
@samth I never noticed this PR. There are no tests and no docs. If you add those, we can marge it in. |
samth
added a commit
to samth/htdp
that referenced
this pull request
Jun 29, 2026
check-random-within combines check-random and check-within: the test
and expected expressions are evaluated with the same freshly-seeded
pseudo-random generator (like check-random), and the two results are
then compared up to a tolerance (like check-within). This is the form
to use when a random computation produces inexact numbers, which
check-random refuses to compare.
- test-engine/racket-tests: add the check-random-within syntax and
do-check-random-within, and provide it.
- lang/htdp-{beginner,beginner-abbr,intermediate,intermediate-lambda,
advanced}: export check-random-within to the student languages.
- typed/test-engine/type-env-ext: give do-check-random-within a type.
- htdp-doc .../prim-ops: document the new form.
- htdp-test .../test-engine/racket-tests: test pass, failure, and the
non-number-tolerance error.
Supersedes the stale draft in racket#95, which predated the rewrite of
check-random into do-check-random. (Grammar BNF listing in
std-grammar.rkt + per-language .scrbl is a remaining follow-up.)
samth
force-pushed
the
random-within
branch
from
September 29, 2026 05:10
229c4dc to
7b9770b
Compare
Contributor
|
@samth Should we merge this? |
samth
marked this pull request as ready for review
September 29, 2026 13:59
Member
Author
|
If you think this is good, I think it's ready to be merged. |
Collaborator
|
Would it be better if there is a version bump & history notes? |
shhyou
approved these changes
Oct 1, 2026
| ;; with the same freshly-seeded pseudo-random generator; like check-within, | ||
| ;; the two results are compared up to the `within` tolerance. | ||
| (define (do-check-random-within test expected-thunk within src) | ||
| (error-check number? within CHECK-WITHIN-INEXACT-FMT #t) |
Collaborator
There was a problem hiding this comment.
The string CHECK-WITHIN-INEXACT-FMT says "check-within: ...". Probably need a new string here (or change the string to ~a and add a format).
| (let ((expected (parameterize ([current-pseudo-random-generator rng]) | ||
| (random-seed k) | ||
| (expected-thunk)))) | ||
| (error-check (lambda (v) (not (procedure? v))) expected CHECK-WITHIN-FUNCTION-FMT #t) |
Collaborator
There was a problem hiding this comment.
Ditto. CHECK-WITHIN-FUNCTION-FMT says "check-within cannot ...
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.