Merge pull request #5619 from ahocevar/remove-goog-asserts

Remove goog.asserts.*
This commit is contained in:
Andreas Hocevar
2016-08-04 23:02:38 +02:00
committed by GitHub
157 changed files with 1429 additions and 1676 deletions

View File

@@ -1,6 +1,5 @@
goog.provide('ol.geom.flat.closest');
goog.require('goog.asserts');
goog.require('ol.math');
@@ -148,7 +147,7 @@ ol.geom.flat.closest.getClosestPoint = function(flatCoordinates, offset, end,
return minSquaredDistance;
}
}
goog.asserts.assert(maxDelta > 0, 'maxDelta should be larger than 0');
goog.DEBUG && console.assert(maxDelta > 0, 'maxDelta should be larger than 0');
var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
var index = offset + stride;
while (index < end) {

View File

@@ -1,6 +1,5 @@
goog.provide('ol.geom.flat.contains');
goog.require('goog.asserts');
goog.require('ol.extent');
@@ -65,7 +64,7 @@ ol.geom.flat.contains.linearRingContainsXY = function(flatCoordinates, offset, e
* @return {boolean} Contains (x, y).
*/
ol.geom.flat.contains.linearRingsContainsXY = function(flatCoordinates, offset, ends, stride, x, y) {
goog.asserts.assert(ends.length > 0, 'ends should not be an empty array');
goog.DEBUG && console.assert(ends.length > 0, 'ends should not be an empty array');
if (ends.length === 0) {
return false;
}
@@ -94,7 +93,7 @@ ol.geom.flat.contains.linearRingsContainsXY = function(flatCoordinates, offset,
* @return {boolean} Contains (x, y).
*/
ol.geom.flat.contains.linearRingssContainsXY = function(flatCoordinates, offset, endss, stride, x, y) {
goog.asserts.assert(endss.length > 0, 'endss should not be an empty array');
goog.DEBUG && console.assert(endss.length > 0, 'endss should not be an empty array');
if (endss.length === 0) {
return false;
}

View File

@@ -1,7 +1,5 @@
goog.provide('ol.geom.flat.deflate');
goog.require('goog.asserts');
/**
* @param {Array.<number>} flatCoordinates Flat coordinates.
@@ -11,7 +9,7 @@ goog.require('goog.asserts');
* @return {number} offset Offset.
*/
ol.geom.flat.deflate.coordinate = function(flatCoordinates, offset, coordinate, stride) {
goog.asserts.assert(coordinate.length == stride,
goog.DEBUG && console.assert(coordinate.length == stride,
'length of the coordinate array should match stride');
var i, ii;
for (i = 0, ii = coordinate.length; i < ii; ++i) {
@@ -32,7 +30,7 @@ ol.geom.flat.deflate.coordinates = function(flatCoordinates, offset, coordinates
var i, ii;
for (i = 0, ii = coordinates.length; i < ii; ++i) {
var coordinate = coordinates[i];
goog.asserts.assert(coordinate.length == stride,
goog.DEBUG && console.assert(coordinate.length == stride,
'length of coordinate array should match stride');
var j;
for (j = 0; j < stride; ++j) {

View File

@@ -1,7 +1,5 @@
goog.provide('ol.geom.flat.flip');
goog.require('goog.asserts');
/**
* @param {Array.<number>} flatCoordinates Flat coordinates.
@@ -18,8 +16,6 @@ ol.geom.flat.flip.flipXY = function(flatCoordinates, offset, end, stride, opt_de
dest = opt_dest;
destOffset = opt_destOffset !== undefined ? opt_destOffset : 0;
} else {
goog.asserts.assert(opt_destOffset === undefined,
'opt_destOffSet should be defined');
dest = [];
destOffset = 0;
}

View File

@@ -1,6 +1,5 @@
goog.provide('ol.geom.flat.geodesic');
goog.require('goog.asserts');
goog.require('ol.math');
goog.require('ol.proj');
@@ -65,7 +64,7 @@ ol.geom.flat.geodesic.line_ = function(interpolate, transform, squaredTolerance)
// segment.
flatCoordinates.push(b[0], b[1]);
key = fracB.toString();
goog.asserts.assert(!(key in fractions),
goog.DEBUG && console.assert(!(key in fractions),
'fractions object should contain key : ' + key);
fractions[key] = true;
} else {
@@ -76,7 +75,7 @@ ol.geom.flat.geodesic.line_ = function(interpolate, transform, squaredTolerance)
geoStack.push(geoB, geoM, geoM, geoA);
}
}
goog.asserts.assert(maxIterations > 0,
goog.DEBUG && console.assert(maxIterations > 0,
'maxIterations should be more than 0');
return flatCoordinates;

View File

@@ -1,6 +1,5 @@
goog.provide('ol.geom.flat.interiorpoint');
goog.require('goog.asserts');
goog.require('ol.array');
goog.require('ol.geom.flat.contains');
@@ -79,7 +78,7 @@ ol.geom.flat.interiorpoint.linearRings = function(flatCoordinates, offset,
* @return {Array.<number>} Interior points.
*/
ol.geom.flat.interiorpoint.linearRingss = function(flatCoordinates, offset, endss, stride, flatCenters) {
goog.asserts.assert(2 * endss.length == flatCenters.length,
goog.DEBUG && console.assert(2 * endss.length == flatCenters.length,
'endss.length times 2 should be flatCenters.length');
var interiorPoints = [];
var i, ii;

View File

@@ -1,6 +1,5 @@
goog.provide('ol.geom.flat.interpolate');
goog.require('goog.asserts');
goog.require('ol.array');
goog.require('ol.math');
@@ -17,13 +16,13 @@ goog.require('ol.math');
ol.geom.flat.interpolate.lineString = function(flatCoordinates, offset, end, stride, fraction, opt_dest) {
// FIXME does not work when vertices are repeated
// FIXME interpolate extra dimensions
goog.asserts.assert(0 <= fraction && fraction <= 1,
goog.DEBUG && console.assert(0 <= fraction && fraction <= 1,
'fraction should be in between 0 and 1');
var pointX = NaN;
var pointY = NaN;
var n = (end - offset) / stride;
if (n === 0) {
goog.asserts.fail('n cannot be 0');
goog.DEBUG && console.assert(false, 'n cannot be 0');
} else if (n == 1) {
pointX = flatCoordinates[offset];
pointY = flatCoordinates[offset + 1];
@@ -121,8 +120,8 @@ ol.geom.flat.lineStringCoordinateAtM = function(flatCoordinates, offset, end, st
return flatCoordinates.slice((lo - 1) * stride, (lo - 1) * stride + stride);
}
var m1 = flatCoordinates[(lo + 1) * stride - 1];
goog.asserts.assert(m0 < m, 'm0 should be less than m');
goog.asserts.assert(m <= m1, 'm should be less than or equal to m1');
goog.DEBUG && console.assert(m0 < m, 'm0 should be less than m');
goog.DEBUG && console.assert(m <= m1, 'm should be less than or equal to m1');
var t = (m - m0) / (m1 - m0);
coordinate = [];
var i;
@@ -131,7 +130,7 @@ ol.geom.flat.lineStringCoordinateAtM = function(flatCoordinates, offset, end, st
flatCoordinates[lo * stride + i], t));
}
coordinate.push(m);
goog.asserts.assert(coordinate.length == stride,
goog.DEBUG && console.assert(coordinate.length == stride,
'length of coordinate array should match stride');
return coordinate;
};
@@ -186,7 +185,7 @@ ol.geom.flat.lineStringsCoordinateAtM = function(
}
offset = end;
}
goog.asserts.fail(
goog.DEBUG && console.assert(false,
'ol.geom.flat.lineStringsCoordinateAtM should have returned');
return null;
};

View File

@@ -1,6 +1,5 @@
goog.provide('ol.geom.flat.intersectsextent');
goog.require('goog.asserts');
goog.require('ol.extent');
goog.require('ol.geom.flat.contains');
goog.require('ol.geom.flat.segments');
@@ -107,7 +106,7 @@ ol.geom.flat.intersectsextent.linearRing = function(flatCoordinates, offset, end
* @return {boolean} True if the geometry and the extent intersect.
*/
ol.geom.flat.intersectsextent.linearRings = function(flatCoordinates, offset, ends, stride, extent) {
goog.asserts.assert(ends.length > 0, 'ends should not be an empty array');
goog.DEBUG && console.assert(ends.length > 0, 'ends should not be an empty array');
if (!ol.geom.flat.intersectsextent.linearRing(
flatCoordinates, offset, ends[0], stride, extent)) {
return false;
@@ -135,7 +134,7 @@ ol.geom.flat.intersectsextent.linearRings = function(flatCoordinates, offset, en
* @return {boolean} True if the geometry and the extent intersect.
*/
ol.geom.flat.intersectsextent.linearRingss = function(flatCoordinates, offset, endss, stride, extent) {
goog.asserts.assert(endss.length > 0, 'endss should not be an empty array');
goog.DEBUG && console.assert(endss.length > 0, 'endss should not be an empty array');
var i, ii;
for (i = 0, ii = endss.length; i < ii; ++i) {
var ends = endss[i];