mirror of https://github.com/tc39/test262.git
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:
parent
9b622bf093
commit
fd029d2d52
|
@ -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");
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue