Python pygments.token.Number.Float() Examples
The following are 4
code examples of pygments.token.Number.Float().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pygments.token.Number
, or try the search function
.
Example #1
Source File: test_sql.py From pygments with BSD 2-Clause "Simplified" License | 5 votes |
def test_can_lex_float(lexer): _assert_are_tokens_of_type(lexer, '1. 1.e1 .1 1.2 1.2e3 1.2e+3 1.2e-3 1e2', Number.Float) _assert_tokens_match(lexer, '1e2.1e2', ((Number.Float, '1e2'), (Number.Float, '.1e2')))
Example #2
Source File: test_basic.py From pygments with BSD 2-Clause "Simplified" License | 5 votes |
def test_can_lex_float(lexer): assert_are_tokens_of_type(lexer, '1. 1.e1 .1 1.2 1.2e3 1.2e+3 1.2e-3 1e2', Number.Float) assert_tokens_match(lexer, '1e2.1e2', ((Number.Float, '1e2'), (Number.Float, '.1e2')))
Example #3
Source File: test_java.py From pygments with BSD 2-Clause "Simplified" License | 5 votes |
def test_numeric_literals(lexer): 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') ] assert list(lexer.get_tokens(fragment)) == tokens
Example #4
Source File: test_clexer.py From pygments with BSD 2-Clause "Simplified" License | 5 votes |
def test_numbers(lexer): code = '42 23.42 23. .42 023 0xdeadbeef 23e+42 42e-23' wanted = [] for item in zip([Number.Integer, Number.Float, Number.Float, Number.Float, Number.Oct, Number.Hex, Number.Float, Number.Float], code.split()): wanted.append(item) wanted.append((Text, ' ')) wanted = wanted[:-1] + [(Text, '\n')] assert list(lexer.get_tokens(code)) == wanted