"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "vendor/underscore/test/utility.js" between
lodash-4.0.0.tar.gz and lodash-4.17.21.tar.gz

About: lodash is a modern JavaScript utility library delivering modularity, performance, & extras. Tagged version.

utility.js  (lodash-4.0.0):utility.js  (lodash-4.17.21)
skipping to change at line 55 skipping to change at line 55
assert.equal(context.underscore.VERSION, _.VERSION); assert.equal(context.underscore.VERSION, _.VERSION);
done(); done();
}); });
}); });
} }
QUnit.test('#750 - Return _ instance.', function(assert) { QUnit.test('#750 - Return _ instance.', function(assert) {
assert.expect(2); assert.expect(2);
var instance = _([]); var instance = _([]);
assert.ok(_(instance) === instance); assert.strictEqual(_(instance), instance);
assert.ok(new _(instance) === instance); assert.strictEqual(new _(instance), instance);
}); });
QUnit.test('identity', function(assert) { QUnit.test('identity', function(assert) {
var stooge = {name: 'moe'}; var stooge = {name: 'moe'};
assert.equal(_.identity(stooge), stooge, 'stooge is the same as his identity '); assert.equal(_.identity(stooge), stooge, 'stooge is the same as his identity ');
}); });
QUnit.test('constant', function(assert) { QUnit.test('constant', function(assert) {
var stooge = {name: 'moe'}; var stooge = {name: 'moe'};
assert.equal(_.constant(stooge)(), stooge, 'should create a function that re turns stooge'); assert.equal(_.constant(stooge)(), stooge, 'should create a function that re turns stooge');
skipping to change at line 140 skipping to change at line 140
assert.deepEqual(vals, [0, 1, 2], 'works as a wrapper'); assert.deepEqual(vals, [0, 1, 2], 'works as a wrapper');
// collects return values // collects return values
assert.deepEqual([0, 1, 2], _.times(3, function(i) { return i; }), 'collects return values'); assert.deepEqual([0, 1, 2], _.times(3, function(i) { return i; }), 'collects return values');
assert.deepEqual(_.times(0, _.identity), []); assert.deepEqual(_.times(0, _.identity), []);
assert.deepEqual(_.times(-1, _.identity), []); assert.deepEqual(_.times(-1, _.identity), []);
assert.deepEqual(_.times(parseFloat('-Infinity'), _.identity), []); assert.deepEqual(_.times(parseFloat('-Infinity'), _.identity), []);
}); });
QUnit.test('mixin', function(assert) { QUnit.test('mixin', function(assert) {
_.mixin({ var ret = _.mixin({
myReverse: function(string) { myReverse: function(string) {
return string.split('').reverse().join(''); return string.split('').reverse().join('');
} }
}); });
assert.equal(ret, _, 'returns the _ object to facilitate chaining');
assert.equal(_.myReverse('panacea'), 'aecanap', 'mixed in a function to _'); assert.equal(_.myReverse('panacea'), 'aecanap', 'mixed in a function to _');
assert.equal(_('champ').myReverse(), 'pmahc', 'mixed in a function to the OO P wrapper'); assert.equal(_('champ').myReverse(), 'pmahc', 'mixed in a function to the OO P wrapper');
}); });
QUnit.test('_.escape', function(assert) { QUnit.test('_.escape', function(assert) {
assert.equal(_.escape(null), ''); assert.equal(_.escape(null), '');
}); });
QUnit.test('_.unescape', function(assert) { QUnit.test('_.unescape', function(assert) {
var string = 'Curly & Moe'; var string = 'Curly & Moe';
skipping to change at line 191 skipping to change at line 192
allEscaped += allEscaped; allEscaped += allEscaped;
assert.ok(_.every(escapeCharacters, function(escapeChar) { assert.ok(_.every(escapeCharacters, function(escapeChar) {
return allEscaped.indexOf(escapeChar) !== -1; return allEscaped.indexOf(escapeChar) !== -1;
}), 'handles multiple characters'); }), 'handles multiple characters');
assert.ok(allEscaped.indexOf(joiner) >= 0, 'can escape multiple escape chara cters at the same time'); assert.ok(allEscaped.indexOf(joiner) >= 0, 'can escape multiple escape chara cters at the same time');
// test & -> & // test & -> &
var str = 'some string & another string & yet another'; var str = 'some string & another string & yet another';
var escaped = _.escape(str); var escaped = _.escape(str);
assert.ok(escaped.indexOf('&') !== -1, 'handles & aka &'); assert.notStrictEqual(escaped.indexOf('&'), -1, 'handles & aka &');
assert.equal(_.unescape(str), str, 'can unescape &'); assert.equal(_.unescape(str), str, 'can unescape &');
}); });
QUnit.test('template', function(assert) { QUnit.test('template', function(assert) {
var basicTemplate = _.template("<%= thing %> is gettin' on my noives!"); var basicTemplate = _.template("<%= thing %> is gettin' on my noives!");
var result = basicTemplate({thing: 'This'}); var result = basicTemplate({thing: 'This'});
assert.equal(result, "This is gettin' on my noives!", 'can do basic attribut e interpolation'); assert.equal(result, "This is gettin' on my noives!", 'can do basic attribut e interpolation');
var sansSemicolonTemplate = _.template('A <% this %> B'); var sansSemicolonTemplate = _.template('A <% this %> B');
assert.equal(sansSemicolonTemplate(), 'A B'); assert.equal(sansSemicolonTemplate(), 'A B');
skipping to change at line 373 skipping to change at line 374
QUnit.test('_.templateSettings.variable', function(assert) { QUnit.test('_.templateSettings.variable', function(assert) {
var s = '<%=data.x%>'; var s = '<%=data.x%>';
var data = {x: 'x'}; var data = {x: 'x'};
var tmp = _.template(s, {variable: 'data'}); var tmp = _.template(s, {variable: 'data'});
assert.strictEqual(tmp(data), 'x'); assert.strictEqual(tmp(data), 'x');
_.templateSettings.variable = 'data'; _.templateSettings.variable = 'data';
assert.strictEqual(_.template(s)(data), 'x'); assert.strictEqual(_.template(s)(data), 'x');
}); });
QUnit.test('#547 - _.templateSettings is unchanged by custom settings.', funct ion(assert) { QUnit.test('#547 - _.templateSettings is unchanged by custom settings.', funct ion(assert) {
assert.ok(!_.templateSettings.variable); assert.notOk(_.templateSettings.variable);
_.template('', {}, {variable: 'x'}); _.template('', {}, {variable: 'x'});
assert.ok(!_.templateSettings.variable); assert.notOk(_.templateSettings.variable);
}); });
QUnit.test('#556 - undefined template variables.', function(assert) { QUnit.test('#556 - undefined template variables.', function(assert) {
var template = _.template('<%=x%>'); var template = _.template('<%=x%>');
assert.strictEqual(template({x: null}), ''); assert.strictEqual(template({x: null}), '');
assert.strictEqual(template({x: void 0}), ''); assert.strictEqual(template({x: void 0}), '');
var templateEscaped = _.template('<%-x%>'); var templateEscaped = _.template('<%-x%>');
assert.strictEqual(templateEscaped({x: null}), ''); assert.strictEqual(templateEscaped({x: null}), '');
assert.strictEqual(templateEscaped({x: void 0}), ''); assert.strictEqual(templateEscaped({x: void 0}), '');
skipping to change at line 400 skipping to change at line 401
var templateWithPropertyEscaped = _.template('<%-x.foo%>'); var templateWithPropertyEscaped = _.template('<%-x.foo%>');
assert.strictEqual(templateWithPropertyEscaped({x: {}}), ''); assert.strictEqual(templateWithPropertyEscaped({x: {}}), '');
assert.strictEqual(templateWithPropertyEscaped({x: {}}), ''); assert.strictEqual(templateWithPropertyEscaped({x: {}}), '');
}); });
QUnit.test('interpolate evaluates code only once.', function(assert) { QUnit.test('interpolate evaluates code only once.', function(assert) {
assert.expect(2); assert.expect(2);
var count = 0; var count = 0;
var template = _.template('<%= f() %>'); var template = _.template('<%= f() %>');
template({f: function(){ assert.ok(!count++); }}); template({f: function(){ assert.notOk(count++); }});
var countEscaped = 0; var countEscaped = 0;
var templateEscaped = _.template('<%- f() %>'); var templateEscaped = _.template('<%- f() %>');
templateEscaped({f: function(){ assert.ok(!countEscaped++); }}); templateEscaped({f: function(){ assert.notOk(countEscaped++); }});
}); });
QUnit.test('#746 - _.template settings are not modified.', function(assert) { QUnit.test('#746 - _.template settings are not modified.', function(assert) {
assert.expect(1); assert.expect(1);
var settings = {}; var settings = {};
_.template('', null, settings); _.template('', null, settings);
assert.deepEqual(settings, {}); assert.deepEqual(settings, {});
}); });
QUnit.test('#779 - delimeters are applied to unescaped text.', function(assert ) { QUnit.test('#779 - delimeters are applied to unescaped text.', function(assert ) {
 End of changes. 8 change blocks. 
8 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)