diff --git a/test/private/tokenizer.rkt b/test/private/tokenizer.rkt index 375f586a..28d6ea89 100644 --- a/test/private/tokenizer.rkt +++ b/test/private/tokenizer.rkt @@ -27,6 +27,8 @@ (define-lex-abbrev rest-of-line (concatenation (complement (concatenation any-string #\newline any-string)) #\newline)) +(define-lex-abbrev comment-line (concatenation "//" rest-of-line)) + (define-lex-abbrev dash-line (concatenation (repetition 3 +inf.0 #\-) #\newline)) (define-lex-abbrev equals-line (concatenation (repetition 3 +inf.0 #\=) #\newline)) (define-lex-abbrev pipe-dash-line (concatenation "|" dash-line)) @@ -83,6 +85,7 @@ (define initial-lexer (lexer-src-pos [whitespace (return-without-pos (initial-lexer input-port))] + [comment-line (return-without-pos (initial-lexer input-port))] [":" (token-COLON)] ["@" (token-AT-SIGN)] [".." (token-DOUBLE-DOT)] @@ -166,6 +169,18 @@ (position-token (token-CODE-LINE "#lang racket\n") (position 11 2 2) (position 24 3 0)))) (check-equal? (tokenize-until-eof tokenizer) expected-tokens)) + (test-case "comments between statements" + (define input (open-input-string "header:\n// a comment\n- #lang racket\n")) + (port-count-lines! input) + (define tokenizer (make-refactoring-test-tokenizer input)) + (define expected-tokens + (list + (position-token (token-IDENTIFIER 'header) (position 1 1 0) (position 7 1 6)) + (position-token (token-COLON) (position 7 1 6) (position 8 1 7)) + (position-token (token-SINGLE-DASH) (position 22 3 0) (position 24 3 2)) + (position-token (token-CODE-LINE "#lang racket\n") (position 24 3 2) (position 37 4 0)))) + (check-equal? (tokenize-until-eof tokenizer) expected-tokens)) + (test-case "code blocks" (define input (open-input-string "---\n#lang racket/base\n(void)\n---\n")) (port-count-lines! input) diff --git a/test/testing-lang-test.rkt b/test/testing-lang-test.rkt index ba588a1a..aa8098ef 100644 --- a/test/testing-lang-test.rkt +++ b/test/testing-lang-test.rkt @@ -4,6 +4,7 @@ header: - #lang resyntax/test +// Comments are allowed between statements (see issue #350). test: "unnecessary multi-line code blocks in tests refactorable to single-line code blocks" |------------------- | test: "foo"