Increase precision of assertions for Error Cause

Minimize the code provided to the `assert.throws` utility in order to
reduce the possibility of false positives and to improve failure
messages in non-conforming runtimes.
This commit is contained in:
Mike Pennisi 2021-04-23 14:55:09 -04:00 committed by Rick Waldron
parent 9b622bf093
commit fd029d2d52
1 changed files with 17 additions and 15 deletions

View File

@ -22,29 +22,31 @@ features: [error-cause]
---*/ ---*/
var message = "my-message"; var message = "my-message";
var options;
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// CHECK#0 // CHECK#0
options = new Proxy({}, {
has(target, prop) {
if (prop === "cause") {
throw new Test262Error("HasProperty");
}
return prop in target;
},
});
assert.throws(Test262Error, function () { assert.throws(Test262Error, function () {
var options = new Proxy({}, { new Error(message, options);
has(target, prop) {
if (prop === "cause") {
throw new Test262Error("HasProperty");
}
return prop in target;
},
});
var error = new Error(message, options);
}, "HasProperty"); }, "HasProperty");
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// CHECK#1 // CHECK#1
options = {
get cause() {
throw new Test262Error("Get Cause");
},
};
assert.throws(Test262Error, function () { assert.throws(Test262Error, function () {
var options = { new Error(message, options);
get cause() {
throw new Test262Error("Get Cause");
},
};
var error = new Error(message, options);
}, "Get Cause"); }, "Get Cause");
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////