mirror of
https://github.com/fluencelabs/aqua-playground
synced 2025-06-13 03:31:38 +00:00
add new test for streams
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import "@fluencelabs/aqua-lib/builtin.aqua"
|
||||
|
||||
service Stringer("stringer-id"):
|
||||
returnString: string -> string
|
||||
|
||||
@ -9,18 +11,26 @@ func checkStreams(ch: []string) -> []string:
|
||||
stream <- Stringer.returnString(b)
|
||||
<- stream
|
||||
|
||||
func getStream() -> *u32:
|
||||
nums = *[1,2,3,4]
|
||||
<- nums
|
||||
|
||||
func returnStreamFromFunc() -> *u32:
|
||||
nums <- getStream()
|
||||
<- nums
|
||||
|
||||
func stringNil() -> *string:
|
||||
valueNil: *string
|
||||
<- valueNil
|
||||
valueNil: *string
|
||||
<- valueNil
|
||||
|
||||
func returnNil() -> *string:
|
||||
relayNil <- stringNil()
|
||||
<- relayNil
|
||||
relayNil <- stringNil()
|
||||
<- relayNil
|
||||
|
||||
func stringNone() -> ?string:
|
||||
valueNone: ?string
|
||||
<- valueNone
|
||||
valueNone: ?string
|
||||
<- valueNone
|
||||
|
||||
func returnNone() -> ?string:
|
||||
relayNone <- stringNone()
|
||||
<- relayNone
|
||||
relayNone <- stringNone()
|
||||
<- relayNone
|
||||
|
@ -13,7 +13,7 @@ import { bugNG69Call, ifCall, ifWrapCall } from '../examples/ifCall';
|
||||
import { parCall, testTimeoutCall } from '../examples/parCall';
|
||||
import { complexCall } from '../examples/complex';
|
||||
import { constantsCall, particleTtlAndTimestampCall } from '../examples/constantsCall';
|
||||
import { returnNilCall, returnNoneCall, streamCall } from '../examples/streamCall';
|
||||
import {returnNilCall, returnNoneCall, streamCall, streamReturnFromInnerFunc} from '../examples/streamCall';
|
||||
import { topologyBug205Call, topologyBug394Call, topologyBug427Call, topologyCall } from '../examples/topologyCall';
|
||||
import { foldJoinCall } from '../examples/foldJoinCall';
|
||||
import { registerHandlers, returnNull, returnOptionalCall, useOptionalCall } from '../examples/useOptionalCall';
|
||||
@ -231,6 +231,11 @@ describe('Testing examples', () => {
|
||||
expect(returnNoneResult).toBe(null);
|
||||
});
|
||||
|
||||
it('stream.aqua return stream from inner func', async () => {
|
||||
let streamResult = await streamReturnFromInnerFunc()
|
||||
expect(streamResult).toEqual([1, 2, 3, 4]);
|
||||
})
|
||||
|
||||
it('streamCan.aqua', async () => {
|
||||
let streamCanResult = await streamCanCall();
|
||||
expect(streamCanResult).toEqual(['a', 'b', null]);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { FluencePeer } from '@fluencelabs/fluence';
|
||||
import {checkStreams, registerStringer, stringNil, stringNone} from '../compiled/examples/stream';
|
||||
import {checkStreams, registerStringer, returnStreamFromFunc, stringNil, stringNone} from '../compiled/examples/stream';
|
||||
|
||||
export async function streamCall() {
|
||||
registerStringer({
|
||||
@ -18,3 +18,7 @@ export async function returnNilCall() {
|
||||
export async function returnNoneCall() {
|
||||
return stringNone()
|
||||
}
|
||||
|
||||
export async function streamReturnFromInnerFunc() {
|
||||
return await returnStreamFromFunc();
|
||||
}
|
||||
|
Reference in New Issue
Block a user