mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
even more macro tests
This commit is contained in:
parent
37e458109c
commit
d5be829598
1 changed files with 27 additions and 0 deletions
|
@ -195,6 +195,14 @@ def test_call_macro_str(arg):
|
|||
assert rtn is arg
|
||||
|
||||
|
||||
@pytest.mark.parametrize('arg', ['x', '42', 'x + y'])
|
||||
def test_call_macro_ast(arg):
|
||||
def f(x : AST):
|
||||
return x
|
||||
rtn = call_macro(f, [arg], {}, None)
|
||||
assert isinstance(rtn, AST)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('arg', ['x', '42', 'x + y'])
|
||||
def test_call_macro_code(arg):
|
||||
def f(x : compile):
|
||||
|
@ -202,3 +210,22 @@ def test_call_macro_code(arg):
|
|||
rtn = call_macro(f, [arg], {}, None)
|
||||
assert isinstance(rtn, types.CodeType)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('arg', ['x', '42', 'x + y'])
|
||||
def test_call_macro_eval(arg):
|
||||
def f(x : eval):
|
||||
return x
|
||||
rtn = call_macro(f, [arg], {'x': 42, 'y': 0}, None)
|
||||
assert rtn == 42
|
||||
|
||||
|
||||
@pytest.mark.parametrize('arg', ['if y:\n pass',
|
||||
'if 42:\n pass',
|
||||
'if x + y:\n pass'])
|
||||
def test_call_macro_exec(arg):
|
||||
def f(x : exec):
|
||||
return x
|
||||
rtn = call_macro(f, [arg], {'x': 42, 'y': 0}, None)
|
||||
assert rtn is None
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue