1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00
ZoKrates/zokrates_core_test/tests/tests/precedence.zok

20 lines
858 B
Text

def main():
assert(9 == 1 + 2 * 2 ** 2) // Checks precedence of arithmetic operators (expecting transitive behaviour)
assert(9 == 2 ** 2 * 2 + 1)
assert(7 == 2 ** 2 * 2 - 1)
assert(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
assert(0x00 ^ 0x00 == 0x00)
assert(0 - 2 ** 2 == -4)
//check if all statements have evalutated to true
assert(a * b * c * d * e * f == 1)
return