From e3386bf98d3dbf2672a38cab04df6521dfa574e3 Mon Sep 17 00:00:00 2001 From: DieMyst Date: Wed, 25 Oct 2023 17:41:09 +0700 Subject: [PATCH] add test --- aqua-src/antithesis.aqua | 18 +++++++++--------- integration-tests/aqua/examples/closures.aqua | 14 ++++++++++++-- .../src/__test__/examples.spec.ts | 7 ++++++- integration-tests/src/examples/closures.ts | 5 +++++ 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/aqua-src/antithesis.aqua b/aqua-src/antithesis.aqua index c0dd4cde..f29459c0 100644 --- a/aqua-src/antithesis.aqua +++ b/aqua-src/antithesis.aqua @@ -2,15 +2,15 @@ aqua A export bugLNG260 --- func create(a: i8) -> -> i8: --- closureArrow = () -> i8: --- <- a --- <- closureArrow --- --- func test() -> i8, i8: --- arr1 <- create(1) --- arr2 <- create(2) --- <- arr1(), arr2() +func create(a: i8) -> -> i8: + closureArrow = () -> i8: + <- a + <- closureArrow + +func test() -> i8, i8: + arr1 <- create(1) + arr2 <- create(2) + <- arr1(), arr2() func cmp(a: i32, b: i32, pred: i8 -> bool) -> bool: result: ?bool diff --git a/integration-tests/aqua/examples/closures.aqua b/integration-tests/aqua/examples/closures.aqua index d21da611..867d2751 100644 --- a/integration-tests/aqua/examples/closures.aqua +++ b/integration-tests/aqua/examples/closures.aqua @@ -2,7 +2,7 @@ module Closure declares * import "@fluencelabs/aqua-lib/builtin.aqua" -export LocalSrv, closureIn, closureOut, closureBig, closureOut2, lng58Bug +export LocalSrv, closureIn, closureOut, closureBig, closureOut2, lng58Bug, multipleClosuresBugLNG262 service MyOp("op"): identity(s: string) -> string @@ -70,4 +70,14 @@ func lng58Bug() -> string: waiting() - <- status! \ No newline at end of file + <- status! + +func create(a: i8) -> -> i8: + closureArrow = () -> i8: + <- a + <- closureArrow + +func multipleClosuresBugLNG262() -> i8, i8: + arr1 <- create(1) + arr2 <- create(2) + <- arr1(), arr2() \ No newline at end of file diff --git a/integration-tests/src/__test__/examples.spec.ts b/integration-tests/src/__test__/examples.spec.ts index 1e10c89c..3bb54b49 100644 --- a/integration-tests/src/__test__/examples.spec.ts +++ b/integration-tests/src/__test__/examples.spec.ts @@ -104,7 +104,7 @@ import { multiReturnCall } from "../examples/multiReturnCall.js"; import { declareCall } from "../examples/declareCall.js"; import { genOptions, genOptionsEmptyString } from "../examples/optionsCall.js"; import { lng193BugCall } from "../examples/closureReturnRename.js"; -import { closuresCall } from "../examples/closures.js"; +import {closuresCall, multipleClosuresLNG262BugCall} from "../examples/closures.js"; import { closureArrowCaptureCall } from "../examples/closureArrowCapture.js"; import { bugLNG63_2Call, @@ -949,6 +949,11 @@ describe("Testing examples", () => { expect(closuresResult).toEqual(["in", res1, res1, res2]); }, 20000); + it("closures.aqua bug LNG-262", async () => { + let result = await multipleClosuresLNG262BugCall(); + expect(result).toEqual([1, 2]); + }); + it("closureArrowCapture.aqua", async () => { let result = await closureArrowCaptureCall("input"); expect(result).toEqual("call: ".repeat(4) + "input"); diff --git a/integration-tests/src/examples/closures.ts b/integration-tests/src/examples/closures.ts index 6efe8f07..ba516190 100644 --- a/integration-tests/src/examples/closures.ts +++ b/integration-tests/src/examples/closures.ts @@ -5,6 +5,7 @@ import { registerLocalSrv, closureOut2, lng58Bug, + multipleClosuresBugLNG262 } from "../compiled/examples/closures.js"; import { config } from "../config.js"; @@ -32,3 +33,7 @@ export async function closuresCall(): Promise< export async function lng58CBugCall(): Promise { return lng58Bug(); } + +export async function multipleClosuresLNG262BugCall(): Promise<[number, number]> { + return multipleClosuresBugLNG262(); +}