From 7e98c1e0f8768c8d01207747cc106a037c9feba4 Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Wed, 14 Feb 2024 16:48:40 +0800 Subject: [PATCH] fix tests --- .../codegen/integration/test_crowdfund.py | 2 +- .../modules/test_stateless_functions.py | 4 +- .../codegen/storage_variables/test_setters.py | 32 ++++---- tests/functional/codegen/types/test_bytes.py | 8 +- .../codegen/types/test_dynamic_array.py | 47 ++++++----- .../test_variable_declaration_exception.py | 2 +- tests/functional/syntax/test_ann_assign.py | 8 +- tests/functional/syntax/test_block.py | 6 +- tests/functional/syntax/test_constants.py | 12 +-- tests/functional/syntax/test_flag.py | 8 +- tests/functional/syntax/test_immutables.py | 2 +- tests/functional/syntax/test_invalids.py | 2 +- tests/functional/syntax/test_no_none.py | 6 +- tests/functional/syntax/test_structs.py | 82 +++++++++---------- .../cli/vyper_compile/test_compile_files.py | 4 +- .../unit/semantics/analysis/test_for_loop.py | 2 +- tests/unit/semantics/test_storage_slots.py | 14 ++-- 17 files changed, 116 insertions(+), 125 deletions(-) diff --git a/tests/functional/codegen/integration/test_crowdfund.py b/tests/functional/codegen/integration/test_crowdfund.py index 1a8b3f7e9f..b07ce5dc22 100644 --- a/tests/functional/codegen/integration/test_crowdfund.py +++ b/tests/functional/codegen/integration/test_crowdfund.py @@ -121,7 +121,7 @@ def __init__(_beneficiary: address, _goal: uint256, _timelimit: uint256): def participate(): assert block.timestamp < self.deadline nfi: int128 = self.nextFunderIndex - self.funders[nfi] = Funder({sender: msg.sender, value: msg.value}) + self.funders[nfi] = Funder(sender=msg.sender, value=msg.value) self.nextFunderIndex = nfi + 1 @external diff --git a/tests/functional/codegen/modules/test_stateless_functions.py b/tests/functional/codegen/modules/test_stateless_functions.py index 26c3f338fb..722b287d98 100644 --- a/tests/functional/codegen/modules/test_stateless_functions.py +++ b/tests/functional/codegen/modules/test_stateless_functions.py @@ -159,7 +159,7 @@ def test_library_structs(get_contract, make_input_bundle): @internal def foo() -> SomeStruct: - return SomeStruct({x: 1}) + return SomeStruct(x=1) """ contract_source = """ import library @@ -170,7 +170,7 @@ def bar(s: library.SomeStruct): @external def baz() -> library.SomeStruct: - return library.SomeStruct({x: 2}) + return library.SomeStruct(x=2) @external def qux() -> library.SomeStruct: diff --git a/tests/functional/codegen/storage_variables/test_setters.py b/tests/functional/codegen/storage_variables/test_setters.py index 119157977a..cf4138b939 100644 --- a/tests/functional/codegen/storage_variables/test_setters.py +++ b/tests/functional/codegen/storage_variables/test_setters.py @@ -91,16 +91,16 @@ def test_multi_setter_struct_test(get_contract_with_gas_estimation): @external def foo() -> int128: foo0: int128 = 1 - self.dog[0] = Dog({foo: foo0, bar: 2}) - self.dog[1] = Dog({foo: 3, bar: 4}) - self.dog[2] = Dog({foo: 5, bar: 6}) + self.dog[0] = Dog(foo=foo0, bar=2) + self.dog[1] = Dog(foo=3, bar=4) + self.dog[2] = Dog(foo=5, bar=6) return self.dog[0].foo + self.dog[0].bar * 10 + self.dog[1].foo * 100 + \ self.dog[1].bar * 1000 + self.dog[2].foo * 10000 + self.dog[2].bar * 100000 @external def fop() -> int128: - self.z = [Z({foo: [1, 2, 3], bar: [Bar({a: 4, b: 5}), Bar({a: 2, b: 3})]}), - Z({foo: [6, 7, 8], bar: [Bar({a: 9, b: 1}), Bar({a: 7, b: 8})]})] + self.z = [Z(foo=[1, 2, 3], bar=[Bar(a=4, b=5), Bar(a=2, b=3)]), + Z(foo=[6, 7, 8], bar=[Bar(a=9, b=1), Bar(a=7, b=8)])] return self.z[0].foo[0] + self.z[0].foo[1] * 10 + self.z[0].foo[2] * 100 + \ self.z[0].bar[0].a * 1000 + \ self.z[0].bar[0].b * 10000 + \ @@ -116,15 +116,15 @@ def fop() -> int128: @external def goo() -> int128: - god: Goo[3] = [Goo({foo: 1, bar: 2}), Goo({foo: 3, bar: 4}), Goo({foo: 5, bar: 6})] + god: Goo[3] = [Goo(foo=1, bar=2), Goo(foo=3, bar=4), Goo(foo=5, bar=6)] return god[0].foo + god[0].bar * 10 + god[1].foo * 100 + \ god[1].bar * 1000 + god[2].foo * 10000 + god[2].bar * 100000 @external def gop() -> int128: zed: Zed[2] = [ - Zed({foo: [1, 2, 3], bar: [Bar({a: 4, b: 5}), Bar({a: 2, b: 3})]}), - Zed({foo: [6, 7, 8], bar: [Bar({a: 9, b: 1}), Bar({a: 7, b: 8})]}) + Zed(foo=[1, 2, 3], bar=[Bar(a=4, b=5), Bar(a=2, b=3)]), + Zed(foo=[6, 7, 8], bar=[Bar(a=9, b=1), Bar(a=7, b=8)]) ] return zed[0].foo[0] + zed[0].foo[1] * 10 + \ zed[0].foo[2] * 100 + \ @@ -157,7 +157,7 @@ def test_struct_assignment_order(get_contract, assert_compile_failed): @external @view def test2() -> uint256: - foo: Foo = Foo({b: 2, a: 297}) + foo: Foo = Foo(b=2, a=297) return foo.a """ assert_compile_failed(lambda: get_contract(code), InvalidAttribute) @@ -193,25 +193,25 @@ def test_composite_setter_test(get_contract_with_gas_estimation): @external def foo() -> int128: - self.mom = Mom({a: [C({c: 1}), C({c: 2}), C({c: 3})], b: 4}) - non: C = C({c: 5}) + self.mom = Mom(a=[C(c=1), C(c=2), C(c=3)], b=4) + non: C = C(c=5) self.mom.a[0] = non - non = C({c: 6}) + non = C(c=6) self.mom.a[2] = non return self.mom.a[0].c + self.mom.a[1].c * 10 + self.mom.a[2].c * 100 + self.mom.b * 1000 @external def fop() -> int128: - popp: Mom = Mom({a: [C({c: 1}), C({c: 2}), C({c: 3})], b: 4}) - self.qoq = C({c: 5}) + popp: Mom = Mom(a=[C(c=1), C(c=2), C(c=3)], b=4) + self.qoq = C(c=5) popp.a[0] = self.qoq - self.qoq = C({c: 6}) + self.qoq = C(c=6) popp.a[2] = self.qoq return popp.a[0].c + popp.a[1].c * 10 + popp.a[2].c * 100 + popp.b * 1000 @external def foq() -> int128: - popp: Mom = Mom({a: [C({c: 1}), C({c: 2}), C({c: 3})], b: 4}) + popp: Mom = Mom(a=[C(c=1), C(c=2), C(c=3)], b=4) popp.a[0] = empty(C) popp.a[2] = empty(C) return popp.a[0].c + popp.a[1].c * 10 + popp.a[2].c * 100 + popp.b * 1000 diff --git a/tests/functional/codegen/types/test_bytes.py b/tests/functional/codegen/types/test_bytes.py index 99e5835f6e..f8ae65cc54 100644 --- a/tests/functional/codegen/types/test_bytes.py +++ b/tests/functional/codegen/types/test_bytes.py @@ -132,7 +132,7 @@ def test_test_bytes5(get_contract_with_gas_estimation): @external def foo(inp1: Bytes[40], inp2: Bytes[45]): - self.g = G({a: inp1, b: inp2}) + self.g = G(a=inp1, b=inp2) @external def check1() -> Bytes[50]: @@ -144,17 +144,17 @@ def check2() -> Bytes[50]: @external def bar(inp1: Bytes[40], inp2: Bytes[45]) -> Bytes[50]: - h: H = H({a: inp1, b: inp2}) + h: H = H(a=inp1, b=inp2) return h.a @external def bat(inp1: Bytes[40], inp2: Bytes[45]) -> Bytes[50]: - h: H = H({a: inp1, b: inp2}) + h: H = H(a=inp1, b=inp2) return h.b @external def quz(inp1: Bytes[40], inp2: Bytes[45]): - h: H = H({a: inp1, b: inp2}) + h: H = H(a=inp1, b=inp2) self.g.a = h.a self.g.b = h.b """ diff --git a/tests/functional/codegen/types/test_dynamic_array.py b/tests/functional/codegen/types/test_dynamic_array.py index fc3223caaf..b55f07639b 100644 --- a/tests/functional/codegen/types/test_dynamic_array.py +++ b/tests/functional/codegen/types/test_dynamic_array.py @@ -1362,12 +1362,12 @@ def test_list_of_structs_lists_with_nested_lists(get_contract, tx_failed): def foo(x: uint8) -> uint8: b: DynArray[Bar[2], 2] = [ [ - Bar({a: [[x, x + 1], [x + 2, x + 3]]}), - Bar({a: [[x + 4, x +5], [x + 6, x + 7]]}) + Bar(a=[[x, x + 1], [x + 2, x + 3]]), + Bar(a=[[x + 4, x +5], [x + 6, x + 7]]) ], [ - Bar({a: [[x + 8, x + 9], [x + 10, x + 11]]}), - Bar({a: [[x + 12, x + 13], [x + 14, x + 15]]}) + Bar(a=[[x + 8, x + 9], [x + 10, x + 11]]), + Bar(a=[[x + 12, x + 13], [x + 14, x + 15]]) ], ] return b[0][0].a[0][0] + b[0][1].a[1][1] + b[1][0].a[0][1] + b[1][1].a[1][0] @@ -1503,11 +1503,11 @@ def _foo3() -> DynArray[DynArray[DynArray[uint256, 2], 2], 2]: @external def bar() -> DynArray[DynArray[DynArray[uint256, 2], 2], 2]: - foo: Foo = Foo({ - a1: self._foo(), - a2: self._foo2(), - a3: self._foo3(), - }) + foo: Foo = Foo( + a1=self._foo(), + a2=self._foo2(), + a3=self._foo3(), + ) return foo.a3 """ c = get_contract(code) @@ -1524,12 +1524,12 @@ def test_struct_of_lists_2(get_contract): @internal def _foo(x: int128) -> Foo: - f: Foo = Foo({ - b: b"hello", - da: [x, x * 2], - sa: [x + 1, x + 2, x + 3, x + 4, x + 5], - some_int: x - 1 - }) + f: Foo = Foo( + b=b"hello", + da=[x, x * 2], + sa=[x + 1, x + 2, x + 3, x + 4, x + 5], + some_int=x - 1 + ) return f @external @@ -1550,12 +1550,11 @@ def test_struct_of_lists_3(get_contract): @internal def _foo(x: int128) -> Foo: - f: Foo = Foo({ - a: [x, x * 2], - b: [0x0000000000000000000000000000000000000012], - c: [False, True, False] - - }) + f: Foo = Foo( + a=[x, x * 2], + b=[0x0000000000000000000000000000000000000012], + c=[False, True, False] + ) return f @external @@ -1577,15 +1576,15 @@ def test_nested_struct_of_lists(get_contract, assert_compile_failed, optimize): @internal def _foo() -> nestedFoo: - return nestedFoo({a1: [ + return nestedFoo(a1=[ [[3, 7], [7, 3]], [[7, 3], [3, 7]], - ]}) + ]) @internal def _foo2() -> Foo: _nF1: nestedFoo = self._foo() - return Foo({b1: [[[_nF1, _nF1], [_nF1, _nF1]], [[_nF1, _nF1], [_nF1, _nF1]]]}) + return Foo(b1=[[[_nF1, _nF1], [_nF1, _nF1]], [[_nF1, _nF1], [_nF1, _nF1]]]) @internal def _foo3(f: Foo) -> Foo: diff --git a/tests/functional/syntax/exceptions/test_variable_declaration_exception.py b/tests/functional/syntax/exceptions/test_variable_declaration_exception.py index f34c9a33c4..dc234454da 100644 --- a/tests/functional/syntax/exceptions/test_variable_declaration_exception.py +++ b/tests/functional/syntax/exceptions/test_variable_declaration_exception.py @@ -13,7 +13,7 @@ def foo() -> int128: """ struct S: x: int128 -s: S = S({x: int128}, 1) +s: S = S(x=int128, 1) """, """ struct S: diff --git a/tests/functional/syntax/test_ann_assign.py b/tests/functional/syntax/test_ann_assign.py index 7fdb1328c2..23ebeb9560 100644 --- a/tests/functional/syntax/test_ann_assign.py +++ b/tests/functional/syntax/test_ann_assign.py @@ -59,7 +59,7 @@ def data() -> int128: b: decimal @external def foo() -> int128: - s: S = S({a: 1.2, b: 1}) + s: S = S(a=1.2, b=1) return s.a """, TypeMismatch, @@ -71,7 +71,7 @@ def foo() -> int128: b: decimal @external def foo() -> int128: - s: S = S({a: 1}) + s: S = S(a=1) """, VariableDeclarationException, ), @@ -82,7 +82,7 @@ def foo() -> int128: b: decimal @external def foo() -> int128: - s: S = S({b: 1.2, a: 1}) + s: S = S(b=1.2, a=1) """, InvalidAttribute, ), @@ -93,7 +93,7 @@ def foo() -> int128: b: decimal @external def foo() -> int128: - s: S = S({a: 1, b: 1.2, c: 1, d: 33, e: 55}) + s: S = S(a=1, b=1.2, c=1, d=33, e=55) return s.a """, UnknownAttribute, diff --git a/tests/functional/syntax/test_block.py b/tests/functional/syntax/test_block.py index 8d8bffb697..aea39aa9c7 100644 --- a/tests/functional/syntax/test_block.py +++ b/tests/functional/syntax/test_block.py @@ -63,8 +63,8 @@ def add_record(): y: int128 @external def add_record(): - a: X = X({x: block.timestamp}) - b: Y = Y({y: 5}) + a: X = X(x=block.timestamp) + b: Y = Y(y=5) a.x = b.y """, """ @@ -123,7 +123,7 @@ def foo(): x: uint256 @external def add_record(): - a: X = X({x: block.timestamp}) + a: X = X(x=block.timestamp) a.x = block.gaslimit a.x = block.basefee a.x = 5 diff --git a/tests/functional/syntax/test_constants.py b/tests/functional/syntax/test_constants.py index 63abf24485..5eb9eefe25 100644 --- a/tests/functional/syntax/test_constants.py +++ b/tests/functional/syntax/test_constants.py @@ -135,7 +135,7 @@ def test(VAL: uint256): a: uint256 b: uint256 -CONST_BAR: constant(Foo) = Foo({a: 1, b: block.number}) +CONST_BAR: constant(Foo) = Foo(a=1, b=block.number) """, StateAccessViolation, ), @@ -163,7 +163,7 @@ def foo() -> uint256: struct Foo: a : uint256 -x: constant(Foo) = Foo({a: 1}) +x: constant(Foo) = Foo(a=1) @external def hello() : @@ -276,7 +276,7 @@ def deposit(deposit_input: Bytes[2048]): a: uint256 b: uint256 -CONST_BAR: constant(Foo) = Foo({a: 1, b: 2}) +CONST_BAR: constant(Foo) = Foo(a=1, b=2) """, """ CONST_EMPTY: constant(bytes32) = empty(bytes32) @@ -293,7 +293,7 @@ def foo() -> bytes32: A: constant(uint256) = 1 B: constant(uint256) = 2 -CONST_BAR: constant(Foo) = Foo({a: A, b: B}) +CONST_BAR: constant(Foo) = Foo(a=A, b=B) """, """ struct Foo: @@ -306,10 +306,10 @@ def foo() -> bytes32: A: constant(uint256) = 1 B: constant(uint256) = 2 -C: constant(Foo) = Foo({a: A, b: B}) +C: constant(Foo) = Foo(a=A, b=B) D: constant(int128) = -1 -CONST_BAR: constant(Bar) = Bar({c: C, d: D}) +CONST_BAR: constant(Bar) = Bar(c=C, d=D) """, """ interface Foo: diff --git a/tests/functional/syntax/test_flag.py b/tests/functional/syntax/test_flag.py index 22309502b7..7732ccc39f 100644 --- a/tests/functional/syntax/test_flag.py +++ b/tests/functional/syntax/test_flag.py @@ -158,10 +158,10 @@ def run() -> Action: @external def run() -> Order: - return Order({ - action: Action.BUY, - amount: 10**18 - }) + return Order( + action=Action.BUY, + amount=10**18 + ) """, "flag Foo:\n" + "\n".join([f" member{i}" for i in range(256)]), """ diff --git a/tests/functional/syntax/test_immutables.py b/tests/functional/syntax/test_immutables.py index 59fb1a69d9..7e5903a6a1 100644 --- a/tests/functional/syntax/test_immutables.py +++ b/tests/functional/syntax/test_immutables.py @@ -165,7 +165,7 @@ def report(): @deploy def __init__(): - x = Foo({a:1}) + x = Foo(a=1) @external def hello() : diff --git a/tests/functional/syntax/test_invalids.py b/tests/functional/syntax/test_invalids.py index dfc74fc75b..f4e60902ef 100644 --- a/tests/functional/syntax/test_invalids.py +++ b/tests/functional/syntax/test_invalids.py @@ -357,7 +357,7 @@ def a(): @external def a(): - x: int128 = StructX({y: 1}) + x: int128 = StructX(y=1) """, UnknownAttribute, ) diff --git a/tests/functional/syntax/test_no_none.py b/tests/functional/syntax/test_no_none.py index 085ce395ab..ebe32816bd 100644 --- a/tests/functional/syntax/test_no_none.py +++ b/tests/functional/syntax/test_no_none.py @@ -178,7 +178,7 @@ def test_struct_none(assert_compile_failed, get_contract_with_gas_estimation): @external def foo(): - mom: Mom = Mom({a: None, b: 0}) + mom: Mom = Mom(a=None, b=0) """, """ struct Mom: @@ -187,7 +187,7 @@ def foo(): @external def foo(): - mom: Mom = Mom({a: 0, b: None}) + mom: Mom = Mom(a=0, b=None) """, """ struct Mom: @@ -196,7 +196,7 @@ def foo(): @external def foo(): - mom: Mom = Mom({a: None, b: None}) + mom: Mom = Mom(a=None, b=None) """, ] diff --git a/tests/functional/syntax/test_structs.py b/tests/functional/syntax/test_structs.py index 4fad35d1d4..1b7846d53d 100644 --- a/tests/functional/syntax/test_structs.py +++ b/tests/functional/syntax/test_structs.py @@ -4,14 +4,14 @@ from vyper.exceptions import ( InstantiationException, StructureException, + SyntaxException, TypeMismatch, UnknownAttribute, VariableDeclarationException, ) fail_list = [ - ( - """ + """ struct A: x: int128 a: A @@ -19,8 +19,6 @@ def foo(): self.a = A(1) """, - VariableDeclarationException, - ), ( """ struct A: @@ -28,24 +26,20 @@ def foo(): a: A @external def foo(): - self.a = A({x: 1, y: 2}) + self.a = A(x=1, y=2) """, UnknownAttribute, ), - ( - """ + """ struct A: x: int128 y: int128 a: A @external def foo(): - self.a = A({x: 1}) + self.a = A(x=1) """, - VariableDeclarationException, - ), - ( - """ + """ struct A: x: int128 struct B: @@ -56,10 +50,7 @@ def foo(): def foo(): self.a = A(self.b) """, - VariableDeclarationException, - ), - ( - """ + """ struct A: x: int128 a: A @@ -68,10 +59,7 @@ def foo(): def foo(): self.a = A(self.b) """, - VariableDeclarationException, - ), - ( - """ + """ struct A: x: int128 y: int128 @@ -80,10 +68,7 @@ def foo(): def foo(): self.a = A({x: 1}) """, - VariableDeclarationException, - ), - ( - """ + """ struct C: c: int128 struct Mom: @@ -98,8 +83,6 @@ def foo(): def foo(): self.nom = Nom(self.mom) """, - VariableDeclarationException, - ), """ struct C1: c: int128 @@ -251,7 +234,7 @@ def foo(): nom: C[3] @external def foo(): - self.mom = Mom({a: self.nom, b: 5.5}) + self.mom = Mom(a=self.nom, b=5.5) """, TypeMismatch, ), @@ -268,7 +251,7 @@ def foo(): nom: C2[3] @external def foo(): - self.mom = Mom({a: self.nom, b: 5}) + self.mom = Mom(a=self.nom, b=5) """, TypeMismatch, ), @@ -285,7 +268,7 @@ def foo(): nom: C[3] @external def foo(): - self.mom = Mom({a: self.nom, b: self.nom}) + self.mom = Mom(a=self.nom, b=self.nom) """, TypeMismatch, ), @@ -329,7 +312,7 @@ def foo(): nom: C2[3] @external def foo(): - self.mom = Mom({a: self.nom, b: 5}) + self.mom = Mom(a=self.nom, b=5) """, TypeMismatch, ), @@ -342,9 +325,9 @@ def foo(): bar: int128[3] @external def foo(): - self.bar = Bar({0: 5, 1: 7, 2: 9}) + self.bar = Bar(0=5, 1=7, 2=9) """, - UnknownAttribute, + SyntaxException, ), ( """ @@ -355,7 +338,7 @@ def foo(): bar: int128[3] @external def foo(): - self.bar = Bar({a: 5, b: 7, c: 9}) + self.bar = Bar(a=5, b=7, c=9) """, TypeMismatch, ), @@ -366,7 +349,7 @@ def foo(): dog: int128 @external def foo() -> int128: - f: Farm = Farm({cow: 5, dog: 7}) + f: Farm = Farm(cow=5, dog=7) return f """, TypeMismatch, @@ -390,7 +373,7 @@ def foo(): b: B @external def foo(): - self.b = B({foo: 1, foo: 2}) + self.b = B(foo=1, foo=2) """, UnknownAttribute, ), @@ -425,7 +408,7 @@ def foo(): @external def foo(): - Foo({a: 1}) + Foo(a=1) """, StructureException, ), @@ -439,6 +422,15 @@ def foo(): """, InstantiationException, ), + # valid syntax in versions <0.4.0 + """ +struct A: + x: int128 +a: A +@external +def foo(): + self.a = A({x: 1, y: 2}) + """, ] @@ -459,7 +451,7 @@ def test_block_fail(bad_code): a: A @external def foo(): - self.a = A({x: 1}) + self.a = A(x=1) """, """ struct C: @@ -482,7 +474,7 @@ def foo(): nom: C[3] @external def foo(): - mom: Mom = Mom({a:[C({c:0}), C({c:0}), C({c:0})], b: 0}) + mom: Mom = Mom(a=[C(c=0), C(c=0), C(c=0)], b=0) mom.a = self.nom """, """ @@ -495,7 +487,7 @@ def foo(): nom: C[3] @external def foo(): - self.mom = Mom({a: self.nom, b: 5}) + self.mom = Mom(a=self.nom, b=5) """, """ struct C: @@ -507,7 +499,7 @@ def foo(): nom: C[3] @external def foo(): - self.mom = Mom({a: self.nom, b: 5}) + self.mom = Mom(a=self.nom, b=5) """, """ struct C: @@ -518,8 +510,8 @@ def foo(): mom: Mom @external def foo(): - nom: C[3] = [C({c:0}), C({c:0}), C({c:0})] - self.mom = Mom({a: nom, b: 5}) + nom: C[3] = [C(c=0), C(c=0), C(c=0)] + self.mom = Mom(a=nom, b=5) """, """ struct B: @@ -548,7 +540,7 @@ def foo(): d: bool @external def get_y() -> int128: - return C({c: A({a: X({x: 1, y: -1}), b: 777}), d: True}).c.a.y - 10 + return C(c=A(a=X(x=1, y=-1), b=777), d=True).c.a.y - 10 """, """ struct X: @@ -560,7 +552,7 @@ def get_y() -> int128: struct C: c: A d: bool -FOO: constant(C) = C({c: A({a: X({x: 1, y: -1}), b: 777}), d: True}) +FOO: constant(C) = C(c=A(a=X(x=1, y=-1), b=777), d=True) @external def get_y() -> int128: return FOO.c.a.y - 10 @@ -572,7 +564,7 @@ def get_y() -> int128: @external def foo(): - bar: C = C({a: 1, b: block.timestamp}) + bar: C = C(a=1, b=block.timestamp) """, ] diff --git a/tests/unit/cli/vyper_compile/test_compile_files.py b/tests/unit/cli/vyper_compile/test_compile_files.py index 6adee24db6..bc99b07a8e 100644 --- a/tests/unit/cli/vyper_compile/test_compile_files.py +++ b/tests/unit/cli/vyper_compile/test_compile_files.py @@ -38,7 +38,7 @@ def test_invalid_root_path(): @external def foo() -> {alias}.FooStruct: - return {alias}.FooStruct({{foo_: 13}}) + return {alias}.FooStruct(foo_=13) @external def bar(a: address) -> {alias}.FooStruct: @@ -176,7 +176,7 @@ def know_thyself(a: address) -> ISelf.FooStruct: @external def be_known() -> ISelf.FooStruct: - return ISelf.FooStruct({{foo_: 42}}) + return ISelf.FooStruct(foo_=42) """ make_file("contracts/ISelf.vyi", interface_code) meta = make_file("contracts/Self.vy", code) diff --git a/tests/unit/semantics/analysis/test_for_loop.py b/tests/unit/semantics/analysis/test_for_loop.py index c97c9c095e..bc4ae1a2f7 100644 --- a/tests/unit/semantics/analysis/test_for_loop.py +++ b/tests/unit/semantics/analysis/test_for_loop.py @@ -171,7 +171,7 @@ def test_modify_iterator_through_struct(dummy_input_bundle): def foo(): self.a.iter = [1, 2, 3] for i: uint256 in self.a.iter: - self.a = A({iter: [1, 2, 3, 4]}) + self.a = A(iter=[1, 2, 3, 4]) """ vyper_module = parse_to_ast(code) with pytest.raises(ImmutableViolation) as e: diff --git a/tests/unit/semantics/test_storage_slots.py b/tests/unit/semantics/test_storage_slots.py index 1dc70fd1ba..7cbe71cf29 100644 --- a/tests/unit/semantics/test_storage_slots.py +++ b/tests/unit/semantics/test_storage_slots.py @@ -27,19 +27,19 @@ @deploy def __init__(): - self.a = StructOne({a: "ok", b: [4,5,6]}) + self.a = StructOne(a="ok", b=[4,5,6]) self.b = [7, 8] self.c = b"thisisthirtytwobytesokhowdoyoudo" self.d = [-1, -2, -3, -4] self.e = "A realllllly long string but we won't use it all" self.f = [33] self.g = [ - StructTwo({a: b"hello", b: [-66, 420], c: "another string"}), - StructTwo({ - a: b"gbye", - b: [1337, 888], - c: "whatifthisstringtakesuptheentirelengthwouldthatbesobadidothinkso" - }) + StructTwo(a=b"hello", b=[-66, 420], c="another string"), + StructTwo( + a=b"gbye", + b=[1337, 888], + c="whatifthisstringtakesuptheentirelengthwouldthatbesobadidothinkso" + ) ] self.dyn_array = [1, 2, 3] self.h = [123456789]