From d7d1a0b28ccad4f5b7595af1baa23b8c6ec16146 Mon Sep 17 00:00:00 2001 From: David Majda Date: Sat, 24 Jul 2010 16:38:20 +0200 Subject: [PATCH] Remove unused |PEG.ArrayUtils.range| utility function --- lib/compiler.js | 14 -------------- test/compiler-test.js | 15 --------------- 2 files changed, 29 deletions(-) diff --git a/lib/compiler.js b/lib/compiler.js index 47e2d08..f2ad33e 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -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. diff --git a/test/compiler-test.js b/test/compiler-test.js index 1e9cae4..56d0815 100644 --- a/test/compiler-test.js +++ b/test/compiler-test.js @@ -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));