"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/test.js" between
lodash-4.17.20.tar.gz and lodash-4.17.21.tar.gz

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

test.js  (lodash-4.17.20):test.js  (lodash-4.17.21)
skipping to change at line 22299 skipping to change at line 22299
var data = { 'a': [1, 2, 3] }; var data = { 'a': [1, 2, 3] };
try { try {
assert.strictEqual(compiled(data), '123'); assert.strictEqual(compiled(data), '123');
} catch (e) { } catch (e) {
assert.ok(false, e.message); assert.ok(false, e.message);
} }
}); });
QUnit.test('should forbid code injection through the "variable" options', fu
nction(assert) {
assert.expect(1);
assert.raises(function () {
_.template('', { 'variable': '){console.log(process.env)}; with(obj' });
});
});
QUnit.test('should support custom delimiters', function(assert) { QUnit.test('should support custom delimiters', function(assert) {
assert.expect(2); assert.expect(2);
lodashStable.times(2, function(index) { lodashStable.times(2, function(index) {
var settingsClone = lodashStable.clone(_.templateSettings); var settingsClone = lodashStable.clone(_.templateSettings);
var settings = lodashStable.assign(index ? _.templateSettings : {}, { var settings = lodashStable.assign(index ? _.templateSettings : {}, {
'escape': /\{\{-([\s\S]+?)\}\}/g, 'escape': /\{\{-([\s\S]+?)\}\}/g,
'evaluate': /\{\{([\s\S]+?)\}\}/g, 'evaluate': /\{\{([\s\S]+?)\}\}/g,
'interpolate': /\{\{=([\s\S]+?)\}\}/g 'interpolate': /\{\{=([\s\S]+?)\}\}/g
skipping to change at line 23778 skipping to change at line 23786
0, 2, 1, 1, 0, 2, 1, 1,
0, 0, 0, 0,
5349, 5349, 5349, 5349,
42, 42 42, 42
]; ];
} }
var actual = lodashStable.map(values, func); var actual = lodashStable.map(values, func);
assert.deepEqual(actual, expected); assert.deepEqual(actual, expected);
}); });
QUnit.test('`_.`' + methodName + '` should prevent ReDoS', function(assert)
{
assert.expect(2);
var largeStrLen = 50000,
largeStr = '1' + lodashStable.repeat(' ', largeStrLen) + '1',
maxMs = 1000,
startTime = lodashStable.now();
assert.deepEqual(_[methodName](largeStr), methodName == 'toNumber' ? NaN :
0);
var endTime = lodashStable.now(),
timeSpent = endTime - startTime;
assert.ok(timeSpent < maxMs, 'operation took ' + timeSpent + 'ms');
});
}); });
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
QUnit.module('lodash.toPairs'); QUnit.module('lodash.toPairs');
(function() { (function() {
QUnit.test('should be aliased', function(assert) { QUnit.test('should be aliased', function(assert) {
assert.expect(1); assert.expect(1);
skipping to change at line 24363 skipping to change at line 24387
QUnit.test('`_.' + methodName + '` should work with `undefined` or empty str ing values for `chars`', function(assert) { QUnit.test('`_.' + methodName + '` should work with `undefined` or empty str ing values for `chars`', function(assert) {
assert.expect(2); assert.expect(2);
var string = whitespace + 'a b c' + whitespace, var string = whitespace + 'a b c' + whitespace,
expected = (index == 2 ? whitespace : '') + 'a b c' + (index == 1 ? wh itespace : ''); expected = (index == 2 ? whitespace : '') + 'a b c' + (index == 1 ? wh itespace : '');
assert.strictEqual(func(string, undefined), expected); assert.strictEqual(func(string, undefined), expected);
assert.strictEqual(func(string, ''), string); assert.strictEqual(func(string, ''), string);
}); });
QUnit.test('`_.`' + methodName + '` should prevent ReDoS', function(assert)
{
assert.expect(2);
var largeStrLen = 50000,
largeStr = 'A' + lodashStable.repeat(' ', largeStrLen) + 'A',
maxMs = 1000,
startTime = lodashStable.now();
assert.strictEqual(_[methodName](largeStr), largeStr);
var endTime = lodashStable.now(),
timeSpent = endTime - startTime;
assert.ok(timeSpent < maxMs, 'operation took ' + timeSpent + 'ms');
});
QUnit.test('`_.' + methodName + '` should work as an iteratee for methods li ke `_.map`', function(assert) { QUnit.test('`_.' + methodName + '` should work as an iteratee for methods li ke `_.map`', function(assert) {
assert.expect(1); assert.expect(1);
var string = Object(whitespace + 'a b c' + whitespace), var string = Object(whitespace + 'a b c' + whitespace),
trimmed = (index == 2 ? whitespace : '') + 'a b c' + (index == 1 ? whi tespace : ''), trimmed = (index == 2 ? whitespace : '') + 'a b c' + (index == 1 ? whi tespace : ''),
actual = lodashStable.map([string, string, string], func); actual = lodashStable.map([string, string, string], func);
assert.deepEqual(actual, [trimmed, trimmed, trimmed]); assert.deepEqual(actual, [trimmed, trimmed, trimmed]);
}); });
 End of changes. 3 change blocks. 
0 lines changed or deleted 44 lines changed or added

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