(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/tokenize buffer))
- (and (token? result)
- (equal? 'number (token-type result))
- (equal? "12" (token-text result))))))
+ (token=? result
+ (token 'number "12" (posdata "(string)" 1 2))))))
(def-test "dlang/tokenize should recognize a character"
(call-with-input-string "'a'"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/tokenize buffer))
- (and (token? result)
- (equal? 'character (token-type result))
- (equal? "'a'" (token-text result))))))
+ (token=? result
+ (token 'character "'a'" (posdata "(string)" 1 2))))))
(def-test "dlang/tokenize should recognize a string"
(call-with-input-string "\"\""
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/tokenize buffer))
- (and (token? result)
- (equal? 'string (token-type result))
- (equal? "\"\"" (token-text result))))))
+ (token=? result
+ (token 'string "\"\"" (posdata "(string)" 1 2))))))
(def-test "dlang/tokenize should recognize a symbol"
(call-with-input-string "$foobar"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/tokenize buffer))
- (and (token? result)
- (equal? 'symbol (token-type result))
- (equal? "$foobar" (token-text result))))))
+ (token=? result
+ (token 'symbol "$foobar" (posdata "(string)" 1 2))))))
(def-test "dlang/tokenize should recognize an id"
(call-with-input-string "foobar"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/tokenize buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "foobar" (token-text result))))))
+ (token=? result
+ (token 'id "foobar" (posdata "(string)" 1 2))))))
(def-test "dlang/tokenize should recognize the EOF"
(call-with-input-string ""
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/tokenize buffer))
- (and (token? result)
- (equal? 'lpar (token-type result))
- (equal? "(" (token-text result))))))
+ (token=? result
+ (token 'lpar "(" (posdata "(string)" 1 1))))))
(def-test "dlang/tokenize should recognize a right parenthese"
(call-with-input-string ")"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/tokenize buffer))
- (and (token? result)
- (equal? 'rpar (token-type result))
- (equal? ")" (token-text result))))))
+ (token=? result
+ (token 'rpar ")" (posdata "(string)" 1 1))))))
(def-test "dlang/tokenize should recognize a comma"
(call-with-input-string ","
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/tokenize buffer))
- (and (token? result)
- (equal? 'comma (token-type result))
- (equal? "," (token-text result))))))
+ (token=? result
+ (token 'comma "," (posdata "(string)" 1 1))))))
(def-test "dlang/tokenize should recognize a semicolon"
(call-with-input-string ";"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/tokenize buffer))
- (and (token? result)
- (equal? 'term (token-type result))
- (equal? ";" (token-text result))))))
+ (token=? result
+ (token 'term ";" (posdata "(string)" 1 1))))))
(def-test "dlang/tokenize should recognize the end keyword"
(call-with-input-string "end"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/tokenize buffer))
- (and (token? result)
- (equal? 'term (token-type result))
- (equal? "end" (token-text result))))))
+ (token=? result
+ (token 'term "end" (posdata "(string)" 1 2))))))
; dlang/whitespace
;------------------------------------------------------------------------------
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/whitespace buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "foo" (token-text result))))))
+ (token=? result
+ (token 'id "foo" (posdata "(string)" 2 2)))
+ )))
; dlang/comment
;------------------------------------------------------------------------------
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/comment buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "bar" (token-text result))))))
+ (token=? result
+ (token 'id "bar" (posdata "(string)" 2 2)))
+ )))
; dlang/number
;------------------------------------------------------------------------------
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/number buffer))
- (and (token? result)
- (equal? 'number (token-type result))
- (equal? "1" (token-text result))))))
+ (token=? result
+ (token 'number "1" (posdata "(string)" 1 1))))))
(def-test "dlang/number should recognize a negative integer"
(call-with-input-string "-1"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/number buffer))
- (and (token? result)
- (equal? 'number (token-type result))
- (equal? "-1" (token-text result))))))
+ (token=? result
+ (token 'number "-1" (posdata "(string)" 1 1))))))
(def-test "dlang/number should recognize a positive float"
(call-with-input-string "1.1"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/number buffer))
- (and (token? result)
- (equal? 'number (token-type result))
- (equal? "1.1" (token-text result))))))
+ (token=? result
+ (token 'number "1.1" (posdata "(string)" 1 1))))))
(def-test "dlang/number should recognize a negative float"
(call-with-input-string "-1.1"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/number buffer))
- (and (token? result)
- (equal? 'number (token-type result))
- (equal? "-1.1" (token-text result))))))
+ (token=? result
+ (token 'number "-1.1" (posdata "(string)" 1 1))))))
(def-test "dlang/number should recognize a positive integer with positive exponent"
(call-with-input-string "1e1"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/number buffer))
- (and (token? result)
- (equal? 'number (token-type result))
- (equal? "1e1" (token-text result))))))
+ (token=? result
+ (token 'number "1e1" (posdata "(string)" 1 1))))))
(def-test "dlang/number should recognize a positive integer with negative exponent"
(call-with-input-string "1e-1"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/number buffer))
- (and (token? result)
- (equal? 'number (token-type result))
- (equal? "1e-1" (token-text result))))))
+ (token=? result
+ (token 'number "1e-1" (posdata "(string)" 1 1))))))
(def-test "dlang/number should recognize a positive float with positive exponent"
(call-with-input-string "1.1e1"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/number buffer))
- (and (token? result)
- (equal? 'number (token-type result))
- (equal? "1.1e1" (token-text result))))))
+ (token=? result
+ (token 'number "1.1e1" (posdata "(string)" 1 1))))))
(def-test "dlang/number should recognize a positive float with negative exponent"
(call-with-input-string "1.1e-1"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/number buffer))
- (and (token? result)
- (equal? 'number (token-type result))
- (equal? "1.1e-1" (token-text result))))))
+ (token=? result
+ (token 'number "1.1e-1" (posdata "(string)" 1 1))))))
(def-test "dlang/number should recognize a negative integer with positive exponent"
(call-with-input-string "-1e1"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/number buffer))
- (and (token? result)
- (equal? 'number (token-type result))
- (equal? "-1e1" (token-text result))))))
+ (token=? result
+ (token 'number "-1e1" (posdata "(string)" 1 1))))))
(def-test "dlang/number should recognize a negative integer with negative exponent"
(call-with-input-string "-1e-1"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/number buffer))
- (and (token? result)
- (equal? 'number (token-type result))
- (equal? "-1e-1" (token-text result))))))
+ (token=? result
+ (token 'number "-1e-1" (posdata "(string)" 1 1))))))
(def-test "dlang/number should recognize a negative float with positive exponent"
(call-with-input-string "-1.1e1"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/number buffer))
- (and (token? result)
- (equal? 'number (token-type result))
- (equal? "-1.1e1" (token-text result))))))
+ (token=? result
+ (token 'number "-1.1e1" (posdata "(string)" 1 1))))))
(def-test "dlang/number should recognize a negative float with negative exponent"
(call-with-input-string "-1.1e-1"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/number buffer))
- (and (token? result)
- (equal? 'number (token-type result))
- (equal? "-1.1e-1" (token-text result))))))
+ (token=? result
+ (token 'number "-1.1e-1" (posdata "(string)" 1 1))))))
; dlang/integer
;------------------------------------------------------------------------------
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/character buffer))
- (and (token? result)
- (equal? 'character (token-type result))
- (equal? "'a'" (token-text result))))))
+ (token=? result
+ (token 'character "'a'" (posdata "(string)" 1 1))))))
(def-test "dlang/character should error when missing first single quote"
(call-with-input-string "a'"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/string buffer))
- (and (token? result)
- (equal? 'string (token-type result))
- (equal? "\"\"" (token-text result))))))
+ (token=? result
+ (token 'string "\"\"" (posdata "(string)" 1 1))))))
(def-test "dlang/string should recognize a string of length 1"
(call-with-input-string "\"a\""
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/string buffer))
- (and (token? result)
- (equal? 'string (token-type result))
- (equal? "\"a\"" (token-text result))))))
+ (token=? result
+ (token 'string "\"a\"" (posdata "(string)" 1 1))))))
(def-test "dlang/string should recognize a string of length 2"
(call-with-input-string "\"ab\""
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/string buffer))
- (and (token? result)
- (equal? 'string (token-type result))
- (equal? "\"ab\"" (token-text result))))))
+ (token=? result
+ (token 'string "\"ab\"" (posdata "(string)" 1 1))))))
(def-test "dlang/string should recognize a string of length 3"
(call-with-input-string "\"abc\""
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/string buffer))
- (and (token? result)
- (equal? 'string (token-type result))
- (equal? "\"abc\"" (token-text result))))))
+ (token=? result
+ (token 'string "\"abc\"" (posdata "(string)" 1 1))))))
(def-test "dlang/string should error when missing first double quote"
(call-with-input-string "a\""
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/symbol buffer))
- (and (token? result)
- (equal? 'symbol (token-type result))
- (equal? "$a" (token-text result))))))
+ (token=? result
+ (token 'symbol "$a" (posdata "(string)" 1 1))))))
(def-test "dlang/symbol should recognize a symbol of length two"
(call-with-input-string "$ab"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/symbol buffer))
- (and (token? result)
- (equal? 'symbol (token-type result))
- (equal? "$ab" (token-text result))))))
+ (token=? result
+ (token 'symbol "$ab" (posdata "(string)" 1 1))))))
(def-test "dlang/symbol should recognize a symbol of length three"
(call-with-input-string "$abc"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/symbol buffer))
- (and (token? result)
- (equal? 'symbol (token-type result))
- (equal? "$abc" (token-text result))))))
+ (token=? result
+ (token 'symbol "$abc" (posdata "(string)" 1 1))))))
(def-test "dlang/symbol should stop recognition on EOF"
(call-with-input-string "$abc"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/symbol buffer))
- (and (token? result)
- (equal? 'symbol (token-type result))
- (equal? "$abc" (token-text result))))))
+ (token=? result
+ (token 'symbol "$abc" (posdata "(string)" 1 1))))))
(def-test "dlang/symbol should stop recognition on whitespace"
(call-with-input-string "$abc "
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/symbol buffer))
- (and (token? result)
- (equal? 'symbol (token-type result))
- (equal? "$abc" (token-text result))))))
+ (token=? result
+ (token 'symbol "$abc" (posdata "(string)" 1 1))))))
(def-test "dlang/symbol should error when no name given for a symbol"
(call-with-input-string "$"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/id buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "a" (token-text result))))))
+ (token=? result
+ (token 'id "a" (posdata "(string)" 1 1))))))
(def-test "dlang/id should recognize an id of length two"
(call-with-input-string "ab"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/id buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "ab" (token-text result))))))
+ (token=? result
+ (token 'id "ab" (posdata "(string)" 1 1))))))
(def-test "dlang/id should recognize an id of length three"
(call-with-input-string "abc"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/id buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "abc" (token-text result))))))
+ (token=? result
+ (token 'id "abc" (posdata "(string)" 1 1))))))
(def-test "dlang/id should stop recognition on whitespace"
(call-with-input-string "abc abc"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/id buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "abc" (token-text result))))))
+ (token=? result
+ (token 'id "abc" (posdata "(string)" 1 1))))))
(def-test "dlang/id should stop recognition on EOF"
(call-with-input-string "abc"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/id buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "abc" (token-text result))))))
+ (token=? result
+ (token 'id "abc" (posdata "(string)" 1 1))))))
(def-test "dlang/id should error when no id recognized"
(call-with-input-string ""
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/id buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "foo" (token-text result))))))
+ (token=? result
+ (token 'id "foo" (posdata "(string)" 1 1))))))
(def-test "dlang/id should stop recognition when left paren encountered"
(call-with-input-string "foo("
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/id buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "foo" (token-text result))))))
+ (token=? result
+ (token 'id "foo" (posdata "(string)" 1 1))))))
(def-test "dlang/id should stop recognition when right paren encountered"
(call-with-input-string "foo)"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/id buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "foo" (token-text result))))))
+ (token=? result
+ (token 'id "foo" (posdata "(string)" 1 1))))))
(def-test "dlang/id should stop recognition when semicolon encountered"
(call-with-input-string "foo;"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/id buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "foo" (token-text result))))))
+ (token=? result
+ (token 'id "foo" (posdata "(string)" 1 1))))))
(def-test "dlang/id should stop recognition when comma encountered"
(call-with-input-string "foo,"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/id buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "foo" (token-text result))))))
+ (token=? result
+ (token 'id "foo" (posdata "(string)" 1 1))))))
(def-test "dlang/id should stop recognition when single quote encountered"
(call-with-input-string "foo'"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/id buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "foo" (token-text result))))))
+ (token=? result
+ (token 'id "foo" (posdata "(string)" 1 1))))))
(def-test "dlang/id should stop recognition when double quote encountered"
(call-with-input-string "foo\""
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/id buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "foo" (token-text result))))))
+ (token=? result
+ (token 'id "foo" (posdata "(string)" 1 1))))))
(def-test "dlang/id should stop recognition when dollar sign encountered"
(call-with-input-string "foo$"
(lambda (input)
(define buffer (dlang/char-buf input))
(define result (dlang/id buffer))
- (and (token? result)
- (equal? 'id (token-type result))
- (equal? "foo" (token-text result))))))
+ (token=? result
+ (token 'id "foo" (posdata "(string)" 1 1))))))
; dlang/id-char?
;------------------------------------------------------------------------------