From c2058af13aa3cad10c1d391dba04ae94653a132f Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 16 May 2019 12:11:01 +0200 Subject: [PATCH] Remove unused roundUpToPowerOfTwo function --- src/ol/math.js | 11 ----------- test/spec/ol/math.test.js | 41 +-------------------------------------- 2 files changed, 1 insertion(+), 51 deletions(-) diff --git a/src/ol/math.js b/src/ol/math.js index 372780d7d9..222b9c8d0c 100644 --- a/src/ol/math.js +++ b/src/ol/math.js @@ -1,7 +1,6 @@ /** * @module ol/math */ -import {assert} from './asserts.js'; /** * Takes a number and clamps it to within the provided bounds. @@ -43,16 +42,6 @@ export const cosh = (function() { }()); -/** - * @param {number} x X. - * @return {number} The smallest power of two greater than or equal to x. - */ -export function roundUpToPowerOfTwo(x) { - assert(0 < x, 29); // `x` must be greater than `0` - return Math.pow(2, Math.ceil(Math.log(x) / Math.LN2)); -} - - /** * Returns the square of the closest distance between the point (x, y) and the * line segment (x1, y1) to (x2, y2). diff --git a/test/spec/ol/math.test.js b/test/spec/ol/math.test.js index a5a8d98f64..d499d6c800 100644 --- a/test/spec/ol/math.test.js +++ b/test/spec/ol/math.test.js @@ -1,4 +1,4 @@ -import {clamp, lerp, cosh, roundUpToPowerOfTwo, solveLinearSystem, toDegrees, toRadians, modulo} from '../../../src/ol/math.js'; +import {clamp, lerp, cosh, solveLinearSystem, toDegrees, toRadians, modulo} from '../../../src/ol/math.js'; describe('ol.math.clamp', function() { @@ -49,45 +49,6 @@ describe('ol.math.cosh', function() { }); -describe('ol.math.roundUpToPowerOfTwo', function() { - - it('raises an exception when x is negative', function() { - expect(function() { - roundUpToPowerOfTwo(-1); - }).to.throwException(); - }); - - it('raises an exception when x is zero', function() { - expect(function() { - roundUpToPowerOfTwo(0); - }).to.throwException(); - }); - - it('returns the expected value for simple powers of two', function() { - expect(roundUpToPowerOfTwo(1)).to.be(1); - expect(roundUpToPowerOfTwo(2)).to.be(2); - expect(roundUpToPowerOfTwo(4)).to.be(4); - expect(roundUpToPowerOfTwo(8)).to.be(8); - expect(roundUpToPowerOfTwo(16)).to.be(16); - expect(roundUpToPowerOfTwo(32)).to.be(32); - expect(roundUpToPowerOfTwo(64)).to.be(64); - expect(roundUpToPowerOfTwo(128)).to.be(128); - expect(roundUpToPowerOfTwo(256)).to.be(256); - }); - - it('returns the expected value for simple powers of ten', function() { - expect(roundUpToPowerOfTwo(1)).to.be(1); - expect(roundUpToPowerOfTwo(10)).to.be(16); - expect(roundUpToPowerOfTwo(100)).to.be(128); - expect(roundUpToPowerOfTwo(1000)).to.be(1024); - expect(roundUpToPowerOfTwo(10000)).to.be(16384); - expect(roundUpToPowerOfTwo(100000)).to.be(131072); - expect(roundUpToPowerOfTwo(1000000)).to.be(1048576); - expect(roundUpToPowerOfTwo(10000000)).to.be(16777216); - }); - -}); - describe('ol.math.solveLinearSystem', function() { it('calculates correctly', function() {