Skip to content

Commit

Permalink
added tests for ast_to_typ
Browse files Browse the repository at this point in the history
  • Loading branch information
nucccc committed Dec 4, 2023
1 parent c30d6fa commit 74b6987
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/test_ast_to_typ.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ def test_type_from_constant():
t = typ_from_constant(const)
assert t.is_float()

const_code = 'b\'abc\''
const_mod = ast.parse(const_code)
const = const_mod.body[0].value

t = typ_from_constant(const)
assert t.is_any()



def test_type_from_iter():
code = '''for i in range(7):\n\tpass'''
m = ast.parse(code)
Expand Down Expand Up @@ -81,4 +90,16 @@ def test_type_from_bin_op():
op_mod = ast.parse(op_code)
bin_op = op_mod.body[0].value
t = typ_from_bin_op(bin_op)
assert t.is_float()
assert t.is_float()

op_code = 'a - 1'
op_mod = ast.parse(op_code)
bin_op = op_mod.body[0].value
t = typ_from_bin_op(bin_op)
assert t.is_any()

op_code = '1 - a'
op_mod = ast.parse(op_code)
bin_op = op_mod.body[0].value
t = typ_from_bin_op(bin_op)
assert t.is_any()

0 comments on commit 74b6987

Please sign in to comment.