Skip to content

Commit

Permalink
test262/harness: basic sm
Browse files Browse the repository at this point in the history
test262: 55.10% (+0.06) | πŸ§ͺ 50255 | 🀠 27693 (+31) | ❌ 7209 (+11) | πŸ’€ 14002 (-42) | πŸ—οΈ 32 (-1) | πŸ’₯ 182 (+3) | ⏰ 140 | πŸ“ 997 (-2)
  • Loading branch information
CanadaHonk committed Dec 14, 2024
1 parent de317fe commit c06fd49
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 2 deletions.
129 changes: 128 additions & 1 deletion test262/harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -1382,4 +1382,131 @@ const assertNativeFunction = function(fn, special) {
} catch {
throw new Test262Error('assertNativeFunction failed');
}
};
};

/// sm/non262.js
function print() {}
function printBugNumber() {}
function inSection() {}
function printStatus() {}
function writeHeaderToLog() {}

function assertThrownErrorContains(f, substr) {
try {
f();
} catch {
return;
}

throw new Test262Error("Expected error no exception thrown");
}

function assertThrowsInstanceOfWithMessageCheck(f, ctor, _check, msg) {
var fullmsg;
try {
f();
} catch (exc) {
if (exc instanceof ctor)
return;
fullmsg = `Assertion failed: expected exception ${ctor.name}, got ${exc}`;
}

if (fullmsg === undefined)
fullmsg = `Assertion failed: expected exception ${ctor.name}, no exception thrown`;
if (msg !== undefined)
fullmsg += " - " + msg;

throw new Error(fullmsg);
}

function assertEq(a, b) {
assert.sameValue(a, b);
}
function reportCompare(a, b) {
assert.sameValue(a, b);
}

function reportMatch(expectedRegExp, actual) {
assert.sameValue(typeof actual, "string");
assert.notSameValue(expectedRegExp.exec(actual), null);
}

function createExternalArrayBuffer(size) {
return new ArrayBuffer(size);
}

function enableGeckoProfilingWithSlowAssertions() {}
function enableGeckoProfiling() {}
function disableGeckoProfiling() {}

// sm/non262-shell.js
function deepEqual(a, b) {
if (typeof a != typeof b)
return false;

if (typeof a == 'object') {
var props = {};
for (var prop in a) {
if (!deepEqual(a[prop], b[prop]))
return false;
props[prop] = true;
}

for (var prop in b)
if (!props[prop])
return false;

return a.length == b.length;
}

if (a === b) {
return a !== 0 || 1/a === 1/b;
}

return a !== a && b !== b;
}

function assertThrowsValue(f, val, msg) {
var fullmsg;
try {
f();
} catch (exc) {
if ((exc === val) === (val === val) && (val !== 0 || 1 / exc === 1 / val))
return;
}

throw new Error('assertThrowsValue failed');
};

function assertThrownErrorContains(thunk, substr) {
try {
thunk();
} catch {
return;
}

throw new Error("Expected error no exception thrown");
};

function assertThrowsInstanceOfWithMessageCheck(f, ctor, check, msg) {
var fullmsg;
try {
f();
} catch (exc) {
if (exc instanceof ctor) return;
}

throw new Error('assertThrowsInstanceOfWithMessageCheck failed');
};

function assertThrowsInstanceOf(f, ctor, msg) {
assertThrowsInstanceOfWithMessageCheck(f, ctor, _ => true, msg);
};

function assertThrowsInstanceOfWithMessage(f, ctor, expected, msg) {
assertThrowsInstanceOfWithMessageCheck(f, ctor, message => message === expected, msg);
}

function assertThrowsInstanceOfWithMessageContains(f, ctor, substr, msg) {
assertThrowsInstanceOfWithMessageCheck(f, ctor, message => message.indexOf(substr) !== -1, msg);
}
2 changes: 1 addition & 1 deletion test262/history.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions test262/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,11 @@ if (isMainThread) {
contents;
}

// hack: skip compiler timeouts
if (test.file === 'test/staging/sm/String/normalize-generateddata-input.js') {
contents = 'throw "skipped";';
}

if (debugAsserts) contents = contents
.replace('var assert = mustBeTrue => {', 'var assert = (mustBeTrue, msg) => {')
.replaceAll('(actual, expected) => {', '(actual, expected, msg) => {')
Expand Down

0 comments on commit c06fd49

Please sign in to comment.