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