зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1280362 - Move assertThrowsInstanceOf into shell.js's IIFE. r=arai
--HG-- extra : rebase_source : 658e8d233b5f387598b10d8228f5aef3699df58c
This commit is contained in:
Родитель
73045413bb
Коммит
520c357e28
|
@ -55,6 +55,29 @@
|
|||
}
|
||||
global.assertThrows = assertThrows;
|
||||
|
||||
function assertThrowsInstanceOf(f, ctor, msg) {
|
||||
var fullmsg;
|
||||
try {
|
||||
f();
|
||||
} catch (exc) {
|
||||
if (exc instanceof ctor)
|
||||
return;
|
||||
fullmsg =
|
||||
"Assertion failed: expected exception " + ctor.name + ", got " + exc;
|
||||
}
|
||||
|
||||
if (fullmsg === undefined) {
|
||||
fullmsg =
|
||||
"Assertion failed: expected exception " + ctor.name + ", " +
|
||||
"no exception thrown";
|
||||
}
|
||||
if (msg !== undefined)
|
||||
fullmsg += " - " + msg;
|
||||
|
||||
throw new Error(fullmsg);
|
||||
}
|
||||
global.assertThrowsInstanceOf = assertThrowsInstanceOf;
|
||||
|
||||
/****************************
|
||||
* UTILITY FUNCTION EXPORTS *
|
||||
****************************/
|
||||
|
@ -936,19 +959,3 @@ function assertEqArray(a1, a2) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function assertThrowsInstanceOf(f, ctor, msg) {
|
||||
var fullmsg;
|
||||
try {
|
||||
f();
|
||||
} catch (exc) {
|
||||
if (exc instanceof ctor)
|
||||
return;
|
||||
fullmsg = "Assertion failed: expected exception " + ctor.name + ", got " + exc;
|
||||
}
|
||||
if (fullmsg === undefined)
|
||||
fullmsg = "Assertion failed: expected exception " + ctor.name + ", no exception thrown";
|
||||
if (msg !== undefined)
|
||||
fullmsg += " - " + msg;
|
||||
throw new Error(fullmsg);
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче