Skip to content

Commit

Permalink
revert unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iFrostizz committed Nov 10, 2023
1 parent a782cbe commit b3ad481
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 40 deletions.
46 changes: 8 additions & 38 deletions tests/functional/builtins/codegen/test_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,72 +434,42 @@ def test_slice_bytes32_calldata_extended(get_contract, code, result):
)


code_compruntime = [
code_comptime = [
(
"bytes32",
"""
@external
@view
def baz() -> Bytes[16]:
return slice(0x1234567891234567891234567891234567891234567891234567891234567891, 0, 16)
""",
"""
@external
@view
def baz(val: bytes32) -> Bytes[16]:
return slice(val, 0, 16)
""",
"0x1234567891234567891234567891234567891234567891234567891234567891",
"12345678912345678912345678912345",
),
(
"string",
"""
@external
@view
def baz() -> String[5]:
return slice("why hello! how are you?", 4, 5)
""",
"""
@external
@view
def baz(val: String[100]) -> String[5]:
return slice(val, 4, 5)
""",
"why hello! how are you?",
"hello",
),
(
"bytes",
"""
@external
@view
def baz() -> Bytes[6]:
return slice(b'gm sir, how are you ?', 0, 6)
""",
"""
@external
@view
def baz(val: Bytes[100]) -> Bytes[6]:
return slice(val, 0, 6)
""",
b"gm sir, how are you ?",
"gm sir".encode("utf-8").hex(),
),
]


@pytest.mark.parametrize(
"name,compcode,runcode,arg,result", code_compruntime, ids=[el[0] for el in code_compruntime]
)
def test_comptime_runtime(get_contract, name, compcode, runcode, arg, result):
c1 = get_contract(compcode)
c2 = get_contract(runcode)
ret1 = c1.baz()
ret2 = c2.baz(arg)
if hasattr(ret1, "hex"):
assert ret1.hex() == result
assert ret2.hex() == result
@pytest.mark.parametrize("code,result", code_comptime)
def test_comptime(get_contract, code, result):
c = get_contract(code)
ret = c.baz()
if hasattr(ret, "hex"):
assert ret.hex() == result
else:
assert ret1 == result
assert ret2 == result
assert ret == result
2 changes: 0 additions & 2 deletions vyper/builtins/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,6 @@ def evaluate(self, node):
if st_val + le_val > 32:
raise ArgumentException("Slice is out of bounds", st)
if isinstance(lit, vy_ast.Bytes):
st_val *= 2
le_val *= 2
sublit = lit.value[st_val : (st_val + le_val)]
return vy_ast.Bytes.from_node(node, value=sublit)
elif isinstance(lit, vy_ast.Str):
Expand Down

0 comments on commit b3ad481

Please sign in to comment.