Skip to content

Commit

Permalink
testcase : objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyodu authored Sep 10, 2024
1 parent d22737d commit 2881eff
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions testcases/objects/intro.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function handleCodeRun(code) {
try {
const capturedOutput = [];
const originalConsoleLog = console.log;
console.log = (...args) => {
capturedOutput.push(
args.map((arg) => {
if (typeof arg === "object" && arg !== null) {
return JSON.stringify(arg);
}
return arg.toString();
}).join(" "),
);
originalConsoleLog(...args);
};
if (code) {
eval(code);
}
console.log = originalConsoleLog;
return capturedOutput.join("\n");
} catch (error) {
return `${error}`;
}
}

code += "\ntry { isPass = true; if (car.manufacturer == undefined || car.model == undefined) isPass = false; } catch (e) { isPass = false; msg = e.message; }"
eval(code)

0 comments on commit 2881eff

Please sign in to comment.