Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(compiler): Add boolean algebra [fixes LNG-211] #814

Merged
merged 16 commits into from
Jul 27, 2023
File renamed without changes.
40 changes: 40 additions & 0 deletions integration-tests/aqua/examples/boolAlgebra.aqua
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
aqua Bool

export main, Effector

service Effector("effector"):
effect(name: string) -> bool

func foo(x: i8) -> bool:
y = x + 1
<- y < 5

func bar(x: i8) -> i8:
y = x - 1
<- y

func main(peer: string) -> []bool:
res: *bool

on peer:
a = 1 + 2
b = 2 - 1
res <<- true || false && true -- true
res <<- (true || false) && true -- true
res <<- foo(3) && b > 0 || a > 4 -- true
res <<- bar(a) > 2 || true -- true
res <<- foo(4) && bar(2) < 2 -- false
res <<- !foo(10) && !!true -- true
res <<- !(bar(2) < 1) || !!(a < 2) -- true

-- Effector is only registered on init_peer
res <<- true || Effector.effect("impossible") -- true
res <<- !!false && Effector.effect("impossible") -- false
res <<- foo(0) || Effector.effect("impossible") -- true
res <<- foo(10) && Effector.effect("impossible") -- false
res <<- Effector.effect("true") || true -- true
res <<- Effector.effect("true") && false -- false
res <<- !foo(10) || Effector.effect("impossible") -- true
res <<- !(1 < 2) && !Effector.effect("impossible") -- false

<- res
Loading
Loading