feat(examples): Add return closure rename example [fixes LNG-193] (#84)

This commit is contained in:
InversionSpaces 2023-06-13 11:57:32 +02:00 committed by GitHub
parent 4db5b3a171
commit 01c62d7a00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,15 @@
export lng193Bug
func getClosure(arg: u16, peer: string) -> u16 -> u16:
on peer:
closure = (x: u16) -> u16:
<- arg + x
<- closure
func lng193Bug(peer: string, closurePeer: string) -> u16:
on peer:
c = getClosure(42, closurePeer)
b = c
a = b
res = a(1) + b(2) + c(3)
<- res

View File

@ -38,6 +38,7 @@ import {literalCall} from '../examples/returnLiteralCall.js';
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 {bugLNG63_2Call, bugLNG63_3Call, bugLNG63Call, streamCanCall} from '../examples/streamCanCall.js';
import {streamCallbackCall} from '../examples/streamCallback.js';
@ -527,6 +528,11 @@ describe('Testing examples', () => {
expect(res3).toEqual(res4);
}, 180000);
it('closureReturnRename.aqua bug LNG-193', async () => {
let result = await lng193BugCall();
expect(result).toEqual(1 + 42 + 2 + 42 + 3 + 42)
}, 20000)
it('closures.aqua', async () => {
let closuresResult = await closuresCall();
let res1 = config.externalAddressesRelay2;

View File

@ -0,0 +1,11 @@
import { Fluence } from '@fluencelabs/fluence';
import {
lng193Bug
} from '../compiled/examples/closureReturnRename.js';
import { config } from '../config.js'
const relays = config.relays
export async function lng193BugCall(): Promise<number> {
return lng193Bug(relays[4].peerId, relays[5].peerId)
}