diff options
author | Tim Hatch <tim@timhatch.com> | 2014-10-07 13:36:40 -0700 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2014-10-07 13:36:40 -0700 |
commit | b6bb2c8014af050d4f11f22e35e2fa4a3e79b242 (patch) | |
tree | 309d0452a17799837162a6f1ca1c6f615107b6d9 /tests/test_java.py | |
parent | 292b11fdfa96f33f40380a1053b65a2d5f344783 (diff) | |
download | pygments-b6bb2c8014af050d4f11f22e35e2fa4a3e79b242.tar.gz |
Fix highlighting of Java enhanced for loops.
Fixes #965
Diffstat (limited to 'tests/test_java.py')
-rw-r--r-- | tests/test_java.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test_java.py b/tests/test_java.py new file mode 100644 index 00000000..9cf96373 --- /dev/null +++ b/tests/test_java.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +""" + Basic JavaLexer Test + ~~~~~~~~~~~~~~~~~~~~ + + :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import unittest + +from pygments.token import Text, Name, Operator, Keyword +from pygments.lexers import JavaLexer + + +class JavaTest(unittest.TestCase): + + def setUp(self): + self.lexer = JavaLexer() + self.maxDiff = None + + def testEnhancedFor(self): + fragment = u'label:\nfor(String var2: var1) {}\n' + tokens = [ + (Name.Label, u'label:'), + (Text, u'\n'), + (Keyword, u'for'), + (Operator, u'('), + (Name, u'String'), + (Text, u' '), + (Name, u'var2'), + (Operator, u':'), + (Text, u' '), + (Name, u'var1'), + (Operator, u')'), + (Text, u' '), + (Operator, u'{'), + (Operator, u'}'), + (Text, u'\n'), + ] + self.assertEqual(tokens, list(self.lexer.get_tokens(fragment))) + |