From b6bb2c8014af050d4f11f22e35e2fa4a3e79b242 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Tue, 7 Oct 2014 13:36:40 -0700 Subject: Fix highlighting of Java enhanced for loops. Fixes #965 --- tests/test_java.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/test_java.py (limited to 'tests/test_java.py') 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))) + -- cgit v1.2.1