-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add parser * Add semantics * Add inlining * Add range test * Rewrite to for ... rec * Rewrite tests * Fix import * Add nested test * Remove only * Add yes|no test * Add multi rec test * Add pipeline test * Unignore tests * Change timeouts * Add remote rec test * Fix integration tests * Add parser test * Add semantics test * Add inlining test * Add comment
- Loading branch information
1 parent
9aec470
commit ae32f80
Showing
30 changed files
with
448 additions
and
120 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
integration-tests/aqua/examples/recursiveStreams/multiRec.aqua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
aqua MultiRec | ||
|
||
export TestService, multiRecStream | ||
|
||
service TestService("test-srv"): | ||
handle(i: i32) -> []i32 | ||
|
||
func multiRecStream(init: i32, target: i32) -> []i32: | ||
result: *string | ||
loop: *i32 | ||
|
||
loop <<- init | ||
for l <- loop rec: | ||
news <- TestService.handle(l) | ||
for n <- news: | ||
loop <<- n | ||
if l == target: | ||
result <<- "done" | ||
|
||
join result! | ||
|
||
<- loop |
19 changes: 19 additions & 0 deletions
19
integration-tests/aqua/examples/recursiveStreams/nested.aqua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
aqua Nested | ||
|
||
export nested | ||
|
||
func nested(n: u32) -> []u32: | ||
result: *u32 | ||
iterator: *u32 | ||
|
||
iterator <<- 0 | ||
for i <- iterator rec: | ||
if i < n: | ||
for j <- iterator rec: | ||
result <<- j | ||
iterator <<- i + 1 | ||
|
||
if n > 0: | ||
join result[n * (n + 1) / 2 - 1] | ||
|
||
<- result |
29 changes: 29 additions & 0 deletions
29
integration-tests/aqua/examples/recursiveStreams/pipeline.aqua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
aqua Pipeline | ||
|
||
export pipelineStream | ||
|
||
func pipelineStream(init: i32, target: i32) -> []i32: | ||
result: *string | ||
|
||
loop1: *i32 | ||
loop2: *i32 | ||
loop3: *i32 | ||
|
||
loop1 <<- init | ||
for l <- loop1 rec: | ||
if l < target: | ||
loop1 <<- l + 1 | ||
loop2 <<- l * 3 | ||
|
||
for l <- loop2 rec: | ||
loop3 <<- l | ||
loop3 <<- l + 1 | ||
loop3 <<- l + 2 | ||
|
||
for l <- loop3 rec: | ||
if l == target: | ||
result <<- "success" | ||
|
||
join result! | ||
|
||
<- loop3 |
18 changes: 18 additions & 0 deletions
18
integration-tests/aqua/examples/recursiveStreams/range.aqua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
aqua Range | ||
|
||
export range | ||
|
||
func range(a: i32, b: i32) -> []i32: | ||
result: *i32 | ||
iterator: *i32 | ||
|
||
iterator <<- a | ||
for i <- iterator rec: | ||
if i < b: | ||
result <<- i | ||
iterator <<- i + 1 | ||
|
||
if b > a: | ||
join result[b - a - 1] | ||
|
||
<- result |
19 changes: 19 additions & 0 deletions
19
integration-tests/aqua/examples/recursiveStreams/remoteRec.aqua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
aqua RemoteRec | ||
|
||
export RemoteSrv, remoteRecStream | ||
|
||
service RemoteSrv("remote-srv"): | ||
handle(i: i32) -> i32 | ||
|
||
func remoteRecStream(init: i32, target: i32, friend: string, friendRelay: string) -> []i32: | ||
loop: *i32 | ||
|
||
loop <<- init | ||
for l <- loop rec: | ||
on friend via friendRelay: | ||
if l < target: | ||
loop <- RemoteSrv.handle(l) | ||
|
||
join loop[target - init] | ||
|
||
<- loop |
21 changes: 21 additions & 0 deletions
21
integration-tests/aqua/examples/recursiveStreams/yesNo.aqua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
aqua YesNo | ||
|
||
export YesNoService, yesNoStream | ||
|
||
service YesNoService("yesno"): | ||
get() -> string | ||
|
||
func yesNoStream() -> []string: | ||
result: *string | ||
loop: *string | ||
|
||
loop <<- "yes" | ||
for l <- loop rec: | ||
if l == "yes": | ||
loop <- YesNoService.get() | ||
else: | ||
result <<- "success" | ||
|
||
join result! | ||
|
||
<- loop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
integration-tests/src/examples/recursiveStreams/multiRecStreamCall.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { | ||
multiRecStream, | ||
registerTestService, | ||
} from "../../compiled/examples/recursiveStreams/multiRec.js"; | ||
|
||
export async function multiRecStreamCall( | ||
init: number, | ||
target: number, | ||
handle: (i: number) => number[], | ||
): Promise<number[]> { | ||
registerTestService({ handle }); | ||
|
||
return await multiRecStream(init, target); | ||
} |
5 changes: 5 additions & 0 deletions
5
integration-tests/src/examples/recursiveStreams/nestedCall.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { nested } from "../../compiled/examples/recursiveStreams/nested.js"; | ||
|
||
export async function nestedCall(n: number): Promise<number[]> { | ||
return await nested(n); | ||
} |
8 changes: 8 additions & 0 deletions
8
integration-tests/src/examples/recursiveStreams/pipelineCall.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { pipelineStream } from "../../compiled/examples/recursiveStreams/pipeline.js"; | ||
|
||
export async function pipelineStreamCall( | ||
init: number, | ||
target: number, | ||
): Promise<number[]> { | ||
return await pipelineStream(init, target); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { range } from "../../compiled/examples/recursiveStreams/range.js"; | ||
|
||
export async function rangeCall(a: number, b: number): Promise<number[]> { | ||
return await range(a, b); | ||
} |
15 changes: 15 additions & 0 deletions
15
integration-tests/src/examples/recursiveStreams/remoteRecCall.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { IFluenceClient } from "@fluencelabs/js-client"; | ||
import { remoteRecStream } from "../../compiled/examples/recursiveStreams/remoteRec.js"; | ||
|
||
export async function remoteRecStreamCall( | ||
init: number, | ||
target: number, | ||
peer: IFluenceClient, | ||
): Promise<number[]> { | ||
return await remoteRecStream( | ||
init, | ||
target, | ||
peer.getPeerId(), | ||
peer.getRelayPeerId(), | ||
); | ||
} |
16 changes: 16 additions & 0 deletions
16
integration-tests/src/examples/recursiveStreams/yesNoStreamCall.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { | ||
yesNoStream, | ||
registerYesNoService, | ||
} from "../../compiled/examples/recursiveStreams/yesNo.js"; | ||
|
||
export async function yesNoStreamCall(limit: number): Promise<string[]> { | ||
let i = 1; | ||
registerYesNoService({ | ||
get: () => { | ||
i += 1; | ||
return i > limit ? "no" : "yes"; | ||
}, | ||
}); | ||
|
||
return await yesNoStream(); | ||
} |
Oops, something went wrong.