Remove `enforce_arity` function from util.js.

Remove `enforce_arity` function from util.js, because it is
not used anymore.
This commit is contained in:
Rafid Aslam 2016-12-03 21:52:56 +07:00 committed by Tim Abbott
parent 3b891ef080
commit 426cb13e23
2 changed files with 0 additions and 38 deletions

View File

@ -116,33 +116,6 @@ var _ = global._;
});
}());
(function test_enforce_arity() {
function f1() {}
var eaf1 = util.enforce_arity(f1);
assert.doesNotThrow(function () { f1('foo'); });
assert.doesNotThrow(function () { eaf1(); });
assert.throws(function () { eaf1('foo'); }, /called with \d+ arguments/);
assert.throws(function () { eaf1('foo', 'bar'); }, /called with \d+ arguments/);
function f2(x) {}
var eaf2 = util.enforce_arity(f2);
assert.doesNotThrow(function () { f2(); });
assert.doesNotThrow(function () { eaf2('foo'); });
assert.throws(function () { eaf2(); }, /called with \d+ arguments/);
assert.throws(function () { eaf2('foo', 'bar'); }, /called with \d+ arguments/);
function f3(x, y) {}
var eaf3 = util.enforce_arity(f3);
assert.doesNotThrow(function () { f3(); });
assert.doesNotThrow(function () { eaf3('foo', 'bar'); });
assert.throws(function () { eaf3(); }, /called with \d+ arguments/);
assert.throws(function () { eaf3('foo'); }, /called with \d+ arguments/);
assert.throws(function () { eaf3('foo','bar', 'baz'); }, /called with \d+ arguments/);
}());
(function test_all_and_everyone_mentions_regexp() {
var messages_with_all_mentions = [
'@all',

View File

@ -214,17 +214,6 @@ exports.CachedValue.prototype = {
}
};
exports.enforce_arity = function util_enforce_arity(func) {
return function () {
if (func.length !== arguments.length) {
throw new Error("Function '" + func.name + "' called with "
+ arguments.length + " arguments, but expected "
+ func.length);
}
return func.apply(this, arguments);
};
};
exports.execute_early = function (func) {
if (page_params.test_suite) {
$(document).one('phantom_page_loaded', func);