|
95 | 95 | assert.equal(undefPropertyOf('curly'), void 0, 'should return undefined when obj is undefined');
|
96 | 96 | });
|
97 | 97 |
|
| 98 | + QUnit.test('method', function(assert) { |
| 99 | + var stooge = {name: function () { |
| 100 | + return 'moe'; |
| 101 | + }, sum: function(a,b,c) { |
| 102 | + return a + b + c |
| 103 | + }}; |
| 104 | + assert.equal(_.method('name')(stooge), 'moe', 'should return the results of calling the method with the given name'); |
| 105 | + assert.equal(_.method('sum')(stooge, 1, 2, 3), 6, 'passes rest of arguments to named method for evaluation'); |
| 106 | + assert.equal(_.method(function () { return this.name(); })(stooge), 'moe', 'attempts to apply a function literal passed.'); |
| 107 | + assert.equal(_.method(function (a,b,c) { return this.sum(a,b,c); })(stooge, 1, 2, 3), 6, 'passes arguments when applying a function literal.'); |
| 108 | + assert.equal(_.method('macerena')(stooge), void 0, 'should return undefined for non-existant method name on defined object'); |
| 109 | + assert.equal(_.method('name')(null), void 0, 'should return undefined for null object'); |
| 110 | + assert.equal(_.method()(stooge), void 0, 'should return undefined for undefined method name on existing object'); |
| 111 | + assert.equal(_.method()(void 0), void 0, 'should return undefined for undefined method name on undefined object'); |
| 112 | + }); |
| 113 | + |
98 | 114 | QUnit.test('random', function(assert) {
|
99 | 115 | var array = _.range(1000);
|
100 | 116 | var min = Math.pow(2, 31);
|
|
0 commit comments