Add _.trunc test for floating-point lengths.

This commit is contained in:
jdalton
2015-02-01 00:16:37 -08:00
parent 0cd942f152
commit ed1a75ef4c

View File

@@ -11762,7 +11762,7 @@
});
});
test('should coerce `start` and `end` to finite numbers', 1, function() {
test('should coerce `start` and `end` to integers', 1, function() {
var actual = [_.slice(array, 0.1, 1.1), _.slice(array, '0', 1), _.slice(array, 0, '1'), _.slice(array, '1'), _.slice(array, NaN, 1), _.slice(array, 1, NaN)];
deepEqual(actual, [[1], [1], [1], [2, 3], [1], []]);
});
@@ -12784,9 +12784,9 @@
});
});
test('should coerce `length` to a number', 4, function() {
_.each(['', '4'], function(length, index) {
var actual = index ? 'h...' : '...';
test('should coerce `length` to an integer', 8, function() {
_.each(['', NaN, 4.5, '4'], function(length, index) {
var actual = index > 1 ? 'h...' : '...';
strictEqual(_.trunc(string, length), actual);
strictEqual(_.trunc(string, { 'length': { 'valueOf': _.constant(length) } }), actual);
});