Remove unused |PEG.ArrayUtils.range| utility function

redux
David Majda 14 years ago
parent 98da358ef4
commit d7d1a0b28c

@ -37,20 +37,6 @@ PEG.GrammarError.prototype = Error.prototype;
/* Array manipulation utility functions. */
PEG.ArrayUtils = {
/* Like Python's |range|, but without |step|. */
range: function(start, stop) {
if (stop === undefined) {
stop = start;
start = 0;
}
var result = new Array(Math.max(0, stop - start));
for (var i = 0, j = start; j < stop; i++, j++) {
result[i] = j;
}
return result;
},
/*
* The code needs to be in sync with the code template in the compilation
* function for "action" nodes.

@ -61,21 +61,6 @@ global.doesNotParseWithPos = function(parser, input, line, column) {
module("PEG.ArrayUtils");
test("range", function() {
deepEqual(PEG.ArrayUtils.range(-1), []);
deepEqual(PEG.ArrayUtils.range(0), []);
deepEqual(PEG.ArrayUtils.range(1), [0]);
deepEqual(PEG.ArrayUtils.range(2), [0, 1]);
deepEqual(PEG.ArrayUtils.range(3), [0, 1, 2]);
deepEqual(PEG.ArrayUtils.range(0, -1), []);
deepEqual(PEG.ArrayUtils.range(0, 0), []);
deepEqual(PEG.ArrayUtils.range(0, 1), [0]);
deepEqual(PEG.ArrayUtils.range(0, 2), [0, 1]);
deepEqual(PEG.ArrayUtils.range(0, 3), [0, 1, 2]);
deepEqual(PEG.ArrayUtils.range(-3, 0), [-3, -2, -1]);
});
test("contains", function() {
ok(!PEG.ArrayUtils.contains([], 42));

Loading…
Cancel
Save