-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
wit-parser
tests for streams, futures, and error-contexts
Signed-off-by: Joel Dice <[email protected]>
- Loading branch information
Showing
5 changed files
with
325 additions
and
0 deletions.
There are no files selected for viewing
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
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,7 @@ | ||
package foo:error-contexts; | ||
|
||
interface error-contexts { | ||
type t1 = error-context; | ||
|
||
foo: func(x: error-context, y: t1) -> result<_, error-context>; | ||
} |
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,66 @@ | ||
{ | ||
"worlds": [], | ||
"interfaces": [ | ||
{ | ||
"name": "error-contexts", | ||
"types": { | ||
"t1": 0 | ||
}, | ||
"functions": { | ||
"foo": { | ||
"name": "foo", | ||
"kind": "freestanding", | ||
"params": [ | ||
{ | ||
"name": "x", | ||
"type": 1 | ||
}, | ||
{ | ||
"name": "y", | ||
"type": 0 | ||
} | ||
], | ||
"results": [ | ||
{ | ||
"type": 2 | ||
} | ||
] | ||
} | ||
}, | ||
"package": 0 | ||
} | ||
], | ||
"types": [ | ||
{ | ||
"name": "t1", | ||
"kind": "errorcontext", | ||
"owner": { | ||
"interface": 0 | ||
} | ||
}, | ||
{ | ||
"name": null, | ||
"kind": "errorcontext", | ||
"owner": null | ||
}, | ||
{ | ||
"name": null, | ||
"kind": { | ||
"result": { | ||
"ok": null, | ||
"err": 1 | ||
} | ||
}, | ||
"owner": null | ||
} | ||
], | ||
"packages": [ | ||
{ | ||
"name": "foo:error-contexts", | ||
"interfaces": { | ||
"error-contexts": 0 | ||
}, | ||
"worlds": {} | ||
} | ||
] | ||
} |
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 @@ | ||
package foo:streams-and-futures; | ||
|
||
interface streams-and-futures { | ||
type t1 = stream<u8>; | ||
type t2 = stream<stream<string>>; | ||
type t3 = future; | ||
type t4 = future<list<u8>>; | ||
type t5 = option<stream<future>>; | ||
resource r1; | ||
type t6 = stream<r1>; | ||
type t7 = future<result<r1>>; | ||
|
||
foo: func(x: stream<u32>, y: t6) -> future<result<list<string>, string>>; | ||
} |
199 changes: 199 additions & 0 deletions
199
crates/wit-parser/tests/ui/streams-and-futures.wit.json
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,199 @@ | ||
{ | ||
"worlds": [], | ||
"interfaces": [ | ||
{ | ||
"name": "streams-and-futures", | ||
"types": { | ||
"t1": 0, | ||
"t2": 2, | ||
"t3": 3, | ||
"t4": 5, | ||
"t5": 8, | ||
"r1": 9, | ||
"t6": 11, | ||
"t7": 13 | ||
}, | ||
"functions": { | ||
"foo": { | ||
"name": "foo", | ||
"kind": "freestanding", | ||
"params": [ | ||
{ | ||
"name": "x", | ||
"type": 14 | ||
}, | ||
{ | ||
"name": "y", | ||
"type": 11 | ||
} | ||
], | ||
"results": [ | ||
{ | ||
"type": 17 | ||
} | ||
] | ||
} | ||
}, | ||
"package": 0 | ||
} | ||
], | ||
"types": [ | ||
{ | ||
"name": "t1", | ||
"kind": { | ||
"stream": "u8" | ||
}, | ||
"owner": { | ||
"interface": 0 | ||
} | ||
}, | ||
{ | ||
"name": null, | ||
"kind": { | ||
"stream": "string" | ||
}, | ||
"owner": null | ||
}, | ||
{ | ||
"name": "t2", | ||
"kind": { | ||
"stream": 1 | ||
}, | ||
"owner": { | ||
"interface": 0 | ||
} | ||
}, | ||
{ | ||
"name": "t3", | ||
"kind": { | ||
"future": null | ||
}, | ||
"owner": { | ||
"interface": 0 | ||
} | ||
}, | ||
{ | ||
"name": null, | ||
"kind": { | ||
"list": "u8" | ||
}, | ||
"owner": null | ||
}, | ||
{ | ||
"name": "t4", | ||
"kind": { | ||
"future": 4 | ||
}, | ||
"owner": { | ||
"interface": 0 | ||
} | ||
}, | ||
{ | ||
"name": null, | ||
"kind": { | ||
"future": null | ||
}, | ||
"owner": null | ||
}, | ||
{ | ||
"name": null, | ||
"kind": { | ||
"stream": 6 | ||
}, | ||
"owner": null | ||
}, | ||
{ | ||
"name": "t5", | ||
"kind": { | ||
"option": 7 | ||
}, | ||
"owner": { | ||
"interface": 0 | ||
} | ||
}, | ||
{ | ||
"name": "r1", | ||
"kind": "resource", | ||
"owner": { | ||
"interface": 0 | ||
} | ||
}, | ||
{ | ||
"name": null, | ||
"kind": { | ||
"handle": { | ||
"own": 9 | ||
} | ||
}, | ||
"owner": null | ||
}, | ||
{ | ||
"name": "t6", | ||
"kind": { | ||
"stream": 10 | ||
}, | ||
"owner": { | ||
"interface": 0 | ||
} | ||
}, | ||
{ | ||
"name": null, | ||
"kind": { | ||
"result": { | ||
"ok": 10, | ||
"err": null | ||
} | ||
}, | ||
"owner": null | ||
}, | ||
{ | ||
"name": "t7", | ||
"kind": { | ||
"future": 12 | ||
}, | ||
"owner": { | ||
"interface": 0 | ||
} | ||
}, | ||
{ | ||
"name": null, | ||
"kind": { | ||
"stream": "u32" | ||
}, | ||
"owner": null | ||
}, | ||
{ | ||
"name": null, | ||
"kind": { | ||
"list": "string" | ||
}, | ||
"owner": null | ||
}, | ||
{ | ||
"name": null, | ||
"kind": { | ||
"result": { | ||
"ok": 15, | ||
"err": "string" | ||
} | ||
}, | ||
"owner": null | ||
}, | ||
{ | ||
"name": null, | ||
"kind": { | ||
"future": 16 | ||
}, | ||
"owner": null | ||
} | ||
], | ||
"packages": [ | ||
{ | ||
"name": "foo:streams-and-futures", | ||
"interfaces": { | ||
"streams-and-futures": 0 | ||
}, | ||
"worlds": {} | ||
} | ||
] | ||
} |