Skip to content

Commit

Permalink
feat(compiler): Add boolean algebra [fixes LNG-211] (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
InversionSpaces authored Jul 27, 2023
1 parent fabf8d7 commit a5b6102
Show file tree
Hide file tree
Showing 24 changed files with 1,311 additions and 448 deletions.
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

0 comments on commit a5b6102

Please sign in to comment.