summaryrefslogtreecommitdiff
path: root/tests/test_java.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_java.py')
-rw-r--r--tests/test_java.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/test_java.py b/tests/test_java.py
index 33a64e99..f4096647 100644
--- a/tests/test_java.py
+++ b/tests/test_java.py
@@ -9,7 +9,7 @@
import unittest
-from pygments.token import Text, Name, Operator, Keyword
+from pygments.token import Text, Name, Operator, Keyword, Number
from pygments.lexers import JavaLexer
@@ -40,3 +40,39 @@ class JavaTest(unittest.TestCase):
]
self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+ def testNumericLiterals(self):
+ fragment = '0 5L 9__542_72l 0xbEEf 0X9_A 0_35 01 0b0___101_0'
+ fragment += ' 0. .7_17F 3e-1_3d 1f 6_01.9e+3 0x.1Fp3 0XEP8D\n'
+ tokens = [
+ (Number.Integer, '0'),
+ (Text, ' '),
+ (Number.Integer, '5L'),
+ (Text, ' '),
+ (Number.Integer, '9__542_72l'),
+ (Text, ' '),
+ (Number.Hex, '0xbEEf'),
+ (Text, ' '),
+ (Number.Hex, '0X9_A'),
+ (Text, ' '),
+ (Number.Oct, '0_35'),
+ (Text, ' '),
+ (Number.Oct, '01'),
+ (Text, ' '),
+ (Number.Bin, '0b0___101_0'),
+ (Text, ' '),
+ (Number.Float, '0.'),
+ (Text, ' '),
+ (Number.Float, '.7_17F'),
+ (Text, ' '),
+ (Number.Float, '3e-1_3d'),
+ (Text, ' '),
+ (Number.Float, '1f'),
+ (Text, ' '),
+ (Number.Float, '6_01.9e+3'),
+ (Text, ' '),
+ (Number.Float, '0x.1Fp3'),
+ (Text, ' '),
+ (Number.Float, '0XEP8D'),
+ (Text, '\n')
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))