Skip to content

Commit

Permalink
add tests for more types
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed May 15, 2023
1 parent 9ac97e0 commit 71b36df
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/parser/features/test_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,33 @@ def bug(xs: uint256[2]) -> uint256[2]:
c = get_contract(code)

assert c.bug([1, 2]) == [2, 1]


def test_assign_rhs_lhs_overlap_dynarray(get_contract):
# GH issue 2418, generalize to dynarrays
code = """
@external
def bug(xs: DynArray[uint256, 2]) -> DynArray[uint256, 2]:
ys: DynArray[uint256, 2] = xs
ys = [ys[1], ys[0]]
return ys
"""
c = get_contract(code)
assert c.bug([1, 2]) == [2, 1]


def test_assign_rhs_lhs_overlap_struct(get_contract):
# GH issue 2418, generalize to structs
code = """
struct Point:
x: uint256
y: uint256
@external
def bug(p: Point) -> Point:
t: Point = p
t = Point({x: t.y, y: t.x})
return t
"""
c = get_contract(code)
assert c.bug((1, 2)) == (2, 1)

0 comments on commit 71b36df

Please sign in to comment.