Skip to content

Commit

Permalink
Add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
InversionSpaces committed Aug 1, 2023
1 parent 3a0266d commit ff5eafd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
16 changes: 15 additions & 1 deletion integration-tests/aqua/examples/boolAlgebra.aqua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
aqua Bool

export main, Effector
export main, compareStreams, Effector

service Effector("effector"):
effect(name: string) -> bool
Expand All @@ -13,6 +13,16 @@ func bar(x: i8) -> i8:
y = x - 1
<- y

func compareStreams(peer: string) -> bool:
s1: *i8
s2: *i8

on peer:
s1 <<- bar(43)
s2 <<- bar(43)

<- s1 == s2

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

Expand All @@ -26,6 +36,8 @@ func main(peer: string) -> []bool:
res <<- foo(4) && bar(2) < 2 -- false
res <<- !foo(10) && !!true -- true
res <<- !(bar(2) < 1) || !!(a < 2) -- true
res <<- bar(42) == bar(40 + 2) && foo(10) -- false
res <<- bar(2) < 5 || bar(2) != 1 -- true

-- Effector is only registered on init_peer
res <<- true || Effector.effect("impossible") -- true
Expand All @@ -36,5 +48,7 @@ func main(peer: string) -> []bool:
res <<- Effector.effect("true") && false -- false
res <<- !foo(10) || Effector.effect("impossible") -- true
res <<- !(1 < 2) && !Effector.effect("impossible") -- false
res <<- !(bar(5) == 5) || Effector.effect("impossible") -- true
res <<- bar(5) != 4 && Effector.effect("impossible") -- false

<- res
11 changes: 10 additions & 1 deletion integration-tests/src/__test__/examples.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { registerHandlers, returnNull, returnOptionalCall, useOptionalCall } fro
import { viaArrCall, viaOptCall, viaOptNullCall, viaStreamCall } from '../examples/viaCall.js';
import { nestedFuncsCall } from '../examples/nestedFuncsCall.js';
import { assignmentCall } from '../examples/assignment.js';
import { boolAlgebraCall } from '../examples/boolAlgebra.js';
import { boolAlgebraCall, compareStreamsCall } from '../examples/boolAlgebra.js';
import { tryCatchCall } from '../examples/tryCatchCall.js';
import { tryOtherwiseCall } from '../examples/tryOtherwiseCall.js';
import { coCall } from '../examples/coCall.js';
Expand Down Expand Up @@ -404,6 +404,10 @@ describe('Testing examples', () => {
false,
true,
true,
false,
true,
true,
false,
true,
false,
true,
Expand All @@ -415,6 +419,11 @@ describe('Testing examples', () => {
]);
});

it('boolAlgebra.aqua compareStreams', async () => {
let result = await compareStreamsCall(relayPeerId1);
expect(result).toEqual(true);
});

it('join.aqua local', async () => {
let joinLocalCallResult = await joinIdxLocalCall(relayPeerId1);
expect(joinLocalCallResult.length).toBeGreaterThanOrEqual(2);
Expand Down
6 changes: 5 additions & 1 deletion integration-tests/src/examples/boolAlgebra.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { main, registerEffector } from '../compiled/examples/boolAlgebra.js';
import { main, compareStreams, registerEffector } from '../compiled/examples/boolAlgebra.js';

export async function boolAlgebraCall(relay: string): Promise<boolean[]> {
registerEffector({
Expand All @@ -10,3 +10,7 @@ export async function boolAlgebraCall(relay: string): Promise<boolean[]> {

return await main(relay);
}

export async function compareStreamsCall(relay: string): Promise<boolean> {
return await compareStreams(relay);
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class TypesInterpreter[S[_], X](implicit
if ScalarType.number(lst) && ScalarType.number(rst) =>
true
// Hack: u64 `U` LiteralType.signed = TopType,
// but they shoudl be comparable
// but they should be comparable
case (lst: ScalarType, LiteralType.signed) if ScalarType.number(lst) =>
true
case (LiteralType.signed, rst: ScalarType) if ScalarType.number(rst) =>
Expand Down

0 comments on commit ff5eafd

Please sign in to comment.