mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 557591 - Add tests for Utils.catch.
--HG-- extra : rebase_source : 545492072668cfb6862dde756506e12cf43d4375
This commit is contained in:
parent
1eb66ef77b
commit
ff586e08e3
42
services/sync/tests/unit/test_utils_catch.js
Normal file
42
services/sync/tests/unit/test_utils_catch.js
Normal file
@ -0,0 +1,42 @@
|
||||
_("Make sure catch when copied to an object will correctly catch stuff");
|
||||
Cu.import("resource://weave/util.js");
|
||||
|
||||
function run_test() {
|
||||
let ret, rightThis, didCall, didThrow;
|
||||
let obj = {
|
||||
catch: Utils.catch,
|
||||
_log: {
|
||||
debug: function(str) {
|
||||
didThrow = str.search(/^Exception: /) == 0;
|
||||
}
|
||||
},
|
||||
|
||||
func: function() this.catch(function() {
|
||||
rightThis = this == obj;
|
||||
didCall = true;
|
||||
return 5;
|
||||
})(),
|
||||
|
||||
throwy: function() this.catch(function() {
|
||||
rightThis = this == obj;
|
||||
didCall = true;
|
||||
throw 10;
|
||||
})()
|
||||
};
|
||||
|
||||
_("Make sure a normal call will call and return");
|
||||
rightThis = didCall = didThrow = false;
|
||||
ret = obj.func();
|
||||
do_check_eq(ret, 5);
|
||||
do_check_true(rightThis);
|
||||
do_check_true(didCall);
|
||||
do_check_false(didThrow);
|
||||
|
||||
_("Make sure catch/throw results in debug call and caller doesn't need to handle exception");
|
||||
rightThis = didCall = didThrow = false;
|
||||
ret = obj.throwy();
|
||||
do_check_eq(ret, undefined);
|
||||
do_check_true(rightThis);
|
||||
do_check_true(didCall);
|
||||
do_check_true(didThrow);
|
||||
}
|
Loading…
Reference in New Issue
Block a user