Merge pull request #849 from Zokrates/fix-complex-type-side-effects
More complete test for pass by value
This commit is contained in:
commit
27cd2a9b0b
3 changed files with 21 additions and 13 deletions
|
@ -1,14 +1,14 @@
|
||||||
{
|
{
|
||||||
"entry_point": "./tests/tests/structs/mutate_argument.zok",
|
"entry_point": "./tests/tests/pass_by_value.zok",
|
||||||
"curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"],
|
"curves": ["Bn128", "Bls12_381", "Bls12_377", "Bw6_761"],
|
||||||
"tests": [
|
"tests": [
|
||||||
{
|
{
|
||||||
"input": {
|
"input": {
|
||||||
"values": ["1"]
|
"values": ["1", "1", "1"]
|
||||||
},
|
},
|
||||||
"output": {
|
"output": {
|
||||||
"Ok": {
|
"Ok": {
|
||||||
"values": ["2", "1"]
|
"values": ["2", "1", "2", "1", "2", "1"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
18
zokrates_core_test/tests/tests/pass_by_value.zok
Normal file
18
zokrates_core_test/tests/tests/pass_by_value.zok
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
struct Foo {
|
||||||
|
field a
|
||||||
|
}
|
||||||
|
|
||||||
|
def mutate(field a) -> field:
|
||||||
|
a = a + 1
|
||||||
|
return a
|
||||||
|
|
||||||
|
def mutate(Foo f) -> Foo:
|
||||||
|
f.a = f.a + 1
|
||||||
|
return f
|
||||||
|
|
||||||
|
def mutate(field[1] f) -> field[1]:
|
||||||
|
f[0] = f[0] + 1
|
||||||
|
return f
|
||||||
|
|
||||||
|
def main(field[1] f, Foo g, field h) -> (field[1], field[1], Foo, Foo, field, field):
|
||||||
|
return mutate(f), f, mutate(g), g, mutate(h), h
|
|
@ -1,10 +0,0 @@
|
||||||
struct Foo {
|
|
||||||
field a
|
|
||||||
}
|
|
||||||
|
|
||||||
def mutate(field[1] f) -> field[1]:
|
|
||||||
f[0] = f[0] + 1
|
|
||||||
return f
|
|
||||||
|
|
||||||
def main(field[1] f) -> (field[1], field[1]):
|
|
||||||
return mutate(f), f
|
|
Loading…
Reference in a new issue