mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
49412510e0
--HG-- rename : services/sync/modules/async.js => services/common/async.js rename : services/sync/modules/log4moz.js => services/common/log4moz.js rename : services/sync/modules/ext/Observers.js => services/common/observers.js rename : services/sync/modules/ext/Preferences.js => services/common/preferences.js rename : services/sync/modules/ext/StringBundle.js => services/common/stringbundle.js rename : services/sync/tests/unit/test_async_chain.js => services/common/tests/unit/test_async_chain.js rename : services/sync/tests/unit/test_async_querySpinningly.js => services/common/tests/unit/test_async_querySpinningly.js rename : services/sync/tests/unit/test_log4moz.js => services/common/tests/unit/test_log4moz.js rename : services/sync/tests/unit/test_Observers.js => services/common/tests/unit/test_observers.js rename : services/sync/tests/unit/test_Preferences.js => services/common/tests/unit/test_preferences.js rename : services/sync/tests/unit/test_restrequest.js => services/common/tests/unit/test_restrequest.js rename : services/sync/tests/unit/test_utils_makeURI.js => services/common/tests/unit/test_utils_makeURI.js rename : services/sync/tests/unit/test_utils_namedTimer.js => services/common/tests/unit/test_utils_namedTimer.js rename : services/sync/tests/unit/test_utils_stackTrace.js => services/common/tests/unit/test_utils_stackTrace.js
31 lines
811 B
JavaScript
31 lines
811 B
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
Cu.import("resource://services-common/async.js");
|
|
|
|
function run_test() {
|
|
_("Chain a few async methods, making sure the 'this' object is correct.");
|
|
|
|
let methods = {
|
|
save: function(x, callback) {
|
|
this.x = x;
|
|
callback(x);
|
|
},
|
|
addX: function(x, callback) {
|
|
callback(x + this.x);
|
|
},
|
|
double: function(x, callback) {
|
|
callback(x * 2);
|
|
},
|
|
neg: function(x, callback) {
|
|
callback(-x);
|
|
}
|
|
};
|
|
methods.chain = Async.chain;
|
|
|
|
// ((1 + 1 + 1) * (-1) + 1) * 2 + 1 = -3
|
|
methods.chain(methods.save, methods.addX, methods.addX, methods.neg,
|
|
methods.addX, methods.double, methods.addX, methods.save)(1);
|
|
do_check_eq(methods.x, -3);
|
|
}
|