コード例 #1
0
def test_mulitline_brace_arg():
    src = r"""
    \outer{
        \inner
    }
    """
    assert tokenize(src) == [Command('outer', args=[[Command('inner')]])]
コード例 #2
0
def test_multiple_brace_args_with_command():
    src = r"""
    \outer{a}{
        \inner
        some body text
    }
    """

    res = tokenize(src)
    assert res == [
        Command('outer', [['a'], [Command('inner'), 'some body text\n    ']])
    ]
コード例 #3
0
def test_inner_body_and_two_commands():
    src = r"""
    \outer{
        \inner1{a}
        hello
        \inner2
    }
    """

    tokens = tokenize(src)
    print(tokens)
    assert tokens == [
        Command('outer',
                args=[[
                    Command('inner1', args=[['a']]), 'hello\n        ',
                    Command('inner2')
                ]])
    ]
コード例 #4
0
def test_command_then_body():
    assert tokenize(r'\command body') == [Command('command'), 'body']
コード例 #5
0
def test_nested_brace_args_with_body_2():
    assert tokenize(r'\outer{\inner text}') == [
        Command('outer', args=[[Command('inner'), 'text']])
    ]
コード例 #6
0
def test_body_then_command():
    assert tokenize(r'body \command') == ['body ', Command('command')]
コード例 #7
0
def test_nested_brace_args_with_body():
    assert tokenize(r'\outer{text \inner}') == [
        Command('outer', args=[['text ', Command('inner')]])
    ]
コード例 #8
0
def test_single_command():
    assert tokenize(r'\mycommand') == [Command('mycommand')]
コード例 #9
0
def test_inline_math():
    assert tokenize(r"$1+1$") == [Math(["1+1"])]
コード例 #10
0
def test_nested_brace_args():
    assert tokenize(r'\outer{\inner}') == [
        Command('outer', args=[[Command('inner')]])
    ]
コード例 #11
0
def test_two_commands():
    assert tokenize(r'\mycommand\myothercommand') == [
        Command('mycommand'), Command('myothercommand')
    ]
コード例 #12
0
def test_brace_and_bracket():
    assert tokenize(r"\command{a}[b]") == [
        Command('command', args=[['a'], ['b']])
    ]
コード例 #13
0
def test_displayed_equation():
    assert tokenize(r"$$1$$") == [Math(['1'], inline=False)]
コード例 #14
0
def test_displayed_math_with_command():
    assert tokenize(r"$$\frac{a}{b} + 1$$") == [
        Math([Command('frac', args=[['a'], ['b']]), '+ 1'], inline=False)
    ]
コード例 #15
0
def test_two_inline_maths():
    assert tokenize(r"$1$ and $2$") == [Math(['1']), 'and ', Math(['2'])]
コード例 #16
0
def test_command_with_brace_arg():
    src = r'\test{a}'
    assert tokenize(src) == [Command('test', args=[['a']])]
コード例 #17
0
def test_inline_math_with_command():
    assert tokenize(r"$\frac{a}{b} + 1$") == [
        Math([Command('frac', args=[['a'], ['b']]), '+ 1'])
    ]
コード例 #18
0
def test_two_command_inside_command():
    assert tokenize(r'\outer{\innerone \innertwo}') == [
        Command('outer', args=[[Command('innerone'),
                                Command('innertwo')]])
    ]
コード例 #19
0
def test_bracket_arg():
    assert tokenize(r"\command[value]") == [
        Command('command', args=[['value']])
    ]
コード例 #20
0
def test_inline_and_displayed_maths():
    assert tokenize(r"$1$ and $$2$$") == [
        Math(['1']), 'and ', Math(['2'], inline=False)
    ]
コード例 #21
0
def test_bracket_and_brace():
    assert tokenize(r"\command[a]{b}") == [
        Command('command', args=[['a'], ['b']])
    ]
コード例 #22
0
def test_command_with_number():
    assert tokenize(r"\hello1") == [Command('hello1')]
コード例 #23
0
def test_many_brace_args():
    assert tokenize(r'\test{a}{b}') == [Command('test', args=[['a'], ['b']])]
コード例 #24
0
def test_multiple_brace_args():
    assert tokenize(r"\command{a}{b}") == [
        Command('command', args=[['a'], ['b']])
    ]
コード例 #25
0
def test_brace_args_with_white_space():
    assert tokenize(r'\test{a long argument}') == [
        Command('test', args=[['a long argument']])
    ]