@@ -242,19 +242,134 @@ suite("stream<T> lowers", () => {
242242 ) ;
243243 assert . deepEqual ( returnedVals , [
244244 // TODO: wit type representation smoothing mismatch
245- { tag : "maybe-u32" , val : { tag : ' some' , val : 123 } } ,
246- { tag : "maybe-u32" , val : { tag : ' none' } } ,
245+ { tag : "maybe-u32" , val : { tag : " some" , val : 123 } } ,
246+ { tag : "maybe-u32" , val : { tag : " none" } } ,
247247 { tag : "str" , val : "string-value" } ,
248248 { tag : "num" , val : 1 } ,
249249 ] ) ;
250250
251- vals = [
252- { tag : "float" , val : 123.1 } ,
253- ] ;
251+ vals = [ { tag : "float" , val : 123.1 } ] ;
254252 returnedVals = await instance [ "jco:test-components/use-stream-async" ] . readStreamValuesVariant (
255253 createReadableStreamFromValues ( vals ) ,
256254 ) ;
257255 assert . closeTo ( returnedVals [ 0 ] . val , 123.1 , 0.01 ) ;
256+ } ) ;
257+
258+ test . concurrent ( "tuple" , async ( ) => {
259+ assert . instanceOf ( instance [ "jco:test-components/use-stream-async" ] . readStreamValuesTuple , AsyncFunction ) ;
260+
261+ let vals = [
262+ [ 1 , - 1 , "one" ] ,
263+ [ 2 , - 2 , "two" ] ,
264+ [ 3 , - 3 , "two" ] ,
265+ ] ;
266+ let returnedVals = await instance [ "jco:test-components/use-stream-async" ] . readStreamValuesTuple (
267+ createReadableStreamFromValues ( vals ) ,
268+ ) ;
269+ assert . deepEqual ( returnedVals , vals ) ;
270+ } ) ;
271+
272+ test . concurrent ( "flags" , async ( ) => {
273+ assert . instanceOf ( instance [ "jco:test-components/use-stream-async" ] . readStreamValuesFlags , AsyncFunction ) ;
274+
275+ let vals = [
276+ { first : true , second : false , third : false } ,
277+ { first : false , second : true , third : false } ,
278+ { first : false , second : false , third : true } ,
279+ ] ;
280+ let returnedVals = await instance [ "jco:test-components/use-stream-async" ] . readStreamValuesFlags (
281+ createReadableStreamFromValues ( vals ) ,
282+ ) ;
283+ assert . deepEqual ( returnedVals , vals ) ;
284+ } ) ;
285+
286+ test . concurrent ( "enum" , async ( ) => {
287+ assert . instanceOf ( instance [ "jco:test-components/use-stream-async" ] . readStreamValuesEnum , AsyncFunction ) ;
288+
289+ let vals = [ "first" , "second" , "third" ] ;
290+ let returnedVals = await instance [ "jco:test-components/use-stream-async" ] . readStreamValuesEnum (
291+ createReadableStreamFromValues ( vals ) ,
292+ ) ;
293+ assert . deepEqual ( returnedVals , [ "first" , "second" , "third" ] ) ;
294+ } ) ;
295+
296+ test . concurrent ( "option<string>" , async ( ) => {
297+ assert . instanceOf ( instance [ "jco:test-components/use-stream-async" ] . readStreamValuesOptionString , AsyncFunction ) ;
298+
299+ let vals = [ "present string" , null ] ;
300+ let returnedVals = await instance [ "jco:test-components/use-stream-async" ] . readStreamValuesOptionString (
301+ createReadableStreamFromValues ( vals ) ,
302+ ) ;
303+ assert . deepEqual ( returnedVals , [
304+ // TODO: wit type representation smoothing mismatch
305+ { tag : "some" , val : "present string" } ,
306+ { tag : "none" } ,
307+ ] ) ;
308+ } ) ;
309+
310+ test . concurrent ( "result<string>" , async ( ) => {
311+ assert . instanceOf ( instance [ "jco:test-components/use-stream-async" ] . readStreamValuesResultString , AsyncFunction ) ;
312+
313+ let vals = [ { tag : "ok" , val : "present string" } , { tag : "err" , val : "nope" } , "bare string (ok)" ] ;
314+ let returnedVals = await instance [ "jco:test-components/use-stream-async" ] . readStreamValuesResultString (
315+ createReadableStreamFromValues ( vals ) ,
316+ ) ;
317+ assert . deepEqual ( returnedVals , [
318+ // TODO: wit type representation smoothing mismatch
319+ { tag : "ok" , val : "present string" } ,
320+ { tag : "err" , val : "nope" } ,
321+ { tag : "ok" , val : "bare string (ok)" } ,
322+ ] ) ;
323+ } ) ;
324+
325+ test . concurrent ( "list<u8>" , async ( ) => {
326+ assert . instanceOf ( instance [ "jco:test-components/use-stream-async" ] . readStreamValuesListU8 , AsyncFunction ) ;
327+
328+ let vals = [ [ 0x01 , 0x02 , 0x03 , 0x04 , 0x05 ] , new Uint8Array ( [ 0x05 , 0x04 , 0x03 , 0x02 , 0x01 ] ) , [ ] ] ;
329+ let returnedVals = await instance [ "jco:test-components/use-stream-async" ] . readStreamValuesListU8 (
330+ createReadableStreamFromValues ( vals ) ,
331+ ) ;
332+ assert . deepEqual ( returnedVals , [
333+ // TODO: wit type representation smoothing mismatch
334+ vals [ 0 ] ,
335+ [ ...vals [ 1 ] ] ,
336+ [ ] ,
337+ ] ) ;
338+ } ) ;
339+
340+ test . concurrent ( "list<string>" , async ( ) => {
341+ assert . instanceOf ( instance [ "jco:test-components/use-stream-async" ] . readStreamValuesListString , AsyncFunction ) ;
342+
343+ let vals = [ [ "first" , "second" , "third" ] , [ ] ] ;
344+ let returnedVals = await instance [ "jco:test-components/use-stream-async" ] . readStreamValuesListString (
345+ createReadableStreamFromValues ( vals ) ,
346+ ) ;
347+ assert . deepEqual ( returnedVals , vals ) ;
348+ } ) ;
258349
350+ test . concurrent ( "list<list<u32, 5>>" , async ( ) => {
351+ assert . instanceOf ( instance [ "jco:test-components/use-stream-async" ] . readStreamValuesFixedListU32 , AsyncFunction ) ;
352+
353+ let vals = [
354+ [
355+ [ 1 , 2 , 3 , 4 , 5 ] ,
356+ [ 0 , 0 , 0 , 0 , 0 ] ,
357+ ] ,
358+ [ [ 0 , 0 , 0 , 0 , 0 ] , new Uint32Array ( [ 0x05 , 0x04 , 0x03 , 0x02 , 0x01 ] ) ] ,
359+ ] ;
360+ let returnedVals = await instance [ "jco:test-components/use-stream-async" ] . readStreamValuesFixedListU32 (
361+ createReadableStreamFromValues ( vals ) ,
362+ ) ;
363+ assert . deepEqual ( returnedVals , [
364+ // TODO(fix): wit type representation smoothing mismatch
365+ [
366+ [ 1 , 2 , 3 , 4 , 5 ] ,
367+ [ 0 , 0 , 0 , 0 , 0 ] ,
368+ ] ,
369+ [
370+ [ 0 , 0 , 0 , 0 , 0 ] ,
371+ [ 0x05 , 0x04 , 0x03 , 0x02 , 0x01 ] ,
372+ ] ,
373+ ] ) ;
259374 } ) ;
260375} ) ;
0 commit comments