Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Nov 17, 2024
1 parent 631a132 commit 2eac70d
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions tests/functional/syntax/exceptions/test_syntax_exception.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest

from vyper.compiler import compile_code
from vyper.exceptions import SyntaxException

fail_list = [
Expand Down Expand Up @@ -107,5 +108,29 @@ def foo():


@pytest.mark.parametrize("bad_code", fail_list)
def test_syntax_exception(assert_compile_failed, get_contract, bad_code):
assert_compile_failed(lambda: get_contract(bad_code), SyntaxException)
def test_syntax_exception(bad_code):
with pytest.raises(SyntaxException):
compile_code(bad_code)


def test_bad_staticcall_keyword():
bad_code = """
from ethereum.ercs import IERC20Detailed
def foo():
staticcall ERC20(msg.sender).transfer(msg.sender, staticall IERC20Detailed(msg.sender).decimals())
""".strip()
with pytest.raises(SyntaxException) as e:
compile_code(bad_code)

expected_error = """
Possible typo: `staticall`
line 4:54
3 def foo():
---> 4 staticcall ERC20(msg.sender).transfer(msg.sender, staticall IERC20Detailed(msg.sender).decimals())
-------------------------------------------------------------^
(hint: did you mean `staticcall`?)
""" # noqa
assert str(e.value) == expected_error.strip()

0 comments on commit 2eac70d

Please sign in to comment.