1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00

Merge pull request #487 from petscheit/precedence_test

Adds Precedence Test
This commit is contained in:
Thibaut Schaeffer 2019-10-03 12:58:43 +02:00 committed by GitHub
commit 595866ee8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 253 additions and 214 deletions

432
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,19 @@
{
"entry_point": "./tests/tests/precedence.zok",
"tests": [
{
"input": {
"values": [
"12"
]
},
"output": {
"Ok": {
"values": [
"12"
]
}
}
}
]
}

View 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