Skip to content

Commit

Permalink
Add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
InversionSpaces committed Jul 27, 2023
1 parent c561d8a commit 882cff3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 17 deletions.
26 changes: 15 additions & 11 deletions integration-tests/aqua/examples/boolAlgebra.aqua
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,22 @@ func main(peer: string) -> []bool:
on peer:
a = 1 + 2
b = 2 - 1
res <<- true || false && true
res <<- (true || false) && true
res <<- foo(3) && b > 0 || a > 4
res <<- bar(a) > 2 || true
res <<- foo(4) && bar(2) < 2
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")
res <<- false && Effector.effect("impossible")
res <<- foo(0) || Effector.effect("impossible")
res <<- foo(10) && Effector.effect("impossible")
res <<- Effector.effect("true") || true
res <<- Effector.effect("true") && false
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
18 changes: 17 additions & 1 deletion integration-tests/src/__test__/examples.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,23 @@ describe('Testing examples', () => {

it('boolAlgebra.aqua', async () => {
let boolAlgebraResult = await boolAlgebraCall(relayPeerId1);
expect(boolAlgebraResult).toEqual([true, true, true, true, false, true, false, true, false, true, false]);
expect(boolAlgebraResult).toEqual([
true,
true,
true,
true,
false,
true,
true,
true,
false,
true,
false,
true,
false,
true,
false,
]);
});

it('join.aqua local', async () => {
Expand Down
9 changes: 4 additions & 5 deletions integration-tests/src/examples/boolAlgebra.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {main, registerEffector} from "../compiled/examples/boolAlgebra.js";
import { main, registerEffector } from '../compiled/examples/boolAlgebra.js';

export async function boolAlgebraCall(relay: string): Promise<boolean[]> {
registerEffector({
effect(name, _) {
console.log(`effect: ${name}`);
if (name == "true") return Promise.resolve(true);
else return Promise.reject(`unknown effect: ${name}`)
if (name == 'true') return Promise.resolve(true);
else return Promise.reject(`unknown effect: ${name}`);
},
});

return await main(relay);
}
}

0 comments on commit 882cff3

Please sign in to comment.