even more macro tests

This commit is contained in:
Anthony Scopatz 2016-08-20 16:00:30 -04:00
parent 37e458109c
commit d5be829598

View file

@ -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