test for multiple abilities with closure

This commit is contained in:
DieMyst 2023-10-25 17:58:36 +07:00
parent e3386bf98d
commit a7cd90f589
3 changed files with 30 additions and 6 deletions

View File

@ -2,7 +2,7 @@ aqua Main
use DECLARE_CONST, decl_bar from "imports_exports/declare.aqua" as Declare 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"): service SomeService("wed"):
getStr(s: string) -> string getStr(s: string) -> string
@ -114,4 +114,18 @@ func bugLNG258_3() -> i8, i8:
res1, res2 <- aB.inner.arrow() res1, res2 <- aB.inner.arrow()
<- res1, res2 <- 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()

View File

@ -33,7 +33,7 @@ import {
import { import {
abilityCall, abilityCall,
complexAbilityCall, complexAbilityCall,
checkAbCallsCall, bugLNG258Call1, bugLNG258Call2, bugLNG258Call3, checkAbCallsCall, bugLNG258Call1, bugLNG258Call2, bugLNG258Call3, multipleAbilityWithClosureCall,
} from "../examples/abilityCall.js"; } from "../examples/abilityCall.js";
import { import {
nilLengthCall, nilLengthCall,
@ -533,7 +533,7 @@ describe("Testing examples", () => {
}); });
}); });
it("ability.aqua", async () => { it("abilities.aqua", async () => {
let result = await abilityCall(); let result = await abilityCall();
expect(result).toStrictEqual([ expect(result).toStrictEqual([
"declare_const123", "declare_const123",
@ -543,17 +543,17 @@ describe("Testing examples", () => {
]); ]);
}); });
it("ability.aqua complex", async () => { it("abilities.aqua complex", async () => {
let result = await complexAbilityCall(); let result = await complexAbilityCall();
expect(result).toStrictEqual([false, true]); expect(result).toStrictEqual([false, true]);
}); });
it("ability.aqua ability calls", async () => { it("abilities.aqua ability calls", async () => {
let result = await checkAbCallsCall(); let result = await checkAbCallsCall();
expect(result).toStrictEqual([true, false, true]); expect(result).toStrictEqual([true, false, true]);
}); });
it("ability.aqua bug LNG-258", async () => { it("abilities.aqua bug LNG-258", async () => {
let result1 = await bugLNG258Call1(); let result1 = await bugLNG258Call1();
expect(result1).toStrictEqual([1, 2]); expect(result1).toStrictEqual([1, 2]);
@ -564,6 +564,11 @@ describe("Testing examples", () => {
expect(result3).toStrictEqual([5, 6]); 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 () => { it("functors.aqua LNG-119 bug", async () => {
let result = await bugLng119Call(); let result = await bugLng119Call();
expect(result).toEqual([1]); expect(result).toEqual([1]);

View File

@ -6,6 +6,7 @@ import {
bugLNG258_1, bugLNG258_1,
bugLNG258_2, bugLNG258_2,
bugLNG258_3, bugLNG258_3,
multipleAbilityWithClosure
} from "../compiled/examples/abilities"; } from "../compiled/examples/abilities";
export async function abilityCall(): Promise<[string, string, string, number]> { 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]> { export async function bugLNG258Call3(): Promise<[number, number]> {
return await bugLNG258_3(); return await bugLNG258_3();
} }
export async function multipleAbilityWithClosureCall(): Promise<[number, number]> {
return await multipleAbilityWithClosure()
}