Infer sign of range's step when only start and end are provided.

This commit is contained in:
John-David Dalton
2015-11-26 21:14:24 -06:00
parent 826af968c8
commit 2dd6f0124e
3 changed files with 12 additions and 12 deletions

View File

@@ -15555,27 +15555,25 @@
QUnit.module('lodash.range');
(function() {
QUnit.test('should work with only an `end` argument', function(assert) {
assert.expect(1);
QUnit.test('should infer the sign of `step` when provided only an `end` argument', function(assert) {
assert.expect(2);
assert.deepEqual(_.range(4), [0, 1, 2, 3]);
});
QUnit.test('should use a `step` of `-1` when provided only a negative `end` argument', function(assert) {
assert.expect(1);
assert.deepEqual(_.range(-4), [0, -1, -2, -3]);
});
QUnit.test('should work with `start` and `end` arguments', function(assert) {
assert.expect(1);
QUnit.test('should infer the sign of `step` when provided only a `start` and `end` argument', function(assert) {
assert.expect(2);
assert.deepEqual(_.range(1, 5), [1, 2, 3, 4]);
assert.deepEqual(_.range(5, 1), [5, 4, 3, 2]);
});
QUnit.test('should work with `start`, `end`, and `step` arguments', function(assert) {
assert.expect(1);
assert.expect(3);
assert.deepEqual(_.range(0, -4, -1), [0, -1, -2, -3]);
assert.deepEqual(_.range(5, 1, -1), [5, 4, 3, 2]);
assert.deepEqual(_.range(0, 20, 5), [0, 5, 10, 15]);
});