Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Nov 14, 2023
1 parent 9b94fdd commit e74d701
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
7 changes: 1 addition & 6 deletions tests/functional/builtins/codegen/test_unary.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,11 @@ def bar() -> decimal:

def test_negation_int128(get_contract):
code = """
a: constant(int128) = -2**127
@external
def foo() -> int128:
return -2**127
a: constant(int128) = min_value(int128)
@external
def bar() -> int128:
return -(a+1)
"""
c = get_contract(code)
assert c.foo() == -(2**127)
assert c.bar() == 2**127 - 1
2 changes: 1 addition & 1 deletion tests/functional/builtins/folding/test_abs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_abs_lower_bound_folded(get_contract, assert_tx_failed):
source = """
@external
def foo() -> int256:
return abs(-2**255)
return abs(min_value(int256))
"""
with pytest.raises(OverflowException):
get_contract(source)
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def test_int128_too_long(get_contract, assert_tx_failed):
contract_1 = """
@external
def foo() -> int256:
return (2**255)-1
return max_value(int256)
"""

c = get_contract(contract_1)
Expand Down
22 changes: 22 additions & 0 deletions tests/functional/syntax/test_unary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest

from vyper.compiler import compile_code
from vyper.exceptions import InvalidType, TypeMismatch


fail_list = [
(
"""
@external
def foo() -> int128:
return -2**127
""",
InvalidType,
),
]


@pytest.mark.parametrize("code,exc", fail_list)
def test_unary_fail(code, exc):
with pytest.raises(exc):
compile_code(code)

0 comments on commit e74d701

Please sign in to comment.