Skip to content

Commit 5b5f9d5

Browse files
test(jco): add test for stream lift of list<u8>
1 parent 8ef44c0 commit 5b5f9d5

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

crates/test-components/src/bin/stream_tx.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ impl bindings::exports::jco::test_components::get_stream_async::Guest for Compon
110110
stream_values_async(vals)
111111
}
112112

113+
async fn get_stream_list_u8(vals: Vec<Vec<u8>>) -> Result<StreamReader<Vec<u8>>, String> {
114+
stream_values_async(vals)
115+
}
116+
113117
async fn get_stream_list_string(
114118
vals: Vec<Vec<String>>,
115119
) -> Result<StreamReader<Vec<String>>, String> {

crates/test-components/wit/all.wit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ interface get-stream-async {
6565

6666
get-stream-variant: async func(vals: list<example-variant>) -> result<stream<example-variant>, string>;
6767

68-
//get-stream-list-u8: async func(vals: list<list<u8>>) -> result<stream<list<u8>>, string>;
68+
get-stream-list-u8: async func(vals: list<list<u8>>) -> result<stream<list<u8>>, string>;
6969
get-stream-list-string: async func(vals: list<list<string>>) -> result<stream<list<string>>, string>;
7070
get-stream-list-record: async func(vals: list<list<example-record>>) -> result<stream<list<example-record>>, string>;
7171
get-stream-fixed-list-u32: async func(vals: list<list<u32, 5>>) -> result<stream<list<u32, 5>>, string>;

packages/jco/test/p3/stream.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,24 @@ suite("stream<T> lifts", () => {
220220
});
221221
});
222222

223+
test("list<u8>", async () => {
224+
assert.instanceOf(instance["jco:test-components/get-stream-async"].getStreamListU8, AsyncFunction);
225+
let vals = [[0x01, 0x02, 0x03, 0x04, 0x05], new Uint8Array([0x05, 0x04, 0x03, 0x02, 0x01]), []];
226+
let stream = await instance["jco:test-components/get-stream-async"].getStreamListU8(vals);
227+
await checkStreamValues({
228+
stream,
229+
vals,
230+
typeName: "list<u8>",
231+
assertEqFn: assert.deepEqual,
232+
expectedValues: [
233+
// TODO: wit type representation smoothing mismatch
234+
vals[0],
235+
[...vals[1]],
236+
[],
237+
],
238+
});
239+
});
240+
223241
test("list<string>", async () => {
224242
assert.instanceOf(instance["jco:test-components/get-stream-async"].getStreamListString, AsyncFunction);
225243
let vals = [["first", "second", "third"], []];
@@ -234,7 +252,7 @@ suite("stream<T> lifts", () => {
234252
[0, 0, 0, 0, 0],
235253
];
236254
let stream = await instance["jco:test-components/get-stream-async"].getStreamFixedListU32(vals);
237-
await checkStreamValues({ stream, vals, typeName: "list<string>", assertEqFn: assert.deepEqual });
255+
await checkStreamValues({ stream, vals, typeName: "list<u32, 5>", assertEqFn: assert.deepEqual });
238256
// TODO: test misuse of fixed length list
239257
});
240258

0 commit comments

Comments
 (0)