From: Mike D. Lowis Date: Fri, 27 Jul 2012 20:00:56 +0000 (-0400) Subject: add tests for token-matches? X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=98e588f14fc363c6c9674a37a556c864dc65548c;p=archive%2Fdlang-scm.git add tests for token-matches? --- diff --git a/tests/test_parse_utils.scm b/tests/test_parse_utils.scm index b654899..7b1229f 100644 --- a/tests/test_parse_utils.scm +++ b/tests/test_parse_utils.scm @@ -128,6 +128,23 @@ ; token-matches? ;------------------------------------------------------------------------------ +(def-test "token-matches? should return true if next token matches type" + (call-with-input-string "abc" + (lambda (input) + (define buffer (dlang/lexer input)) + (token-matches? buffer 'id)))) + +(def-test "token-matches? should return false if next token does not match type" + (call-with-input-string "ab" + (lambda (input) + (define buffer (dlang/lexer input)) + (not (token-matches? buffer 'foo))))) + +(def-test "token-matches? should return false if EOF" + (call-with-input-string "" + (lambda (input) + (define buffer (dlang/lexer input)) + (not (token-matches? buffer 'foo))))) ; keyword-match ;------------------------------------------------------------------------------