1- use std:: ffi:: OsStr ;
2- use std:: process:: { Command , Output } ;
3-
41use quickjs_oxide:: { Context , Runtime , RuntimeError , Value } ;
52
63// Pins QuickJS 2026-06-04 ObjectAssignmentPattern lowering. Object binding
@@ -527,8 +524,13 @@ fn object_assignment_operation_stacks_match_pinned_quickjs() {
527524 return ;
528525 } ;
529526 for & ( description, source) in STACK_CASES {
530- let rust = run_cli ( env ! ( "CARGO_BIN_EXE_qjs" ) . as_ref ( ) , source, description) ;
531- let quickjs = run_cli ( & oracle, source, description) ;
527+ let rust = super :: quickjs_object_pattern_oracle:: run_cli_exact (
528+ env ! ( "CARGO_BIN_EXE_qjs" ) . as_ref ( ) ,
529+ source,
530+ description,
531+ ) ;
532+ let quickjs =
533+ super :: quickjs_object_pattern_oracle:: run_cli_exact ( & oracle, source, description) ;
532534 assert_eq ! ( rust. status. code( ) , quickjs. status. code( ) , "{description}" ) ;
533535 assert_eq ! ( rust. stdout, quickjs. stdout, "{description}" ) ;
534536 assert_eq ! ( rust. stderr, quickjs. stderr, "{description}" ) ;
@@ -543,8 +545,13 @@ fn object_assignment_parser_diagnostics_match_pinned_quickjs() {
543545 } ;
544546 let mut failures = Vec :: new ( ) ;
545547 for & ( description, source) in PARSER_CASES {
546- let rust = run_cli ( env ! ( "CARGO_BIN_EXE_qjs" ) . as_ref ( ) , source, description) ;
547- let quickjs = run_cli ( & oracle, source, description) ;
548+ let rust = super :: quickjs_object_pattern_oracle:: run_cli_exact (
549+ env ! ( "CARGO_BIN_EXE_qjs" ) . as_ref ( ) ,
550+ source,
551+ description,
552+ ) ;
553+ let quickjs =
554+ super :: quickjs_object_pattern_oracle:: run_cli_exact ( & oracle, source, description) ;
548555 if rust. status . code ( ) != quickjs. status . code ( )
549556 || rust. stdout != quickjs. stdout
550557 || rust. stderr != quickjs. stderr
@@ -587,7 +594,11 @@ fn compare_cases(group: &str, cases: &[(&str, &str)]) {
587594 let mut context = runtime. new_context ( ) ;
588595 assert_eq ! (
589596 observe_rust_eval( & runtime, & mut context, source, description) ,
590- observe_oracle( & oracle, source, description) ,
597+ super :: quickjs_object_pattern_oracle:: observe_completion_strip_one_lf(
598+ & oracle,
599+ source,
600+ description,
601+ ) ,
591602 "{group} drifted for {description}: {source:?}" ,
592603 ) ;
593604 }
@@ -627,39 +638,6 @@ fn observe_rust_eval(
627638 }
628639}
629640
630- fn observe_oracle ( oracle : & OsStr , source : & str , description : & str ) -> String {
631- let wrapper = r#"
632- try {
633- var value = std.evalScript(scriptArgs[0]);
634- print('return|' + typeof value + '|' + String(value));
635- } catch (error) {
636- if (error !== null && typeof error === 'object')
637- print('throw|object|' + error.name + '|' + error.message);
638- else
639- print('throw|' + typeof error + '|' + String(error));
640- }
641- "# ;
642- let output = Command :: new ( oracle)
643- . args ( [ "--std" , "-e" , wrapper, source] )
644- . output ( )
645- . unwrap_or_else ( |error| panic ! ( "could not run QuickJS for {description}: {error}" ) ) ;
646- assert ! (
647- output. status. success( ) ,
648- "QuickJS observer failed for {description}: {}" ,
649- String :: from_utf8_lossy( & output. stderr) ,
650- ) ;
651- let stdout = String :: from_utf8 ( output. stdout )
652- . unwrap_or_else ( |error| panic ! ( "QuickJS output was not UTF-8 for {description}: {error}" ) ) ;
653- stdout. strip_suffix ( '\n' ) . unwrap_or ( & stdout) . to_owned ( )
654- }
655-
656- fn run_cli ( program : & OsStr , source : & str , description : & str ) -> Output {
657- Command :: new ( program)
658- . args ( [ "-e" , source] )
659- . output ( )
660- . unwrap_or_else ( |error| panic ! ( "could not run CLI for {description}: {error}" ) )
661- }
662-
663641fn error_string_property (
664642 runtime : & Runtime ,
665643 context : & mut Context ,
0 commit comments