Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
InversionSpaces committed Sep 27, 2023
1 parent 7310ec8 commit 50f4f77
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
39 changes: 39 additions & 0 deletions integration-tests/aqua/examples/ifPropagateErrors.aqua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
aqua IfPropagateErrors

export ifPropagateErrors, TestService

service TestService("test-srv"):
call(s: string) -> string

func ifPropagateErrors() -> []string:
stream: *string

a <- TestService.call("a")
b <- TestService.call("b")

try:
if a == b || a == "a": -- true
stream <- TestService.call("fail1")
else:
stream <- TestService.call("else1")
otherwise:
stream <- TestService.call("otherwise1")

try:
if a != b: -- true
stream <- TestService.call("fail2")
otherwise:
stream <- TestService.call("otherwise2")

try:
if b == "b": --true
if a == "a": -- true
stream <- TestService.call("fail3")
else:
stream <- TestService.call("else3")
else:
stream <- TestService.call("else4")
otherwise:
stream <- TestService.call("otherwise3")

<- stream
6 changes: 6 additions & 0 deletions integration-tests/src/__test__/examples.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { registerPrintln } from "../compiled/examples/println.js";
import { helloWorldCall } from "../examples/helloWorldCall.js";
import { foldBug499Call, foldCall } from "../examples/foldCall.js";
import { bugNG69Call, ifCall, ifWrapCall } from "../examples/ifCall.js";
import { ifPropagateErrorsCall } from "../examples/ifPropagateErrors.js";
import { parCall, testTimeoutCall } from "../examples/parCall.js";
import { complexCall } from "../examples/complex.js";
import {
Expand Down Expand Up @@ -269,6 +270,11 @@ describe("Testing examples", () => {
expect(res).toBe(true);
});

it("ifPropagateErrors.aqua", async () => {
let res = await ifPropagateErrorsCall();
expect(res).toBe([1, 2, 3].flatMap((i) => ["fail" + i, "otherwise" + i]));
});

it("helloWorld.aqua", async () => {
let helloWorldResult = await helloWorldCall();
expect(helloWorldResult).toBe("Hello, NAME!");
Expand Down
15 changes: 15 additions & 0 deletions integration-tests/src/examples/ifPropagateErrors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {
ifPropagateErrors,
registerTestService,
} from "../compiled/examples/ifPropagateErrors.js";

export async function ifPropagateErrorsCall() {
registerTestService({
call: (s) => {
if (s == "fail") return Promise.reject("fail");
else return Promise.resolve(s);
},
});

return await ifPropagateErrors();
}

0 comments on commit 50f4f77

Please sign in to comment.