Add support for negated predicates in assert and with-asserts.#1324
Open
NoahStoryM wants to merge 2 commits intoracket:masterfrom
Open
Add support for negated predicates in assert and with-asserts.#1324NoahStoryM wants to merge 2 commits intoracket:masterfrom
assert and with-asserts.#1324NoahStoryM wants to merge 2 commits intoracket:masterfrom
Conversation
There was a problem hiding this comment.
Resyntax analyzed 2 files in this pull request and has added suggestions.
Comment on lines
+734
to
+739
| (define pred-parser | ||
| (λ (stx) | ||
| (syntax-parse stx | ||
| #:datum-literals (not/p) | ||
| [(not/p (not/p p)) (pred-parser #'p)] | ||
| [_ stx]))) |
There was a problem hiding this comment.
define-lambda-to-define: The define form supports a shorthand for defining functions (including function-returning functions).
Suggested change
| (define pred-parser | |
| (λ (stx) | |
| (syntax-parse stx | |
| #:datum-literals (not/p) | |
| [(not/p (not/p p)) (pred-parser #'p)] | |
| [_ stx]))) | |
| (define (pred-parser stx) | |
| (syntax-parse stx | |
| #:datum-literals (not/p) | |
| [(not/p (not/p p)) (pred-parser #'p)] | |
| [_ stx])) |
Debugging details
Textual replacement
(line-replacement
#:new-lines
'#(" (define (pred-parser stx)"
" (syntax-parse stx"
" #:datum-literals (not/p)"
" [(not/p (not/p p)) (pred-parser #'p)]"
" [_ stx]))")
#:original-lines
'#(" (define pred-parser"
" (λ (stx)"
" (syntax-parse stx"
" #:datum-literals (not/p)"
" [(not/p (not/p p)) (pred-parser #'p)]"
" [_ stx])))")
#:start-line 734)Syntactic replacement
(syntax-replacement
#:introduction-scope #<procedure:do-make-syntax-introducer>
#:new-syntax
#<syntax:/home/runner/.local/share/racket/snapshot/pkgs/resyntax/default-recommendations/function-definition-shortcuts.rkt:87:3 (define (pred-parser (ORIGINAL-SPLICE stx)) (ORIGINAL-GAP (stx) (syntax-parse stx #:datum-literals (not/p) ((not/p (not/p p)) (pred-parser (syntax p))) (_ stx))) (ORIGINAL-SPLICE (syntax-parse stx #:datum-literals (not/p) ((not/p (not/p p)) (pred-parser...>
#:original-syntax
#<syntax:typed-racket-lib/typed-racket/base-env/prims.rkt:734:4 (define pred-parser (λ (stx) (syntax-parse stx #:datum-literals (not/p) ((not/p (not/p p)) (pred-parser (syntax p))) (_ stx))))>)
Comment on lines
+740
to
+745
| (define assert-parser | ||
| (λ (stx) | ||
| (syntax-parse stx | ||
| #:datum-literals (not/p) | ||
| [[x (not/p p)] #'(p x)] | ||
| [[x p] #'(not (p x))]))) |
There was a problem hiding this comment.
define-lambda-to-define: The define form supports a shorthand for defining functions (including function-returning functions).
Suggested change
| (define assert-parser | |
| (λ (stx) | |
| (syntax-parse stx | |
| #:datum-literals (not/p) | |
| [[x (not/p p)] #'(p x)] | |
| [[x p] #'(not (p x))]))) | |
| (define (assert-parser stx) | |
| (syntax-parse stx | |
| #:datum-literals (not/p) | |
| [[x (not/p p)] #'(p x)] | |
| [[x p] #'(not (p x))])) |
Debugging details
Textual replacement
(line-replacement
#:new-lines
'#(" (define (assert-parser stx)"
" (syntax-parse stx"
" #:datum-literals (not/p)"
" [[x (not/p p)] #'(p x)]"
" [[x p] #'(not (p x))]))")
#:original-lines
'#(" (define assert-parser"
" (λ (stx)"
" (syntax-parse stx"
" #:datum-literals (not/p)"
" [[x (not/p p)] #'(p x)]"
" [[x p] #'(not (p x))])))")
#:start-line 740)Syntactic replacement
(syntax-replacement
#:introduction-scope #<procedure:do-make-syntax-introducer>
#:new-syntax
#<syntax:/home/runner/.local/share/racket/snapshot/pkgs/resyntax/default-recommendations/function-definition-shortcuts.rkt:87:3 (define (assert-parser (ORIGINAL-SPLICE stx)) (ORIGINAL-GAP (stx) (syntax-parse stx #:datum-literals (not/p) ((x (not/p p)) (syntax (p x))) ((x p) (syntax (not (p x)))))) (ORIGINAL-SPLICE (syntax-parse stx #:datum-literals (not/p) ((x (not/p p)) (syntax...>
#:original-syntax
#<syntax:typed-racket-lib/typed-racket/base-env/prims.rkt:740:4 (define assert-parser (λ (stx) (syntax-parse stx #:datum-literals (not/p) ((x (not/p p)) (syntax (p x))) ((x p) (syntax (not (p x)))))))>)There was a problem hiding this comment.
Resyntax analyzed 2 files in this pull request and found no issues.
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.
This PR adds support for negated predicates in
assertandwith-assertsin Typed Racket. With this change, programmers can use(not/p pred)to assert that a value does not satisfy the given predicatepred.And before this change, if a value failed an assertion in
assertorwith-asserts, the error message did not show which assertion failed.Here are some examples:
Before:
After: