if (typeof globalThis === 'undefined') {
try {
this.globalThis = this;
} catch (e) {
this.globalThis = (function(){ return this; })();
}
}
if (typeof $DONE === 'undefined') {
function $DONE(err) {
if (err) {
throw err;
}
}
console.log('block-scoped typeof $DONE:', typeof $DONE);
}
console.log('global typeof $DONE:', typeof $DONE);
if (typeof $262 === 'undefined') {
var $262 = {
createRealm: function() { return {}; },
detachArrayBuffer: function(buf) { },
evalScript: function(s) { return eval(s); },
};
}
console.log('typeof $262:', typeof $262);
if (typeof Test262Error === 'undefined') {
function Test262Error(message) {
this.message = message;
}
Test262Error.prototype = {};
Test262Error.prototype.constructor = Test262Error;
Test262Error.prototype.name = 'Test262Error';
Test262Error.prototype.toString = function() { return (this.name || 'Test262Error') + (this.message ? ': ' + this.message : ''); };
this.Test262Error = Test262Error;
}
if (typeof Error === 'undefined') {
function Error(message) {
this.message = message;
}
Error.prototype = {};
Error.prototype.constructor = Error;
this.Error = Error;
}
if (typeof assert === 'undefined') {
function assert(cond) {
if (!cond) throw new Test262Error('assertion failed');
}
this.assert = assert;
}
console.log('typeof assert:', typeof assert);
var threw = false;
try {
assert(false);
} catch(err) {
threw = true;
if (err.constructor !== Test262Error) {
throw new Error(
'Expected a Test262Error, but a "' + err.constructor.name +
'" was thrown.'
);
}
}
if (threw === false) {
throw new Error('Expected a Test262Error, but no error was thrown.');
}
console.log('Test262Error successfully thrown.');