From a7cd90f58940653db7361526f246a5131faacdfa Mon Sep 17 00:00:00 2001 From: DieMyst Date: Wed, 25 Oct 2023 17:58:36 +0700 Subject: [PATCH] test for multiple abilities with closure --- integration-tests/aqua/examples/abilities.aqua | 16 +++++++++++++++- integration-tests/src/__test__/examples.spec.ts | 15 ++++++++++----- integration-tests/src/examples/abilityCall.ts | 5 +++++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/integration-tests/aqua/examples/abilities.aqua b/integration-tests/aqua/examples/abilities.aqua index 25283366..83717475 100644 --- a/integration-tests/aqua/examples/abilities.aqua +++ b/integration-tests/aqua/examples/abilities.aqua @@ -2,7 +2,7 @@ aqua Main use DECLARE_CONST, decl_bar from "imports_exports/declare.aqua" as Declare -export handleAb, SomeService, bug214, checkAbCalls, bugLNG258_1, bugLNG258_2, bugLNG258_3 +export handleAb, SomeService, bug214, checkAbCalls, bugLNG258_1, bugLNG258_2, bugLNG258_3, multipleAbilityWithClosure service SomeService("wed"): getStr(s: string) -> string @@ -114,4 +114,18 @@ func bugLNG258_3() -> i8, i8: res1, res2 <- aB.inner.arrow() <- res1, res2 +ability TestAb: + arrow: -> i8 + +func create(a: i8) -> TestAb: + closureArrow = () -> i8: + <- a + ab = TestAb(arrow = closureArrow) + <- ab + +func multipleAbilityWithClosure() -> i8, i8: + ab <- create(1) + ab2 <- create(2) + <- ab.arrow(), ab2.arrow() + diff --git a/integration-tests/src/__test__/examples.spec.ts b/integration-tests/src/__test__/examples.spec.ts index 3bb54b49..13cb6972 100644 --- a/integration-tests/src/__test__/examples.spec.ts +++ b/integration-tests/src/__test__/examples.spec.ts @@ -33,7 +33,7 @@ import { import { abilityCall, complexAbilityCall, - checkAbCallsCall, bugLNG258Call1, bugLNG258Call2, bugLNG258Call3, + checkAbCallsCall, bugLNG258Call1, bugLNG258Call2, bugLNG258Call3, multipleAbilityWithClosureCall, } from "../examples/abilityCall.js"; import { nilLengthCall, @@ -533,7 +533,7 @@ describe("Testing examples", () => { }); }); - it("ability.aqua", async () => { + it("abilities.aqua", async () => { let result = await abilityCall(); expect(result).toStrictEqual([ "declare_const123", @@ -543,17 +543,17 @@ describe("Testing examples", () => { ]); }); - it("ability.aqua complex", async () => { + it("abilities.aqua complex", async () => { let result = await complexAbilityCall(); expect(result).toStrictEqual([false, true]); }); - it("ability.aqua ability calls", async () => { + it("abilities.aqua ability calls", async () => { let result = await checkAbCallsCall(); expect(result).toStrictEqual([true, false, true]); }); - it("ability.aqua bug LNG-258", async () => { + it("abilities.aqua bug LNG-258", async () => { let result1 = await bugLNG258Call1(); expect(result1).toStrictEqual([1, 2]); @@ -564,6 +564,11 @@ describe("Testing examples", () => { expect(result3).toStrictEqual([5, 6]); }); + it("abilities.aqua multiple abilities with closures", async () => { + let result1 = await multipleAbilityWithClosureCall(); + expect(result1).toStrictEqual([1, 2]); + }); + it("functors.aqua LNG-119 bug", async () => { let result = await bugLng119Call(); expect(result).toEqual([1]); diff --git a/integration-tests/src/examples/abilityCall.ts b/integration-tests/src/examples/abilityCall.ts index 415adaad..32b81e96 100644 --- a/integration-tests/src/examples/abilityCall.ts +++ b/integration-tests/src/examples/abilityCall.ts @@ -6,6 +6,7 @@ import { bugLNG258_1, bugLNG258_2, bugLNG258_3, + multipleAbilityWithClosure } from "../compiled/examples/abilities"; export async function abilityCall(): Promise<[string, string, string, number]> { @@ -37,3 +38,7 @@ export async function bugLNG258Call2(): Promise<[number, number]> { export async function bugLNG258Call3(): Promise<[number, number]> { return await bugLNG258_3(); } + +export async function multipleAbilityWithClosureCall(): Promise<[number, number]> { + return await multipleAbilityWithClosure() +}