mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-18 21:31:46 +00:00
fix(evaluate): use engine262 inspect() for console output
Replace naive manual .stringValue()/.value fallback with engine262's inspect() function so console.log outputs readable strings instead of raw engine262 internal objects. Closes #5
This commit is contained in:
@@ -25,6 +25,7 @@ process.stdin.on("end", async () => {
|
|||||||
const Value = engine.Value;
|
const Value = engine.Value;
|
||||||
const skipDebugger = engine.skipDebugger;
|
const skipDebugger = engine.skipDebugger;
|
||||||
const ask262Debug = engine.ask262Debug;
|
const ask262Debug = engine.ask262Debug;
|
||||||
|
const inspect = engine.inspect;
|
||||||
|
|
||||||
// Reset state
|
// Reset state
|
||||||
ask262Debug.reset();
|
ask262Debug.reset();
|
||||||
@@ -87,19 +88,8 @@ process.stdin.on("end", async () => {
|
|||||||
for (const method of consoleMethods) {
|
for (const method of consoleMethods) {
|
||||||
const fn = CreateBuiltinFunction(
|
const fn = CreateBuiltinFunction(
|
||||||
(args) => {
|
(args) => {
|
||||||
const jsValues = args.map((arg) => {
|
// Use engine262's inspect() to convert Values to readable JS strings
|
||||||
if (arg && typeof arg === "object") {
|
const jsValues = args.map((arg) => inspect(arg));
|
||||||
const strVal = arg.stringValue;
|
|
||||||
if (typeof strVal === "function") {
|
|
||||||
return strVal.call(arg);
|
|
||||||
}
|
|
||||||
const value = arg.value;
|
|
||||||
if (value !== undefined) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return arg;
|
|
||||||
});
|
|
||||||
consoleOutput.push({ method, values: jsValues });
|
consoleOutput.push({ method, values: jsValues });
|
||||||
return Value("undefined");
|
return Value("undefined");
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user