From 4c59abe8110f8cb8d147e03bfb28b825a9ade477 Mon Sep 17 00:00:00 2001 From: Nikhil Benesch Date: Mon, 28 Jul 2014 16:11:39 -0400 Subject: [PATCH] range: don't throw if lower < upper This is a naive library. Don't attempt any sort of sanity checking until we can properly handle infinity. --- lib/range.js | 4 ---- test/range.js | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/range.js b/lib/range.js index 38df7eb..ed3dca3 100644 --- a/lib/range.js +++ b/lib/range.js @@ -25,10 +25,6 @@ function Range(lower, upper, bounds) { return; } - if (lower && upper && lower > upper) { - throw new Error("invalid range: lower bound greater than upper bound"); - } - bounds = bounds || "[)"; if (VALID_BOUNDS.indexOf(bounds) === -1) { throw new Error(util.format("invalid bounds: %s", bounds)); diff --git a/test/range.js b/test/range.js index 4a10ea2..1db72f3 100644 --- a/test/range.js +++ b/test/range.js @@ -14,10 +14,10 @@ describe("Range", function () { range.should.be.an.instanceOf(Range); }); - it("should reject ranges where lower > upper", function () { + it("should not reject ranges where lower > upper", function () { (function () { Range(2, 1, "[]"); - }).should.throw(/invalid range/); + }).should.not.throw(); }); it("should reject ranges with invalid string bounds", function () {