Skip to content

Commit

Permalink
testing ast to typ
Browse files Browse the repository at this point in the history
  • Loading branch information
nucccc committed Dec 4, 2023
1 parent 74b6987 commit a1074a6
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions tests/test_ast_to_typ.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
typ_from_bin_op,
typ_from_constant,
typ_from_iter,
typ_from_call,
ast_val_to_typ
)

Expand Down Expand Up @@ -44,7 +45,6 @@ def test_type_from_constant():

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



def test_type_from_iter():
Expand Down Expand Up @@ -102,4 +102,36 @@ 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_any()
assert t.is_any()


def test_typ_from_call():
code = 'a = int(7.0)'
mod = ast.parse(code)
call = mod.body[0].value

print(type(call))

call_typ = typ_from_call(call = call)
assert call_typ.is_int()

code = 'a = float(7)'
mod = ast.parse(code)
call = mod.body[0].value

call_typ = typ_from_call(call = call)
assert call_typ.is_float()

code = 'a = bool(7)'
mod = ast.parse(code)
call = mod.body[0].value

call_typ = typ_from_call(call = call)
assert call_typ.is_bool()

code = 'a = asfasf(7)'
mod = ast.parse(code)
call = mod.body[0].value

call_typ = typ_from_call(call = call)
assert call_typ.is_any()

0 comments on commit a1074a6

Please sign in to comment.