Files
Zachary D. Rowitsch 2240f6c518 Expand Test262 coverage to 550 tests (Phase B)
Vendor 500 new real Test262 tests (total 550), relax curation filters for
now-supported features (arrow functions, classes, destructuring, spread/rest,
for-in/of, template literals, let/const, instanceof), add automated triage
script, and track pass rate as a CI metric. 190/550 pass (34.5%).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 14:20:22 -05:00

71 lines
2.1 KiB
JavaScript

// Test262 harness shim: assert.js
// Uses function + property assignment (requires function property support).
// Implements SameValue semantics per ES2015 7.2.10.
function assert(mustBeTrue, message) {
if (!mustBeTrue) {
if (typeof message === "undefined") {
message = "Expected true but got false";
}
throw "Test262Error: " + message;
}
}
// SameValue(x, y) per ES2015 7.2.10:
// SameValue(NaN, NaN) = true (unlike ===)
// SameValue(+0, -0) = false (unlike ===)
assert._isSameValue = function(a, b) {
// NaN check: NaN is the only value where x !== x
if (a !== a && b !== b) {
return true;
}
// +0 / -0 check: 1/+0 = +Infinity, 1/-0 = -Infinity
if (a === 0 && b === 0) {
return 1/a === 1/b;
}
return a === b;
};
assert.sameValue = function(actual, expected, message) {
if (!assert._isSameValue(actual, expected)) {
if (typeof message === "undefined") {
message = "Expected SameValue(" + actual + ", " + expected + ") to be true";
}
throw "Test262Error: " + message;
}
};
assert.notSameValue = function(actual, unexpected, message) {
if (assert._isSameValue(actual, unexpected)) {
if (typeof message === "undefined") {
message = "Expected SameValue(" + actual + ", " + unexpected + ") to be false";
}
throw "Test262Error: " + message;
}
};
assert.throws = function(expectedErrorConstructor, func, message) {
var threw = false;
var caughtError;
try {
func();
} catch(e) {
threw = true;
caughtError = e;
}
if (!threw) {
if (typeof message === "undefined") {
message = "Expected function to throw";
}
throw "Test262Error: " + message;
}
if (expectedErrorConstructor !== undefined) {
if (!(caughtError instanceof expectedErrorConstructor)) {
if (typeof message === "undefined") {
message = "Expected a " + expectedErrorConstructor.name + " but got " + caughtError;
}
throw "Test262Error: " + message;
}
}
};