Debian Codegraph @

tests/test_func.py

raw
1 import pytest
2 from pygments.lexers.func import FuncLexer
3 from pygments.token import Token, Name
4
5 @pytest.fixture(scope='module')
6 def lexer_func():
7 yield FuncLexer()
8
9
10 @pytest.mark.parametrize('text', (
11 'take(first)Entry', '"not_a_string', 'msg.sender', 'send_message,then_terminate', '_'))
12 def test_func_not_identifier(lexer_func, text):
13 """Test text that should **not** be tokenized as identifier."""
14 assert list(lexer_func.get_tokens(text))[0] != (Name.Variable, text)
15
16
17 @pytest.mark.parametrize('text', (
18 '`test identifier`', 'simple_identifier', 'query\'\'',
19 '_internal_value', 'get_pubkeys&signatures',
20 'dict::udict_set_builder', '2+2=2*2', '-alsovalidname', '{hehehe}'))
21 def test_func_identifier(lexer_func, text):
22 """Test text that should be tokenized as identifier."""
23 assert list(lexer_func.get_tokens(text))[0] == (Name.Variable, text)
24
25
26 @pytest.mark.parametrize('text', (
27 '`test identifier`(', 'simple_identifier(', 'query\'\'(',
28 '_internal_value(', 'get_pubkeys&signatures(',
29 'dict::udict_set_builder(', '2+2=2*2(', '-alsovalidname(', '{hehehe}('))
30 def test_func_function(lexer_func, text):
31 """Test text that should be tokenized as identifier."""
32 assert list(lexer_func.get_tokens(text))[0] == (Name.Function, text[:-1])
33
34
35 @pytest.mark.parametrize('text', ('0x0f', '0x1_2', '123', '0b10', '0xffff_fff', '1'))
36 def test_func_number(lexer_func, text):
37 """Test text that should be tokenized as number."""
38 assert list(lexer_func.get_tokens(text))[0] == (Token.Literal.Number, text)
39
40
41 @pytest.mark.parametrize('text', ('0x0f_m', '0X1_2', '12d3', '0b1_0f', '0bff_fff', '0b'))
42 def test_func_not_number(lexer_func, text):
43 """Test text that should *not* be tokenized as number."""
44 assert list(lexer_func.get_tokens(text))[0] != (Token.Literal.Number, text)