예제 #1
0
def test_decimal():
    lex = question_lexer.clone()
    lex.input('$(2.15 + 3 - 4.2)')
    assert lexer_to_list(lex) == [('START', '$('),
                                  ('DECIMAL', Decimal('2.15')), ('PLUS', '+'),
                                  ('INT', 3), ('MINUS', '-'),
                                  ('DECIMAL', Decimal('4.2')), ('RPAREN', ')')]
예제 #2
0
def test_text_2():
    lex = question_lexer.clone()
    lex.input('$$()')
    assert lexer_to_list(lex) == [('CHAR', '$'), ('START', '$('),
                                  ('RPAREN', ')')]
예제 #3
0
def test_text_1():
    lex = question_lexer.clone()
    lex.input('Hola')
    assert lexer_to_list(lex) == [('CHAR', 'H'), ('CHAR', 'o'), ('CHAR', 'l'),
                                  ('CHAR', 'a')]
예제 #4
0
def test_character_ignore():
    lex = question_lexer.clone()
    lex.input('$(3 + \t\n 5)')
    assert lexer_to_list(lex) == [('START', '$('), ('INT', 3), ('PLUS', '+'),
                                  ('INT', 5), ('RPAREN', ')')]
예제 #5
0
def test_simple_operation():
    lex = question_lexer.clone()
    lex.input('$(3+5)')
    assert lexer_to_list(lex) == [('START', '$('), ('INT', 3), ('PLUS', '+'),
                                  ('INT', 5), ('RPAREN', ')')]
예제 #6
0
def test_one_operator_2():
    lex = question_lexer.clone()
    lex.input('$(-)')
    assert lexer_to_list(lex) == [('START', '$('), ('MINUS', '-'),
                                  ('RPAREN', ')')]