@@ -17,7 +17,7 @@ import {
1717 readComponentBytes ,
1818 tsGenerationPromise ,
1919} from "./helpers.js" ;
20- import { getDefaultComponentFixtures , COMPONENT_FIXTURES_DIR } from "./common.js" ;
20+ import { getDefaultComponentFixtures , COMPONENT_FIXTURES_DIR , LOCAL_TEST_COMPONENTS_DIR } from "./common.js" ;
2121
2222suite ( `Transpiler codegen` , async ( ) => {
2323 // NOTE: the codegen tests *must* run first and generate outputs for other tests to use
@@ -211,3 +211,20 @@ suite("Directive Prologue", () => {
211211 assert . isOk ( bindingsSource . includes ( '"use jco";' ) ) ;
212212 } ) ;
213213} ) ;
214+
215+ suite ( "codegen determinism" , ( ) => {
216+ // see: https://github.com/bytecodealliance/jco/pull/1373
217+ test ( "consistent output" , async ( ) => {
218+ // NOTE: we need to use a significant enough component here to expose indeterminism
219+ const [ streamTx , streamRx ] = await Promise . all ( [
220+ readFile ( join ( LOCAL_TEST_COMPONENTS_DIR , `stream-tx.wasm` ) ) . then ( ( bytes ) => {
221+ return Promise . all ( [ transpile ( bytes ) , transpile ( bytes ) ] ) ;
222+ } ) ,
223+ readFile ( join ( LOCAL_TEST_COMPONENTS_DIR , `stream-rx.wasm` ) ) . then ( ( bytes ) => {
224+ return Promise . all ( [ transpile ( bytes ) , transpile ( bytes ) ] ) ;
225+ } ) ,
226+ ] ) ;
227+ assert . deepEqual ( streamTx [ 0 ] . files , streamTx [ 1 ] . files ) ;
228+ assert . deepEqual ( streamRx [ 0 ] . files , streamRx [ 1 ] . files ) ;
229+ } ) ;
230+ } ) ;
0 commit comments