测试侧用 vm.runInThisContext 加载浏览器全局脚本,正式代码不为测试加任何导出。 test_shared_sync 断言前后端 shared 逐字节一致,已做反向验证(改一个空格即红)。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
17 lines
610 B
JavaScript
17 lines
610 B
JavaScript
// 极简断言助手(测试代码不受严格 ES5 限制,dev-guide 05 §10)
|
||
module.exports = function () {
|
||
let pass = true;
|
||
let count = 0;
|
||
function eq(name, got, exp) {
|
||
const p = JSON.stringify(got) === JSON.stringify(exp);
|
||
count++;
|
||
if (!p) pass = false;
|
||
console.log((p ? 'PASS' : 'FAIL') + ' ' + name + ' got=' + JSON.stringify(got) + ' exp=' + JSON.stringify(exp));
|
||
}
|
||
function done(label) {
|
||
console.log((pass ? 'ALL PASS' : 'HAS FAILURE') + ' [' + label + '] ' + count + ' checks');
|
||
return pass;
|
||
}
|
||
return { eq, done };
|
||
};
|