зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1237961 - Assert.throws raises a TypeError exception when the "expected" parameter is an arrow function. r=mikedeboer
MozReview-Commit-ID: CyhD00Uwbwj --HG-- extra : rebase_source : 24a80ca12bfdded82f4bc3487ee491defa60da7b
This commit is contained in:
Родитель
43c1d4a481
Коммит
bfb4e9151f
|
@ -314,7 +314,10 @@ function expectedException(actual, expected) {
|
|||
|
||||
if (instanceOf(expected, "RegExp")) {
|
||||
return expected.test(actual);
|
||||
} else if (actual instanceof expected) {
|
||||
// We need to guard against the right hand parameter of "instanceof" lacking
|
||||
// the "prototype" property, which is true of arrow functions in particular.
|
||||
} else if (!(typeof expected === "function" && !expected.prototype) &&
|
||||
actual instanceof expected) {
|
||||
return true;
|
||||
} else if (expected.call({}, actual) === true) {
|
||||
return true;
|
||||
|
|
|
@ -208,6 +208,12 @@ function run_test() {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
// do the same with an arrow function
|
||||
assert.throws(makeBlock(thrower, TypeError), err => {
|
||||
if ((err instanceof TypeError) && /test/.test(err)) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
function testAssertionMessage(actual, expected) {
|
||||
try {
|
||||
|
|
Загрузка…
Ссылка в новой задаче