syntax-color/lexer-contract: make random-test failure declare itself
Random tests that are implciitly injected into a program should declare themselves as such when they fail. Otherwise, random crashes are really confusing.
This commit is contained in:
parent
66729a4473
commit
a1bac35b60
|
@ -33,6 +33,21 @@
|
||||||
(define-values (txt type paren start end) (lexer in))
|
(define-values (txt type paren start end) (lexer in))
|
||||||
(values txt type paren start end 0 #f))]
|
(values txt type paren start end 0 #f))]
|
||||||
[else lexer]))
|
[else lexer]))
|
||||||
|
(define initial-state (pseudo-random-generator->vector
|
||||||
|
(current-pseudo-random-generator)))
|
||||||
|
(with-handlers ([exn:fail?
|
||||||
|
(lambda (exn)
|
||||||
|
(raise
|
||||||
|
(make-exn
|
||||||
|
(format (string-append "try-some-random-streams:"
|
||||||
|
" random testing of lexer failed\n"
|
||||||
|
" lexer: ~e\n"
|
||||||
|
" pseudo-random state: ~s\n"
|
||||||
|
" error message: ~s")
|
||||||
|
lexer
|
||||||
|
initial-state
|
||||||
|
(exn-message exn))
|
||||||
|
(exn-continuation-marks exn))))])
|
||||||
(for ([x (in-range 10)])
|
(for ([x (in-range 10)])
|
||||||
(define size (random 100))
|
(define size (random 100))
|
||||||
(define (quash-backslash-r c)
|
(define (quash-backslash-r c)
|
||||||
|
@ -58,7 +73,7 @@
|
||||||
(cond
|
(cond
|
||||||
[(equal? type 'eof) #t]
|
[(equal? type 'eof) #t]
|
||||||
[(< end size) (loop new-mode end)]
|
[(< end size) (loop new-mode end)]
|
||||||
[else #f]))))
|
[else #f])))))
|
||||||
|
|
||||||
(define (end/c start type)
|
(define (end/c start type)
|
||||||
(cond
|
(cond
|
||||||
|
|
Loading…
Reference in New Issue
Block a user