vyper-debug/tests/core/test_source_map.py

40 lines
881 B
Python
Raw Normal View History

2018-07-17 15:31:45 +00:00
from vdb.source_map import produce_source_map
def test_source_map_output():
code = """
2019-02-11 10:07:17 +00:00
a_map: map(bytes32, bytes32)
2018-07-17 15:31:45 +00:00
@public
def func1(a: int128) -> int128:
b: int128 = 2
c: int128 = 3
g: bytes[10]
return a + b + c + 1
@public
def func2(a: int128):
x: uint256
"""
sm = produce_source_map(code)
# globals
assert sm['globals']['a_map'] == {
2019-02-11 10:07:17 +00:00
'type': 'map(bytes32, bytes32)',
2018-07-17 15:31:45 +00:00
'size': 0,
'position': 0
}
# locals
assert sm['locals']['func1'] == {
'from_lineno': 4,
'to_lineno': 11,
'variables': {
'a': {'type': 'int128', 'size': 32, 'position': 320},
'b': {'type': 'int128', 'size': 32, 'position': 352},
'c': {'type': 'int128', 'size': 32, 'position': 384},
2018-07-18 14:09:25 +00:00
'g': {'type': 'bytes[10]', 'size': 96, 'position': 416}
},
}