mirror of
https://github.com/fluencelabs/aqua-playground
synced 2025-05-29 04:41:18 +00:00
add tests on empty brackets
This commit is contained in:
parent
20bdf06e48
commit
c1dd156b39
@ -23,3 +23,15 @@ func optionSugar(numSome: ?u32, strSome: ?string, numNone: ?u32, strNone: ?strin
|
|||||||
str <<- i
|
str <<- i
|
||||||
<- arr, str, str2
|
<- arr, str, str2
|
||||||
|
|
||||||
|
func emptySugar() -> []u32, []string, []string, *string, ?u32, []u32, ?string:
|
||||||
|
numOp = ?[]
|
||||||
|
strArr = []
|
||||||
|
strStream = *[]
|
||||||
|
strEmptyStream: *string
|
||||||
|
for i <- ?[]:
|
||||||
|
strEmptyStream <<- "some"
|
||||||
|
for i <- *[]:
|
||||||
|
strEmptyStream <<- "some"
|
||||||
|
for i <- []:
|
||||||
|
strEmptyStream <<- "some"
|
||||||
|
<- numOp, strArr, strStream, strEmptyStream, [], ?[], *[]
|
||||||
|
@ -36,7 +36,7 @@ import {streamResCall} from "../examples/streamRestrictionsCall";
|
|||||||
import {joinIdxCall, joinIdxLocalCall, joinIdxRelayCall} from "../examples/joinCall";
|
import {joinIdxCall, joinIdxLocalCall, joinIdxRelayCall} from "../examples/joinCall";
|
||||||
import {topologyBug427} from "../compiled/examples/topology";
|
import {topologyBug427} from "../compiled/examples/topology";
|
||||||
import {recursiveStreamsCall} from "../examples/recursiveStreamsCall";
|
import {recursiveStreamsCall} from "../examples/recursiveStreamsCall";
|
||||||
import {arraySugarCall, optionSugarCall, streamSugarCall} from "../examples/collectionSugarCall";
|
import {allEmptySugarCall, arraySugarCall, optionSugarCall, streamSugarCall} from "../examples/collectionSugarCall";
|
||||||
|
|
||||||
var selfPeerId: string;
|
var selfPeerId: string;
|
||||||
var peer2: FluencePeer;
|
var peer2: FluencePeer;
|
||||||
@ -164,23 +164,25 @@ describe('Testing examples', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('collectionSugar array', async () => {
|
it('collectionSugar array', async () => {
|
||||||
console.log("collectionSugar array")
|
|
||||||
let result = await arraySugarCall();
|
let result = await arraySugarCall();
|
||||||
expect(result).toEqual([[1,2,3], [4,5,6]]);
|
expect(result).toEqual([[1,2,3], [4,5,6]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('collectionSugar stream', async () => {
|
it('collectionSugar stream', async () => {
|
||||||
console.log("collectionSugar stream")
|
|
||||||
let result = await streamSugarCall();
|
let result = await streamSugarCall();
|
||||||
expect(result).toEqual([[1,2,3], [4,5,6]]);
|
expect(result).toEqual([[1,2,3], [4,5,6]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('collectionSugar option', async () => {
|
it('collectionSugar option', async () => {
|
||||||
console.log("collectionSugar option")
|
|
||||||
let result = await optionSugarCall()
|
let result = await optionSugarCall()
|
||||||
expect(result).toEqual([[1], ["some"], []]);
|
expect(result).toEqual([[1], ["some"], []]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('collectionSugar empty', async () => {
|
||||||
|
let result = await allEmptySugarCall()
|
||||||
|
expect(result).toEqual([[], [], [], [], null, [], null]);
|
||||||
|
});
|
||||||
|
|
||||||
it.skip('recursiveStreams.aqua', async () => {
|
it.skip('recursiveStreams.aqua', async () => {
|
||||||
|
|
||||||
let recResult = await recursiveStreamsCall();
|
let recResult = await recursiveStreamsCall();
|
||||||
|
@ -441,3 +441,89 @@ export function optionSugar(...args: any) {
|
|||||||
script
|
script
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export type EmptySugarResult = [number[], string[], string[], string[], number | null, number[], string | null]
|
||||||
|
export function emptySugar(
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<EmptySugarResult>;
|
||||||
|
|
||||||
|
export function emptySugar(
|
||||||
|
peer: FluencePeer,
|
||||||
|
config?: {ttl?: number}
|
||||||
|
): Promise<EmptySugarResult>;
|
||||||
|
|
||||||
|
export function emptySugar(...args: any) {
|
||||||
|
|
||||||
|
let script = `
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||||
|
(new $strStream
|
||||||
|
(seq
|
||||||
|
(new $strArr
|
||||||
|
(seq
|
||||||
|
(new $numOp
|
||||||
|
(call %init_peer_id% ("op" "identity") [[]] numOp-fix)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("op" "identity") [[]] strArr-fix)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("op" "identity") [[]] strStream-fix)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(xor
|
||||||
|
(call %init_peer_id% ("callbackSrv" "response") [numOp-fix strArr-fix strStream-fix $strEmptyStream [] [] []])
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
|
||||||
|
)
|
||||||
|
`
|
||||||
|
return callFunction(
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
"functionName" : "emptySugar",
|
||||||
|
"returnType" : {
|
||||||
|
"tag" : "multiReturn",
|
||||||
|
"returnItems" : [
|
||||||
|
{
|
||||||
|
"tag" : "primitive"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag" : "primitive"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag" : "primitive"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag" : "primitive"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag" : "optional"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag" : "primitive"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag" : "optional"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"argDefs" : [
|
||||||
|
],
|
||||||
|
"names" : {
|
||||||
|
"relay" : "-relay-",
|
||||||
|
"getDataSrv" : "getDataSrv",
|
||||||
|
"callbackSrv" : "callbackSrv",
|
||||||
|
"responseSrv" : "callbackSrv",
|
||||||
|
"responseFnName" : "response",
|
||||||
|
"errorHandlingSrv" : "errorHandlingSrv",
|
||||||
|
"errorFnName" : "error"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
script
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {arraySugar, optionSugar, streamSugar} from "../compiled/examples/collectionSugar";
|
import {arraySugar, emptySugar, optionSugar, streamSugar} from "../compiled/examples/collectionSugar";
|
||||||
|
|
||||||
export async function arraySugarCall(): Promise<[number[], number[]]> {
|
export async function arraySugarCall(): Promise<[number[], number[]]> {
|
||||||
return await arraySugar(3, 6)
|
return await arraySugar(3, 6)
|
||||||
@ -11,3 +11,7 @@ export async function streamSugarCall(): Promise<[number[], number[]]> {
|
|||||||
export async function optionSugarCall(): Promise<[number[], string[], string[]]> {
|
export async function optionSugarCall(): Promise<[number[], string[], string[]]> {
|
||||||
return await optionSugar(1, "some", null, null)
|
return await optionSugar(1, "some", null, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function allEmptySugarCall(): Promise<[number[], string[], string[], string[], number | null, number[], string | null]> {
|
||||||
|
return await emptySugar()
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user