Merge pull request #487 from petscheit/precedence_test
Adds Precedence Test
This commit is contained in:
commit
595866ee8f
3 changed files with 253 additions and 214 deletions
432
Cargo.lock
generated
432
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
19
zokrates_core_test/tests/tests/precedence.json
Normal file
19
zokrates_core_test/tests/tests/precedence.json
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"entry_point": "./tests/tests/precedence.zok",
|
||||
"tests": [
|
||||
{
|
||||
"input": {
|
||||
"values": [
|
||||
"12"
|
||||
]
|
||||
},
|
||||
"output": {
|
||||
"Ok": {
|
||||
"values": [
|
||||
"12"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
16
zokrates_core_test/tests/tests/precedence.zok
Normal file
16
zokrates_core_test/tests/tests/precedence.zok
Normal file
|
@ -0,0 +1,16 @@
|
|||
def main(field g) -> (field):
|
||||
9 == 1 + 2 * 2 ** 2 // Checks precedence of arithmetic operators (expecting transitiv behaviour)
|
||||
9 == 2 ** 2 * 2 + 1
|
||||
7 == 2 ** 2 * 2 - 1
|
||||
3 == 2 ** 2 / 2 + 1
|
||||
|
||||
field a = if 3 == 2 ** 2 / 2 + 1 && true then 1 else 0 fi // combines arithmetic with boolean operators
|
||||
field b = if 3 == 3 && 4 < 5 then 1 else 0 fi // checks precedence of boolean operators
|
||||
field c = if 4 < 5 && 3 == 3 then 1 else 0 fi
|
||||
field d = if 4 > 5 && 2 >= 1 || 1 == 1 then 1 else 0 fi
|
||||
field e = if 2 >= 1 && 4 > 5 || 1 == 1 then 1 else 0 fi
|
||||
field f = if 1 < 2 && false || 4 < 5 && 2 >= 1 then 1 else 0 fi
|
||||
|
||||
//check if all statements have evalutated to true
|
||||
a * b * c * d * e * f == 1
|
||||
return g
|
Loading…
Reference in a new issue