Skip to content

Commit

Permalink
fix functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Feb 6, 2024
1 parent 7a608bd commit 35f79c0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
6 changes: 3 additions & 3 deletions tests/functional/builtins/codegen/test_minmax_value.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from vyper.exceptions import InvalidType, OverflowException
from vyper.exceptions import OverflowException, TypeMismatch
from vyper.semantics.types import DecimalT, IntegerT
from vyper.semantics.types.shortcuts import INT256_T, UINT256_T

Expand Down Expand Up @@ -39,12 +39,12 @@ def foo():
if typ == UINT256_T:
assert_compile_failed(lambda: get_contract(upper), OverflowException)
else:
assert_compile_failed(lambda: get_contract(upper), InvalidType)
assert_compile_failed(lambda: get_contract(upper), TypeMismatch)

if typ == INT256_T:
assert_compile_failed(lambda: get_contract(lower), OverflowException)
else:
assert_compile_failed(lambda: get_contract(lower), InvalidType)
assert_compile_failed(lambda: get_contract(lower), TypeMismatch)


@pytest.mark.parametrize("typ", [DecimalT()])
Expand Down
13 changes: 9 additions & 4 deletions tests/functional/codegen/types/numbers/test_signed_ints.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
import pytest

from vyper import compile_code
from vyper.exceptions import InvalidOperation, InvalidType, OverflowException, ZeroDivisionException
from vyper.exceptions import (
InvalidOperation,
OverflowException,
TypeMismatch,
ZeroDivisionException,
)
from vyper.semantics.types import IntegerT
from vyper.utils import evm_div, evm_mod

Expand Down Expand Up @@ -214,7 +219,7 @@ def num_sub() -> {typ}:
return 1-2**{typ.bits}
"""

exc = OverflowException if typ.bits == 256 else InvalidType
exc = OverflowException if typ.bits == 256 else TypeMismatch
with pytest.raises(exc):
compile_code(code)

Expand Down Expand Up @@ -331,7 +336,7 @@ def foo() -> {typ}:
get_contract(code_2).foo(x)
with tx_failed():
get_contract(code_3).foo(y)
with pytest.raises((InvalidType, OverflowException)):
with pytest.raises((TypeMismatch, OverflowException)):
compile_code(code_4)


Expand Down Expand Up @@ -430,5 +435,5 @@ def test_binop_nested_intermediate_underflow():
def foo():
a: int256 = -2**255 * 2 - 10 + 100
"""
with pytest.raises(InvalidType):
with pytest.raises(TypeMismatch):
compile_code(code)
11 changes: 8 additions & 3 deletions tests/functional/codegen/types/numbers/test_unsigned_ints.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
import pytest

from vyper import compile_code
from vyper.exceptions import InvalidOperation, InvalidType, OverflowException, ZeroDivisionException
from vyper.exceptions import (
InvalidOperation,
OverflowException,
TypeMismatch,
ZeroDivisionException,
)
from vyper.semantics.types import IntegerT
from vyper.utils import SizeLimits, evm_div, evm_mod

Expand Down Expand Up @@ -164,7 +169,7 @@ def foo() -> {typ}:
get_contract(code_2).foo(x)
with tx_failed():
get_contract(code_3).foo(y)
with pytest.raises((InvalidType, OverflowException)):
with pytest.raises((TypeMismatch, OverflowException)):
get_contract(code_4)


Expand Down Expand Up @@ -223,7 +228,7 @@ def test() -> {typ}:

for val in bad_cases:
exc = (
InvalidType
TypeMismatch
if SizeLimits.MIN_INT256 <= val <= SizeLimits.MAX_UINT256
else OverflowException
)
Expand Down

0 comments on commit 35f79c0

Please sign in to comment.