@@ -692,9 +692,12 @@ fn javascript_module_execution_accepts_inline_exports_in_a_context() {
692692 wire_vm ( & connection_id, & session_id, & vm_id) ,
693693 wire:: RequestPayload :: JavaScriptExecutionRequest ( wire:: JavaScriptExecutionRequest {
694694 process : context_process_options ( "module-context" ) ,
695- source : String :: from ( "export const y = 1;" ) ,
695+ source : String :: from (
696+ "globalThis.moduleRuns = (globalThis.moduleRuns ?? 0) + 1;\n \
697+ export const y = globalThis.moduleRuns;",
698+ ) ,
696699 format : Some ( wire:: JavaScriptModuleFormat :: Module ) ,
697- file_path : None ,
700+ file_path : Some ( String :: from ( "/workspace/reused-inline.mjs" ) ) ,
698701 inputs : None ,
699702 } ) ,
700703 ) )
@@ -710,6 +713,56 @@ fn javascript_module_execution_accepts_inline_exports_in_a_context() {
710713 assert_eq ! ( result. outcome, wire:: ExecutionOutcome :: Succeeded ) ;
711714 assert_eq ! ( result. exit_code, Some ( 0 ) ) ;
712715
716+ let repeated = sidecar
717+ . dispatch_wire_blocking ( wire_request (
718+ 5 ,
719+ wire_vm ( & connection_id, & session_id, & vm_id) ,
720+ wire:: RequestPayload :: JavaScriptExecutionRequest ( wire:: JavaScriptExecutionRequest {
721+ process : context_process_options ( "module-context" ) ,
722+ source : String :: from (
723+ "globalThis.moduleRuns = (globalThis.moduleRuns ?? 0) + 1;\n \
724+ export const y = globalThis.moduleRuns;",
725+ ) ,
726+ format : Some ( wire:: JavaScriptModuleFormat :: Module ) ,
727+ file_path : Some ( String :: from ( "/workspace/reused-inline.mjs" ) ) ,
728+ inputs : None ,
729+ } ) ,
730+ ) )
731+ . expect ( "repeat inline ES module with the same identity" ) ;
732+ assert_eq ! ( accepted_execution_id( repeated) , execution_id) ;
733+ let repeated_result = wait_for_execution (
734+ & mut sidecar,
735+ & connection_id,
736+ & session_id,
737+ & vm_id,
738+ & execution_id,
739+ ) ;
740+ assert_eq ! ( repeated_result. outcome, wire:: ExecutionOutcome :: Succeeded ) ;
741+
742+ let evaluation = sidecar
743+ . dispatch_wire_blocking ( wire_request (
744+ 6 ,
745+ wire_vm ( & connection_id, & session_id, & vm_id) ,
746+ wire:: RequestPayload :: JavaScriptEvaluationRequest ( wire:: JavaScriptEvaluationRequest {
747+ process : context_process_options ( "module-context" ) ,
748+ expression : String :: from ( "globalThis.moduleRuns" ) ,
749+ format : Some ( wire:: JavaScriptModuleFormat :: Module ) ,
750+ file_path : None ,
751+ inputs : None ,
752+ } ) ,
753+ ) )
754+ . expect ( "read repeated module execution count" ) ;
755+ assert_eq ! ( accepted_execution_id( evaluation) , execution_id) ;
756+ let evaluation_result = wait_for_execution (
757+ & mut sidecar,
758+ & connection_id,
759+ & session_id,
760+ & vm_id,
761+ & execution_id,
762+ ) ;
763+ assert_eq ! ( evaluation_result. outcome, wire:: ExecutionOutcome :: Succeeded ) ;
764+ assert_eq ! ( evaluation_result. evaluation_value. as_deref( ) , Some ( "2" ) ) ;
765+
713766 reset_execution (
714767 & mut sidecar,
715768 & connection_id,
0 commit comments