Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed May 12, 2022
1 parent 83d0daa commit bd1121d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions tests/parser/functions/test_bitwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def _bitwise_not(x: uint256) -> uint256:
@external
def _shift(x: uint256, y: int128) -> uint256:
return shift(x, y)
@external
def _negatedShift(x: uint256, y: int128) -> uint256:
return shift(x, -y)
"""


Expand Down Expand Up @@ -55,6 +59,14 @@ def test_test_bitwise(get_contract_with_gas_estimation, evm_version):
assert c._shift(x, -1) == x // 2
assert c._shift(x, -3) == x // 8
assert c._shift(x, -256) == 0
assert c._negatedShift(x, -3) == x * 8
assert c._negatedShift(x, -255) == 0
assert c._negatedShift(y, -255) == 2 ** 255
assert c._negatedShift(x, -256) == 0
assert c._negatedShift(x, -0) == x
assert c._negatedShift(x, 1) == x // 2
assert c._negatedShift(x, 3) == x // 8
assert c._negatedShift(x, 256) == 0


@pytest.mark.parametrize("evm_version", list(EVM_VERSIONS))
Expand Down
10 changes: 9 additions & 1 deletion tests/parser/syntax/test_extract32.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

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

fail_list = [
(
Expand Down Expand Up @@ -28,6 +28,14 @@ def foo(inp: Bytes[32]) -> int128:
""",
TypeMismatch,
),
(
"""
@external
def foo(inp: Bytes[32]) -> bool:
return extract32(inp, 0, output_type=bool)
""",
InvalidType,
),
]


Expand Down

0 comments on commit bd1121d

Please sign in to comment.