Skip to content

Commit 4127d3c

Browse files
committed
add a without-option option
1 parent 8a2760a commit 4127d3c

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

syntax-color-doc/syntax-color/syntax-color.scrbl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,15 @@ Parenthesis matching code built on top of @racket[token-tree%].
4747
Checks to be sure a lexing function is well-behaved. For more
4848
details, see @xmethod[color:text<%> start-colorer].
4949

50+
It also supplies a few random arguments to the lexer and checks the results,
51+
using @racket[option/c]'s @racket[#:tester] argument.
52+
5053
@history[#:added "1.2"]}
5154

55+
@defthing[lexer*/c-without-random-testing contract?]{
56+
The same contract as @racket[lexer*/c], except without the random testing.
57+
}
58+
5259
@defstruct*[dont-stop ([val any/c])]{
5360
A structure type used to indicate to the lexer that it should not
5461
allow itself to be interrupted. For more details,

syntax-color-lib/syntax-color/lexer-contract.rkt

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
racket/contract/option)
44
(provide lexer/c
55
lexer*/c
6+
lexer*/c-without-random-testing
67
(struct-out dont-stop)
78
(contract-out
89
[check-colorer-results-match-port-before-and-after
@@ -33,24 +34,31 @@
3334
[new-mode any/c])))
3435
#:tester (λ (lexer) (try-some-random-streams lexer))))
3536

37+
(define lexer*/c-without-option
38+
(or/c (->i ([in (and/c input-port? port-counts-lines?)])
39+
(values [txt any/c]
40+
[type (or/c symbol? (hash/c symbol? any/c #:immutable #t))]
41+
[paren (or/c symbol? #f)]
42+
[start (or/c exact-positive-integer? #f)]
43+
[end (start type) (end/c start type)]))
44+
(->i ([in (and/c input-port? port-counts-lines?)]
45+
[offset exact-nonnegative-integer?]
46+
[mode (not/c dont-stop?)])
47+
(values [txt any/c]
48+
[type (or/c symbol? (hash/c symbol? any/c #:immutable #t))]
49+
[paren (or/c symbol? #f)]
50+
[start (or/c exact-positive-integer? #f)]
51+
[end (start type) (end/c start type)]
52+
[backup exact-nonnegative-integer?]
53+
[new-mode any/c]))))
54+
55+
(define lexer*/c-without-random-testing
56+
(option/c
57+
lexer*/c-without-option))
58+
3659
(define lexer*/c
3760
(option/c
38-
(or/c (->i ([in (and/c input-port? port-counts-lines?)])
39-
(values [txt any/c]
40-
[type (or/c symbol? (hash/c symbol? any/c #:immutable #t))]
41-
[paren (or/c symbol? #f)]
42-
[start (or/c exact-positive-integer? #f)]
43-
[end (start type) (end/c start type)]))
44-
(->i ([in (and/c input-port? port-counts-lines?)]
45-
[offset exact-nonnegative-integer?]
46-
[mode (not/c dont-stop?)])
47-
(values [txt any/c]
48-
[type (or/c symbol? (hash/c symbol? any/c #:immutable #t))]
49-
[paren (or/c symbol? #f)]
50-
[start (or/c exact-positive-integer? #f)]
51-
[end (start type) (end/c start type)]
52-
[backup exact-nonnegative-integer?]
53-
[new-mode any/c])))
61+
lexer*/c-without-option
5462
#:tester (λ (lexer) (try-some-random-streams lexer))))
5563

5664
(define (try-some-random-streams lexer)

0 commit comments

Comments
 (0)