-
-
Notifications
You must be signed in to change notification settings - Fork 784
/
test_variable_names.py
77 lines (69 loc) · 1.27 KB
/
test_variable_names.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import pytest
from pytest import (
raises,
)
from vyper import (
compiler,
)
from vyper.exceptions import (
VariableDeclarationException,
)
fail_list = [ # noqa: E122
"""
@public
def foo(i: int128) -> int128:
varő : int128 = i
return varő
""",
"""
@public
def foo(i: int128) -> int128:
int128 : int128 = i
return int128
""",
"""
@public
def foo(i: int128) -> int128:
decimal : int128 = i
return decimal
""",
"""
@public
def foo(i: int128) -> int128:
wei : int128 = i
return wei
""",
"""
@public
def foo(i: int128) -> int128:
false : int128 = i
return false
""",
]
@pytest.mark.parametrize('bad_code', fail_list)
def test_varname_validity_fail(bad_code):
with raises(VariableDeclarationException):
compiler.compile_code(bad_code)
valid_list = [
"""
@public
def foo(i: int128) -> int128:
variable : int128 = i
return variable
""",
"""
@public
def foo(i: int128) -> int128:
var_123 : int128 = i
return var_123
""",
"""
@public
def foo(i: int128) -> int128:
_var123 : int128 = i
return _var123
""",
]
@pytest.mark.parametrize('good_code', valid_list)
def test_varname_validity_success(good_code):
assert compiler.compile_code(good_code) is not None