test262/implementation-contributed/javascriptcore/stress/json-stringify-gap-calculation-should-be-after-replacer-check.js
test262-automation 24f861721f [javascriptcore-test262-automation] Updated curation log with latest revision sha's from export and changed files.
sourceRevisionAtLastExport: 8bfa53d50 targetRevisionAtLastExport: 8bc4e38a
2018-07-29 23:55:12 -04:00

34 lines
853 B
JavaScript

var proxy = Proxy.revocable([], {});
proxy.revoke();
function shouldThrow(func, errorMessage) {
var errorThrown = false;
var error = null;
try {
func();
} catch (e) {
errorThrown = true;
error = e;
}
if (!errorThrown)
throw new Error('not thrown');
if (String(error) !== errorMessage)
throw new Error(`bad error: ${String(error)}`);
}
shouldThrow(() => {
var string = new String("Hello");
string.toString = function () {
throw new Error("Out");
};
JSON.stringify({}, proxy.proxy, string);
}, `TypeError: Array.isArray cannot be called on a Proxy that has been revoked`);
shouldThrow(() => {
var string = new String("Hello");
string.toString = function () {
throw new Error("Out");
};
JSON.stringify({}, [], string);
}, `Error: Out`);