|
1 | 1 | // Keep the Array-method oracle implementations in separate modules so their |
2 | 2 | // private helpers remain isolated while Cargo builds one integration target. |
3 | 3 |
|
| 4 | +#[path = "support/quickjs_completion.rs"] |
| 5 | +mod quickjs_completion; |
| 6 | + |
4 | 7 | mod support { |
5 | 8 | use std::ffi::OsStr; |
6 | | - use std::process::Command; |
7 | 9 |
|
8 | 10 | use quickjs_oxide::{ |
9 | 11 | CallableRef, CompleteOrdinaryPropertyDescriptor, Context, ObjectRef, Runtime, RuntimeError, |
@@ -64,32 +66,7 @@ mod support { |
64 | 66 | } |
65 | 67 |
|
66 | 68 | pub(super) fn observe_oracle(oracle: &OsStr, source: &str, description: &str) -> String { |
67 | | - let wrapper = r#" |
68 | | -try { |
69 | | - var value = std.evalScript(scriptArgs[0]); |
70 | | - print('return|' + typeof value + '|' + String(value)); |
71 | | -} catch (error) { |
72 | | - if (error !== null && typeof error === 'object') |
73 | | - print('throw|object|' + error.name + '|' + error.message); |
74 | | - else |
75 | | - print('throw|' + typeof error + '|' + String(error)); |
76 | | -} |
77 | | -"#; |
78 | | - let output = Command::new(oracle) |
79 | | - .args(["--std", "-e", wrapper, source]) |
80 | | - .output() |
81 | | - .unwrap_or_else(|error| panic!("could not run QuickJS for {description}: {error}")); |
82 | | - assert!( |
83 | | - output.status.success(), |
84 | | - "QuickJS observer failed for {description}: {}", |
85 | | - String::from_utf8_lossy(&output.stderr), |
86 | | - ); |
87 | | - String::from_utf8(output.stdout) |
88 | | - .unwrap_or_else(|error| { |
89 | | - panic!("QuickJS output was not UTF-8 for {description}: {error}") |
90 | | - }) |
91 | | - .trim_end() |
92 | | - .to_owned() |
| 69 | + super::quickjs_completion::observe(oracle, source, description) |
93 | 70 | } |
94 | 71 |
|
95 | 72 | pub(super) fn data_descriptor_bits(descriptor: &CompleteOrdinaryPropertyDescriptor) -> String { |
|
0 commit comments