Skip to content

Commit a1ffecb

Browse files
committed
1 parent 1a6ef9a commit a1ffecb

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/ticks.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ var e10 = Math.sqrt(50),
33
e2 = Math.sqrt(2);
44

55
export default function(start, stop, count) {
6-
var reverse = stop < start,
6+
var reverse,
77
i = -1,
88
n,
99
ticks,
1010
step;
1111

12-
if (reverse) n = start, start = stop, stop = n;
13-
12+
stop = +stop, start = +start, count = +count;
13+
if (start === stop && count > 0) return [start];
14+
if (reverse = stop < start) n = start, start = stop, stop = n;
1415
if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return [];
1516

1617
if (step > 0) {

test/ticks-test.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ tape("ticks(start, stop, count) returns the empty array if any argument is NaN",
1212
test.end();
1313
});
1414

15-
tape("ticks(start, stop, count) returns the empty array if start === stop", function(test) {
15+
tape("ticks(start, stop, count) returns the empty array if start === stop and count is non-positive", function(test) {
1616
test.deepEqual(array.ticks(1, 1, -1), []);
1717
test.deepEqual(array.ticks(1, 1, 0), []);
1818
test.deepEqual(array.ticks(1, 1, NaN), []);
19-
test.deepEqual(array.ticks(1, 1, 1), []);
20-
test.deepEqual(array.ticks(1, 1, 10), []);
19+
test.end();
20+
});
21+
22+
tape("ticks(start, stop, count) returns the empty array if start === stop and count is positive", function(test) {
23+
test.deepEqual(array.ticks(1, 1, 1), [1]);
24+
test.deepEqual(array.ticks(1, 1, 10), [1]);
2125
test.end();
2226
});
2327

0 commit comments

Comments
 (0)