mirror of
https://github.com/fluencelabs/aqua-playground
synced 2025-03-15 01:51:03 +00:00
feat(examples): Add return closure rename example [fixes LNG-193] (#84)
This commit is contained in:
parent
4db5b3a171
commit
01c62d7a00
15
aqua/examples/closureReturnRename.aqua
Normal file
15
aqua/examples/closureReturnRename.aqua
Normal 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
|
@ -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;
|
||||
|
11
src/examples/closureReturnRename.ts
Normal file
11
src/examples/closureReturnRename.ts
Normal 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)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user