drdr found a 'test suite' that didnt actually have expected results, so I added in expected results and fixed a few bugs that it uncovered
svn: r16362 original commit: 2064861baa303b33fa49b92401d78fb2d363b9cctokens
parent
9de497d854
commit
772b804fbd
@ -1,35 +1,52 @@
|
|||||||
(define-lex-abbrev)
|
#lang scheme/base
|
||||||
(define-lex-abbrev a)
|
(require (for-syntax scheme/base)
|
||||||
(define-lex-abbrev (a b) v)
|
"../lex.ss"
|
||||||
(define-lex-abbrev 1 1)
|
schemeunit)
|
||||||
(define-lex-abbrevs ())
|
|
||||||
|
(define-syntax (catch-syn-error stx)
|
||||||
(define-lex-trans)
|
(syntax-case stx ()
|
||||||
(define-lex-trans (1 b) 1)
|
[(_ arg)
|
||||||
|
(datum->syntax
|
||||||
(lexer)
|
#'here
|
||||||
(lexer ("a" "b" "c"))
|
(with-handlers ((exn:fail:syntax? exn-message))
|
||||||
(lexer ())
|
(syntax-local-expand-expression #'arg)
|
||||||
(lexer (""))
|
"not-an-error"))]))
|
||||||
|
|
||||||
(lexer (a 1))
|
(check-regexp-match #rx"lex-abbrev" (catch-syn-error (define-lex-abbrev)))
|
||||||
(lexer ((a) 1))
|
(check-regexp-match #rx"lex-abbrev" (catch-syn-error (define-lex-abbrev a)))
|
||||||
(let ((a 1))
|
(check-regexp-match #rx"lex-abbrev" (catch-syn-error (define-lex-abbrev (a b) v)))
|
||||||
(lexer ((a) 1)))
|
(check-regexp-match #rx"lex-abbrev" (catch-syn-error (define-lex-abbrev 1 1)))
|
||||||
(let-syntax ((a 1))
|
(check-regexp-match #rx"lex-abbrevs" (catch-syn-error (define-lex-abbrevs ())))
|
||||||
(lexer ((a) 1)))
|
|
||||||
(let ()
|
(check-regexp-match #rx"lex-trans" (catch-syn-error (define-lex-trans)))
|
||||||
(define-lex-trans a 1)
|
|
||||||
(let ()
|
(check-regexp-match #rx"lexer" (catch-syn-error (lexer)))
|
||||||
(lexer ((a) 1))))
|
(check-regexp-match #rx"lexer" (catch-syn-error (lexer ("a" "b" "c"))))
|
||||||
|
(check-regexp-match #rx"lexer" (catch-syn-error (lexer ())))
|
||||||
(lexer (1 1))
|
(check-regexp-match #rx"lexer" (catch-syn-error (lexer (""))))
|
||||||
(lexer ((repetition) 1))
|
|
||||||
(lexer ((repetition #\1 #\1 "3") 1))
|
(check-regexp-match #rx"regular-expression" (catch-syn-error (lexer (a 1))))
|
||||||
(lexer ((repetition 1 #\1 "3") 1))
|
(check-regexp-match #rx"regular-expression" (catch-syn-error (lexer ((a) 1))))
|
||||||
(lexer ((repetition 1 0 "3") 1))
|
(check-regexp-match #rx"regular-expression" (catch-syn-error (let ((a 1)) (lexer ((a) 1)))))
|
||||||
(lexer ((complement) 1))
|
|
||||||
(lexer ((char-range) 1))
|
(check-regexp-match #rx"regular-expression"
|
||||||
(lexer ((char-range #\9 #\0) 1))
|
(catch-syn-error (let-syntax ((a 1))
|
||||||
(lexer ((char-complement) 1))
|
(lexer ((a) 1)))))
|
||||||
(lexer ((char-complement (concatenation "1" "2")) 1))
|
|
||||||
|
(check-regexp-match #rx"define-lex-trans"
|
||||||
|
(catch-syn-error
|
||||||
|
(let ()
|
||||||
|
(define-lex-trans a 1)
|
||||||
|
(let ()
|
||||||
|
(lexer ((a) 1))))))
|
||||||
|
|
||||||
|
(check-regexp-match #rx"regular-expression" (catch-syn-error (lexer (1 1))))
|
||||||
|
(check-regexp-match #rx"repetition" (catch-syn-error (lexer ((repetition) 1))))
|
||||||
|
(check-regexp-match #rx"repetition" (catch-syn-error (lexer ((repetition #\1 #\1 "3") 1))))
|
||||||
|
(check-regexp-match #rx"repetition" (catch-syn-error (lexer ((repetition 1 #\1 "3") 1))))
|
||||||
|
(check-regexp-match #rx"repetition" (catch-syn-error (lexer ((repetition 1 0 "3") 1))))
|
||||||
|
(check-regexp-match #rx"complement" (catch-syn-error (lexer ((complement) 1))))
|
||||||
|
(check-regexp-match #rx"char-range" (catch-syn-error (lexer ((char-range) 1))))
|
||||||
|
(check-regexp-match #rx"char-range" (catch-syn-error (lexer ((char-range #\9 #\0) 1))))
|
||||||
|
(check-regexp-match #rx"char-complement" (catch-syn-error (lexer ((char-complement) 1))))
|
||||||
|
(check-regexp-match #rx"char-complement" (catch-syn-error (lexer ((char-complement (concatenation "1" "2")) 1))))
|
||||||
|
Loading…
Reference in New Issue