Skip to content

Commit

Permalink
add another test
Browse files Browse the repository at this point in the history
---------

Co-authored-by: trocher <[email protected]>
  • Loading branch information
charles-cooper and trocher committed Jun 2, 2024
1 parent 9740de3 commit e46e535
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/functional/syntax/modules/test_initializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,59 @@ def __init__():
assert compile_code(main, input_bundle=input_bundle) is not None


# test multiple uses in different nodes of the import tree
def test_distant_use_initialize(make_input_bundle):
lib3 = """
counter: uint256
@deploy
def __init__():
self.counter = 1
"""
lib2 = """
import lib3
uses: lib3
counter: uint256
@deploy
def __init__():
self.counter = 1
@external
def foo() ->uint256:
return lib3.counter
"""
lib1 = """
import lib2
import lib3
uses: lib3
initializes: lib2[lib3 := lib3]
@deploy
def __init__():
lib2.__init__()
lib3.counter += 1
"""
main = """
import lib1
import lib3
initializes: lib1[lib3 := lib3]
initializes: lib3
@deploy
def __init__():
lib3.__init__()
lib1.__init__()
"""
input_bundle = make_input_bundle({"lib1.vy": lib1, "lib2.vy": lib2, "lib3.vy": lib3})

assert compile_code(main, input_bundle=input_bundle) is not None


def test_initialize_multi_line_uses(make_input_bundle):
lib1 = """
counter: uint256
Expand Down

0 comments on commit e46e535

Please sign in to comment.