diff options
author | Tim Hatch <tim@timhatch.com> | 2014-04-24 11:38:52 -0400 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2014-04-24 11:38:52 -0400 |
commit | 4330942e358d466ec6516e4114865ec6ca641c48 (patch) | |
tree | 522d4de78d70f6acf59f1118c1512fd5649b1aa6 /tests | |
parent | d1e781ec268ad6d1b3af570412245af4e8608770 (diff) | |
download | pygments-4330942e358d466ec6516e4114865ec6ca641c48.tar.gz |
Let qbasic lexer match functions like 'RIGHT$', with test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/examplefiles/qbasic_example | 2 | ||||
-rw-r--r-- | tests/test_qbasiclexer.py | 43 |
2 files changed, 44 insertions, 1 deletions
diff --git a/tests/examplefiles/qbasic_example b/tests/examplefiles/qbasic_example index a5055175..27041af6 100644 --- a/tests/examplefiles/qbasic_example +++ b/tests/examplefiles/qbasic_example @@ -1,2 +1,2 @@ -10 print "hi" +10 print RIGHT$("hi there", 5) 20 goto 10 diff --git a/tests/test_qbasiclexer.py b/tests/test_qbasiclexer.py new file mode 100644 index 00000000..1b81b643 --- /dev/null +++ b/tests/test_qbasiclexer.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +""" + Tests for QBasic + ~~~~~~~~~~~~~~~~ + + :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import glob +import os +import unittest + +from pygments.token import Token +from pygments.lexers.qbasic import QBasicLexer + +class QBasicTest(unittest.TestCase): + def setUp(self): + self.lexer = QBasicLexer() + self.maxDiff = None + + def testKeywordsWithDollar(self): + fragment = u'DIM x\nx = RIGHT$("abc", 1)\n' + expected = [ + (Token.Keyword.Declaration, u'DIM'), + (Token.Text.Whitespace, u' '), + (Token.Name.Variable.Global, u'x'), + (Token.Text, u'\n'), + (Token.Name.Variable.Global, u'x'), + (Token.Text.Whitespace, u' '), + (Token.Operator, u'='), + (Token.Text.Whitespace, u' '), + (Token.Keyword.Reserved, u'RIGHT$'), + (Token.Punctuation, u'('), + (Token.Literal.String.Double, u'"abc"'), + (Token.Punctuation, u','), + (Token.Text.Whitespace, u' '), + (Token.Literal.Number.Integer.Long, u'1'), + (Token.Punctuation, u')'), + (Token.Text, u'\n'), + ] + self.assertEqual(expected, list(self.lexer.get_tokens(fragment))) + |