add new test for streams

This commit is contained in:
DieMyst
2022-10-20 18:51:13 +03:00
parent 7f3ce497de
commit b6109fc22f
3 changed files with 29 additions and 10 deletions

View File

@ -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,6 +11,14 @@ 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

View File

@ -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]);

View File

@ -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();
}