Merge pull request #722 from twpayne/unused-variable-check

More rigorous linting
This commit is contained in:
Tom Payne
2013-05-28 08:06:30 -07:00
40 changed files with 44 additions and 66 deletions

View File

@@ -357,8 +357,11 @@ def build_lint_src_timestamp(t):
path path
for path in ifind('externs', 'build/src/external/externs') for path in ifind('externs', 'build/src/external/externs')
if path.endswith('.js')] if path.endswith('.js')]
t.run('%(GJSLINT)s', '--strict', '--limited_doc_files=%s' % t.run('%(GJSLINT)s',
(','.join(limited_doc_files),), t.newer(t.dependencies)) '--jslint_error=all',
'--limited_doc_files=%s' % (','.join(limited_doc_files),),
'--strict',
t.newer(t.dependencies))
t.touch() t.touch()

View File

@@ -67,7 +67,6 @@ xhr.open('GET', url, true);
xhr.onload = function() { xhr.onload = function() {
if (xhr.status == 200) { if (xhr.status == 200) {
// this is silly to have to tell the layer the destination projection // this is silly to have to tell the layer the destination projection
var projection = map.getView().getProjection();
vector.parseFeatures(xhr.responseText, kml, epsg4326); vector.parseFeatures(xhr.responseText, kml, epsg4326);
} }
}; };

View File

@@ -28,7 +28,7 @@ ol.geom.squaredDistanceToSegment = function(coordinate, segment) {
var v = segment[0]; var v = segment[0];
var w = segment[1]; var w = segment[1];
var l2 = ol.coordinate.squaredDistance(v, w); var l2 = ol.coordinate.squaredDistance(v, w);
if (l2 == 0) { if (l2 === 0) {
return ol.coordinate.squaredDistance(coordinate, v); return ol.coordinate.squaredDistance(coordinate, v);
} }
var t = ((coordinate[0] - v[0]) * (w[0] - v[0]) + var t = ((coordinate[0] - v[0]) * (w[0] - v[0]) +

View File

@@ -1,7 +1,6 @@
goog.provide('ol.geom.Polygon'); goog.provide('ol.geom.Polygon');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('ol.Extent');
goog.require('ol.geom.Geometry'); goog.require('ol.geom.Geometry');
goog.require('ol.geom.GeometryType'); goog.require('ol.geom.GeometryType');
goog.require('ol.geom.LinearRing'); goog.require('ol.geom.LinearRing');
@@ -51,12 +50,6 @@ ol.geom.Polygon = function(coordinates, opt_shared) {
this.dimension = vertices.getDimension(); this.dimension = vertices.getDimension();
goog.asserts.assert(this.dimension >= 2); goog.asserts.assert(this.dimension >= 2);
/**
* @type {ol.Extent}
* @private
*/
this.bounds_ = null;
}; };
goog.inherits(ol.geom.Polygon, ol.geom.Geometry); goog.inherits(ol.geom.Polygon, ol.geom.Geometry);

View File

@@ -48,7 +48,6 @@ goog.inherits(ol.interaction.DragRotate, ol.interaction.Drag);
* @inheritDoc * @inheritDoc
*/ */
ol.interaction.DragRotate.prototype.handleDrag = function(mapBrowserEvent) { ol.interaction.DragRotate.prototype.handleDrag = function(mapBrowserEvent) {
var browserEvent = mapBrowserEvent.browserEvent;
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var size = map.getSize(); var size = map.getSize();
var offset = mapBrowserEvent.getPixel(); var offset = mapBrowserEvent.getPixel();
@@ -70,7 +69,6 @@ ol.interaction.DragRotate.prototype.handleDrag = function(mapBrowserEvent) {
* @inheritDoc * @inheritDoc
*/ */
ol.interaction.DragRotate.prototype.handleDragEnd = function(mapBrowserEvent) { ol.interaction.DragRotate.prototype.handleDragEnd = function(mapBrowserEvent) {
var browserEvent = mapBrowserEvent.browserEvent;
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
// FIXME supports View2D only // FIXME supports View2D only
var view = map.getView(); var view = map.getView();

View File

@@ -106,7 +106,6 @@ ol.interaction.Touch.prototype.handleTouchStart = goog.functions.FALSE;
*/ */
ol.interaction.Touch.prototype.handleMapBrowserEvent = ol.interaction.Touch.prototype.handleMapBrowserEvent =
function(mapBrowserEvent) { function(mapBrowserEvent) {
var browserEvent = mapBrowserEvent.browserEvent.getBrowserEvent();
this.updateTrackedTouches_(mapBrowserEvent); this.updateTrackedTouches_(mapBrowserEvent);
if (this.handled_) { if (this.handled_) {
if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.TOUCHMOVE) { if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.TOUCHMOVE) {

View File

@@ -82,7 +82,7 @@ ol.interaction.TouchPan.prototype.handleTouchEnd =
function(mapBrowserEvent) { function(mapBrowserEvent) {
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var view = map.getView(); var view = map.getView();
if (this.targetTouches.length == 0) { if (this.targetTouches.length === 0) {
var interacting = view.setHint(ol.ViewHint.INTERACTING, -1); var interacting = view.setHint(ol.ViewHint.INTERACTING, -1);
if (!this.noKinetic_ && this.kinetic_ && this.kinetic_.end()) { if (!this.noKinetic_ && this.kinetic_ && this.kinetic_.end()) {
var distance = this.kinetic_.getDistance(); var distance = this.kinetic_.getDistance();

View File

@@ -73,8 +73,6 @@ ol.interaction.TouchRotate.prototype.handleTouchMove =
var touch0 = this.targetTouches[0]; var touch0 = this.targetTouches[0];
var touch1 = this.targetTouches[1]; var touch1 = this.targetTouches[1];
var dx = touch0.clientX - touch1.clientX;
var dy = touch0.clientY - touch1.clientY;
// angle between touches // angle between touches
var angle = Math.atan2( var angle = Math.atan2(

View File

@@ -792,7 +792,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
var i, ii, view2DState; var i, ii, view2DState;
if (this.freezeRenderingCount_ != 0) { if (this.freezeRenderingCount_ !== 0) {
return; return;
} }

View File

@@ -209,7 +209,7 @@ ol.MapBrowserEventHandler.prototype.click_ = function(browserEvent) {
if (!this.dragged_) { if (!this.dragged_) {
var newEvent; var newEvent;
var type = browserEvent.type; var type = browserEvent.type;
if (this.timestamp_ == 0 || type == goog.events.EventType.DBLCLICK) { if (this.timestamp_ === 0 || type == goog.events.EventType.DBLCLICK) {
newEvent = new ol.MapBrowserEvent( newEvent = new ol.MapBrowserEvent(
ol.MapBrowserEvent.EventType.DBLCLICK, this.map_, browserEvent); ol.MapBrowserEvent.EventType.DBLCLICK, this.map_, browserEvent);
this.dispatchEvent(newEvent); this.dispatchEvent(newEvent);

View File

@@ -119,7 +119,7 @@ ol.parser.ogc.GML_v3 = function(opt_options) {
var dim = obj.srsDimension || var dim = obj.srsDimension ||
parseInt(node.getAttribute('srsDimension') || parseInt(node.getAttribute('srsDimension') ||
node.getAttribute('dimension'), 10) || 2; node.getAttribute('dimension'), 10) || 2;
var j, x, y, z; var x, y, z;
var numPoints = coords.length / dim; var numPoints = coords.length / dim;
var points = new Array(numPoints); var points = new Array(numPoints);
for (var i = 0, ii = coords.length; i < ii; i += dim) { for (var i = 0, ii = coords.length; i < ii; i += dim) {

View File

@@ -417,7 +417,7 @@ ol.projection.removeTransform = function(source, destination) {
var transform = transforms[sourceCode][destinationCode]; var transform = transforms[sourceCode][destinationCode];
delete transforms[sourceCode][destinationCode]; delete transforms[sourceCode][destinationCode];
var keys = goog.object.getKeys(transforms[sourceCode]); var keys = goog.object.getKeys(transforms[sourceCode]);
if (keys.length == 0) { if (keys.length === 0) {
delete transforms[sourceCode]; delete transforms[sourceCode];
} }
return transform; return transform;

View File

@@ -132,7 +132,7 @@ ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) {
// for performance reasons, context.setTransform is only used // for performance reasons, context.setTransform is only used
// when the view is rotated. see http://jsperf.com/canvas-transform // when the view is rotated. see http://jsperf.com/canvas-transform
if (frameState.view2DState.rotation == 0) { if (frameState.view2DState.rotation === 0) {
var dx = goog.vec.Mat4.getElement(transform, 0, 3); var dx = goog.vec.Mat4.getElement(transform, 0, 3);
var dy = goog.vec.Mat4.getElement(transform, 1, 3); var dy = goog.vec.Mat4.getElement(transform, 1, 3);
var dw = image.width * goog.vec.Mat4.getElement(transform, 0, 0); var dw = image.width * goog.vec.Mat4.getElement(transform, 0, 0);

View File

@@ -270,7 +270,6 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
var findLoadedTiles = goog.bind(tileSource.findLoadedTiles, tileSource, var findLoadedTiles = goog.bind(tileSource.findLoadedTiles, tileSource,
tilesToDrawByZ, getTileIfLoaded); tilesToDrawByZ, getTileIfLoaded);
var allTilesLoaded = true;
var tmpExtent = ol.extent.createEmpty(); var tmpExtent = ol.extent.createEmpty();
var tmpTileRange = new ol.TileRange(0, 0, 0, 0); var tmpTileRange = new ol.TileRange(0, 0, 0, 0);
var childTileRange, fullyLoaded, tile, tileState, x, y; var childTileRange, fullyLoaded, tile, tileState, x, y;
@@ -286,7 +285,6 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
continue; continue;
} }
allTilesLoaded = false;
fullyLoaded = tileGrid.forEachTileCoordParentTileRange( fullyLoaded = tileGrid.forEachTileCoordParentTileRange(
tile.tileCoord, findLoadedTiles, null, tmpTileRange, tmpExtent); tile.tileCoord, findLoadedTiles, null, tmpTileRange, tmpExtent);
if (!fullyLoaded) { if (!fullyLoaded) {

View File

@@ -115,7 +115,6 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
var findLoadedTiles = goog.bind(tileSource.findLoadedTiles, tileSource, var findLoadedTiles = goog.bind(tileSource.findLoadedTiles, tileSource,
tilesToDrawByZ, getTileIfLoaded); tilesToDrawByZ, getTileIfLoaded);
var allTilesLoaded = true;
var tmpExtent = ol.extent.createEmpty(); var tmpExtent = ol.extent.createEmpty();
var tmpTileRange = new ol.TileRange(0, 0, 0, 0); var tmpTileRange = new ol.TileRange(0, 0, 0, 0);
var childTileRange, fullyLoaded, tile, tileState, x, y; var childTileRange, fullyLoaded, tile, tileState, x, y;
@@ -132,7 +131,6 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
continue; continue;
} }
allTilesLoaded = false;
fullyLoaded = tileGrid.forEachTileCoordParentTileRange( fullyLoaded = tileGrid.forEachTileCoordParentTileRange(
tile.tileCoord, findLoadedTiles, null, tmpTileRange, tmpExtent); tile.tileCoord, findLoadedTiles, null, tmpTileRange, tmpExtent);
if (!fullyLoaded) { if (!fullyLoaded) {

View File

@@ -22,12 +22,6 @@ ol.renderer.Map = function(container, map) {
goog.base(this); goog.base(this);
/**
* @private
* @type {Element}
*/
this.container_ = container;
/** /**
* @private * @private
* @type {ol.Map} * @type {ol.Map}

View File

@@ -109,7 +109,6 @@ ol.renderer.webgl.Layer.prototype.bindFramebuffer =
if (!goog.isDef(this.framebufferDimension) || if (!goog.isDef(this.framebufferDimension) ||
this.framebufferDimension != framebufferDimension) { this.framebufferDimension != framebufferDimension) {
var map = this.getMap();
frameState.postRenderFunctions.push( frameState.postRenderFunctions.push(
goog.partial(function(gl, framebuffer, texture) { goog.partial(function(gl, framebuffer, texture) {
if (!gl.isContextLost()) { if (!gl.isContextLost()) {

View File

@@ -165,7 +165,6 @@ ol.renderer.webgl.Map = function(container, map) {
* @return {number} Priority. * @return {number} Priority.
*/ */
goog.bind(function(element) { goog.bind(function(element) {
var tile = /** @type {ol.Tile} */ (element[0]);
var tileCenter = /** @type {ol.Coordinate} */ (element[1]); var tileCenter = /** @type {ol.Coordinate} */ (element[1]);
var tileResolution = /** @type {number} */ (element[2]); var tileResolution = /** @type {number} */ (element[2]);
var deltaX = tileCenter[0] - this.focus_[0]; var deltaX = tileCenter[0] - this.focus_[0];
@@ -312,7 +311,6 @@ ol.renderer.webgl.Map.prototype.createLayerRenderer = function(layer) {
*/ */
ol.renderer.webgl.Map.prototype.deleteBuffer = function(buf) { ol.renderer.webgl.Map.prototype.deleteBuffer = function(buf) {
var gl = this.getGL(); var gl = this.getGL();
var arr = buf.getArray();
var bufferKey = goog.getUid(buf); var bufferKey = goog.getUid(buf);
goog.asserts.assert(bufferKey in this.bufferCache_); goog.asserts.assert(bufferKey in this.bufferCache_);
var bufferCacheEntry = this.bufferCache_[bufferKey]; var bufferCacheEntry = this.bufferCache_[bufferKey];
@@ -359,7 +357,7 @@ ol.renderer.webgl.Map.prototype.disposeInternal = function() {
*/ */
ol.renderer.webgl.Map.prototype.expireCache_ = function(map, frameState) { ol.renderer.webgl.Map.prototype.expireCache_ = function(map, frameState) {
var gl = this.getGL(); var gl = this.getGL();
var key, textureCacheEntry; var textureCacheEntry;
while (this.textureCache_.getCount() - this.textureCacheFrameMarkerCount_ > while (this.textureCache_.getCount() - this.textureCacheFrameMarkerCount_ >
ol.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK) { ol.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK) {
textureCacheEntry = /** @type {?ol.renderer.webgl.TextureCacheEntry} */ textureCacheEntry = /** @type {?ol.renderer.webgl.TextureCacheEntry} */
@@ -546,7 +544,6 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
this.textureCache_.set((-frameState.index).toString(), null); this.textureCache_.set((-frameState.index).toString(), null);
++this.textureCacheFrameMarkerCount_; ++this.textureCacheFrameMarkerCount_;
var layerStates = frameState.layerStates;
var layersArray = frameState.layersArray; var layersArray = frameState.layersArray;
var i, ii, layer, layerRenderer, layerState; var i, ii, layer, layerRenderer, layerState;
for (i = 0, ii = layersArray.length; i < ii; ++i) { for (i = 0, ii = layersArray.length; i < ii; ++i) {

View File

@@ -64,7 +64,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
goog.asserts.assert(response.statusDescription == 'OK'); goog.asserts.assert(response.statusDescription == 'OK');
var brandLogoUri = response.brandLogoUri; var brandLogoUri = response.brandLogoUri;
var copyright = response.copyright; //var copyright = response.copyright; // FIXME do we need to display this?
goog.asserts.assert(response.resourceSets.length == 1); goog.asserts.assert(response.resourceSets.length == 1);
var resourceSet = response.resourceSets[0]; var resourceSet = response.resourceSets[0];
goog.asserts.assert(resourceSet.resources.length == 1); goog.asserts.assert(resourceSet.resources.length == 1);

View File

@@ -84,7 +84,6 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function() {
this.setExtent(extent); this.setExtent(extent);
} }
var scheme = goog.isDef(tileJSON.scheme) || 'xyz';
if (goog.isDef(tileJSON.scheme)) { if (goog.isDef(tileJSON.scheme)) {
goog.asserts.assert(tileJSON.scheme == 'xyz'); goog.asserts.assert(tileJSON.scheme == 'xyz');
} }

View File

@@ -54,7 +54,6 @@ ol.Sphere.prototype.cosineDistance = function(c1, c2) {
* @return {number} Cross-track distance. * @return {number} Cross-track distance.
*/ */
ol.Sphere.prototype.crossTrackDistance = function(c1, c2, c3) { ol.Sphere.prototype.crossTrackDistance = function(c1, c2, c3) {
var d12 = this.cosineDistance(c1, c2);
var d13 = this.cosineDistance(c1, c2); var d13 = this.cosineDistance(c1, c2);
var theta12 = goog.math.toRadians(this.initialBearing(c1, c2)); var theta12 = goog.math.toRadians(this.initialBearing(c1, c2));
var theta13 = goog.math.toRadians(this.initialBearing(c1, c3)); var theta13 = goog.math.toRadians(this.initialBearing(c1, c3));

View File

@@ -80,7 +80,6 @@ ol.structs.IntegerSet.prototype.compactRanges_ = function() {
var arr = this.arr_; var arr = this.arr_;
var n = arr.length; var n = arr.length;
var rangeIndex = 0; var rangeIndex = 0;
var lastRange = null;
var i; var i;
for (i = 0; i < n; i += 2) { for (i = 0; i < n; i += 2) {
if (arr[i] == arr[i + 1]) { if (arr[i] == arr[i + 1]) {

View File

@@ -138,7 +138,7 @@ ol.style.Icon.prototype.createLiteral = function(feature) {
goog.asserts.assertNumber(opacity, 'opacity must be a number'); goog.asserts.assertNumber(opacity, 'opacity must be a number');
var rotation = var rotation =
/** {@type {number} */ (this.opacity_.evaluate(feature, attrs)); /** {@type {number} */ (this.rotation_.evaluate(feature, attrs));
goog.asserts.assertNumber(rotation, 'rotation must be a number'); goog.asserts.assertNumber(rotation, 'rotation must be a number');
return new ol.style.IconLiteral({ return new ol.style.IconLiteral({

View File

@@ -6,8 +6,8 @@ describe('ol.filter.Logical', function() {
var OR = ol.filter.LogicalOperator.OR; var OR = ol.filter.LogicalOperator.OR;
var AND = ol.filter.LogicalOperator.AND; var AND = ol.filter.LogicalOperator.AND;
var NOT = ol.filter.LogicalOperator.NOT; var NOT = ol.filter.LogicalOperator.NOT;
var include = new ol.filter.Filter(function() {return true}); var include = new ol.filter.Filter(function() {return true;});
var exclude = new ol.filter.Filter(function() {return false}); var exclude = new ol.filter.Filter(function() {return false;});
var apple = new ol.Feature({}); var apple = new ol.Feature({});
var orange = new ol.Feature({}); var orange = new ol.Feature({});

View File

@@ -12,6 +12,7 @@ describe('ol.geom.LinearRing', function() {
it('throws when given mismatched dimension', function() { it('throws when given mismatched dimension', function() {
expect(function() { expect(function() {
var ring = new ol.geom.LinearRing([[10, 20], [30, 40, 50]]); var ring = new ol.geom.LinearRing([[10, 20], [30, 40, 50]]);
ring = ring; // suppress gjslint warning about unused variable
}).to.throwException(); }).to.throwException();
}); });

View File

@@ -13,6 +13,7 @@ describe('ol.geom.LineString', function() {
it('throws when given mismatched dimension', function() { it('throws when given mismatched dimension', function() {
expect(function() { expect(function() {
var line = new ol.geom.LineString([[10, 20], [30, 40, 50]]); var line = new ol.geom.LineString([[10, 20], [30, 40, 50]]);
line = line; // suppress gjslint warning about unused variable
}).to.throwException(); }).to.throwException();
}); });

View File

@@ -15,6 +15,7 @@ describe('ol.geom.MultiLineString', function() {
it('throws when given with insufficient dimensions', function() { it('throws when given with insufficient dimensions', function() {
expect(function() { expect(function() {
var multi = new ol.geom.MultiLineString([1]); var multi = new ol.geom.MultiLineString([1]);
multi = multi; // suppress gjslint warning about unused variable
}).to.throwException(); }).to.throwException();
}); });

View File

@@ -13,6 +13,7 @@ describe('ol.geom.MultiPoint', function() {
it('throws when given with insufficient dimensions', function() { it('throws when given with insufficient dimensions', function() {
expect(function() { expect(function() {
var multi = new ol.geom.MultiPoint([1]); var multi = new ol.geom.MultiPoint([1]);
multi = multi; // suppress gjslint warning about unused variable
}).to.throwException(); }).to.throwException();
}); });

View File

@@ -20,6 +20,7 @@ describe('ol.geom.MultiPolygon', function() {
it('throws when given with insufficient dimensions', function() { it('throws when given with insufficient dimensions', function() {
expect(function() { expect(function() {
var multi = new ol.geom.MultiPolygon([1]); var multi = new ol.geom.MultiPolygon([1]);
multi = multi; // suppress gjslint warning about unused variable
}).to.throwException(); }).to.throwException();
}); });

View File

@@ -23,6 +23,7 @@ describe('ol.geom.Point', function() {
it('throws when given with insufficient dimensions', function() { it('throws when given with insufficient dimensions', function() {
expect(function() { expect(function() {
var point = new ol.geom.Point([1]); var point = new ol.geom.Point([1]);
point = point; // suppress gjslint warning about unused variable
}).to.throwException(); }).to.throwException();
}); });

View File

@@ -17,6 +17,7 @@ describe('ol.geom.Polygon', function() {
it('throws when given mismatched dimension', function() { it('throws when given mismatched dimension', function() {
expect(function() { expect(function() {
var poly = new ol.geom.Polygon([[[10, 20], [30, 40, 50]]]); var poly = new ol.geom.Polygon([[[10, 20], [30, 40, 50]]]);
poly = poly; // suppress gjslint warning about unused variable
}).to.throwException(); }).to.throwException();
}); });

View File

@@ -117,9 +117,9 @@ describe('ol.geom.SharedVertices', function() {
describe('#getCounts()', function() { describe('#getCounts()', function() {
it('returns the counts array', function() { it('returns the counts array', function() {
var vertices = new ol.geom.SharedVertices(); var vertices = new ol.geom.SharedVertices();
var first = vertices.add([[2, 3], [3, 4], [4, 5]]); vertices.add([[2, 3], [3, 4], [4, 5]]);
var second = vertices.add([[5, 6], [6, 6]]); vertices.add([[5, 6], [6, 6]]);
var third = vertices.add([[7, 8]]); vertices.add([[7, 8]]);
expect(vertices.getCounts()).to.eql([3, 2, 1]); expect(vertices.getCounts()).to.eql([3, 2, 1]);
}); });
@@ -169,9 +169,9 @@ describe('ol.geom.SharedVertices', function() {
describe('#getStarts()', function() { describe('#getStarts()', function() {
it('returns the counts array', function() { it('returns the counts array', function() {
var vertices = new ol.geom.SharedVertices(); var vertices = new ol.geom.SharedVertices();
var first = vertices.add([[2, 3], [3, 4], [4, 5]]); vertices.add([[2, 3], [3, 4], [4, 5]]);
var second = vertices.add([[5, 6], [6, 6]]); vertices.add([[5, 6], [6, 6]]);
var third = vertices.add([[7, 8]]); vertices.add([[7, 8]]);
expect(vertices.getStarts()).to.eql([0, 6, 10]); expect(vertices.getStarts()).to.eql([0, 6, 10]);
}); });
@@ -180,19 +180,19 @@ describe('ol.geom.SharedVertices', function() {
describe('#coordinates', function() { describe('#coordinates', function() {
it('is a flat array of all coordinate values', function() { it('is a flat array of all coordinate values', function() {
var vertices = new ol.geom.SharedVertices(); var vertices = new ol.geom.SharedVertices();
var first = vertices.add([[1, 2], [3, 4]]); vertices.add([[1, 2], [3, 4]]);
var second = vertices.add([[5, 6]]); vertices.add([[5, 6]]);
var third = vertices.add([[7, 8], [9, 10], [11, 12]]); vertices.add([[7, 8], [9, 10], [11, 12]]);
expect(vertices.coordinates).to.eql( expect(vertices.coordinates).to.eql(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
}); });
it('is not reassigned', function() { it('is not reassigned', function() {
var vertices = new ol.geom.SharedVertices(); var vertices = new ol.geom.SharedVertices();
var first = vertices.add([[1, 2], [3, 4]]); vertices.add([[1, 2], [3, 4]]);
var coordinates = vertices.coordinates; var coordinates = vertices.coordinates;
var second = vertices.add([[5, 6]]); vertices.add([[5, 6]]);
expect(vertices.coordinates).to.be(coordinates); expect(vertices.coordinates).to.be(coordinates);
}); });
}); });

View File

@@ -49,7 +49,7 @@ describe('ol.parser.kml', function() {
afterLoadXml(url, function(xml) { afterLoadXml(url, function(xml) {
var p = new ol.parser.KML({maxDepth: 1}); var p = new ol.parser.KML({maxDepth: 1});
// we need to supply a callback to get visited NetworkLinks // we need to supply a callback to get visited NetworkLinks
var obj = p.read(xml, function(features) { p.read(xml, function(features) {
expect(features.length).to.eql(3); expect(features.length).to.eql(3);
done(); done();
}); });
@@ -60,7 +60,7 @@ describe('ol.parser.kml', function() {
afterLoadXml(url, function(xml) { afterLoadXml(url, function(xml) {
var p = new ol.parser.KML({maxDepth: 2}); var p = new ol.parser.KML({maxDepth: 2});
// we need to supply a callback to get visited NetworkLinks // we need to supply a callback to get visited NetworkLinks
var obj = p.read(xml, function(features) { p.read(xml, function(features) {
expect(features.length).to.eql(2); expect(features.length).to.eql(2);
done(); done();
}); });
@@ -71,7 +71,7 @@ describe('ol.parser.kml', function() {
afterLoadXml(url, function(xml) { afterLoadXml(url, function(xml) {
var p = new ol.parser.KML({maxDepth: 1}); var p = new ol.parser.KML({maxDepth: 1});
// we need to supply a callback to get visited NetworkLinks // we need to supply a callback to get visited NetworkLinks
var obj = p.read(xml, function(features) { p.read(xml, function(features) {
// since maxDepth is 1, we will not get to the second feature // since maxDepth is 1, we will not get to the second feature
expect(features.length).to.eql(1); expect(features.length).to.eql(1);
done(); done();

View File

@@ -298,7 +298,7 @@ describe('ol.parser.gml_v2', function() {
it('Test boundedBy', function() { it('Test boundedBy', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v2/boundedBy.xml'; var url = 'spec/ol/parser/ogc/xml/gml_v2/boundedBy.xml';
afterLoadXml(url, function(xml) { afterLoadXml(url, function(xml) {
var obj = parser.read(xml); parser.read(xml);
// TODO test bounds on feature // TODO test bounds on feature
// see https://github.com/openlayers/ol3/issues/566 // see https://github.com/openlayers/ol3/issues/566
}); });

View File

@@ -308,8 +308,7 @@ describe('ol.parser.gml_v3', function() {
it('Read autoConfig', function() { it('Read autoConfig', function() {
var url = 'spec/ol/parser/ogc/xml/gml_v3/topp-states-wfs.xml'; var url = 'spec/ol/parser/ogc/xml/gml_v3/topp-states-wfs.xml';
afterLoadXml(url, function(xml) { afterLoadXml(url, function(xml) {
var obj = parser.read(xml); parser.read(xml);
var features = obj.features;
expect(parser.featureType).to.eql('states'); expect(parser.featureType).to.eql('states');
expect(parser.featureNS).to.eql('http://www.openplans.org/topp'); expect(parser.featureNS).to.eql('http://www.openplans.org/topp');
expect(parser.autoConfig === true).to.be.ok(); expect(parser.autoConfig === true).to.be.ok();

View File

@@ -2,9 +2,6 @@ goog.provide('ol.test.parser.ogc.Versioned');
describe('ol.parser.ogc.versioned', function() { describe('ol.parser.ogc.versioned', function() {
var snippet = '<foo version="2.0.0"></foo>';
var snippet2 = '<foo></foo>';
describe('test constructor', function() { describe('test constructor', function() {
var parser = new ol.parser.ogc.Versioned({version: '1.0.0'}); var parser = new ol.parser.ogc.Versioned({version: '1.0.0'});
it('new OpenLayers.Format.XML.VersionedOGC returns object', function() { it('new OpenLayers.Format.XML.VersionedOGC returns object', function() {

View File

@@ -6,7 +6,6 @@ describe('ol.renderer.webgl.ImageLayer', function() {
var renderer; var renderer;
var canvasWidth; var canvasWidth;
var canvasHeight; var canvasHeight;
var viewExtent;
var viewResolution; var viewResolution;
var viewRotation; var viewRotation;
var viewCenter; var viewCenter;

View File

@@ -26,12 +26,14 @@ describe('ol.structs.IntegerSet', function() {
it('throws an exception with an odd number of elements', function() { it('throws an exception with an odd number of elements', function() {
expect(function() { expect(function() {
var is = new ol.structs.IntegerSet([0, 2, 4]); var is = new ol.structs.IntegerSet([0, 2, 4]);
is = is; // suppress gjslint warning about unused variable
}).to.throwException(); }).to.throwException();
}); });
it('throws an exception with out-of-order elements', function() { it('throws an exception with out-of-order elements', function() {
expect(function() { expect(function() {
var is = new ol.structs.IntegerSet([0, 2, 2, 4]); var is = new ol.structs.IntegerSet([0, 2, 2, 4]);
is = is; // suppress gjslint warning about unused variable
}).to.throwException(); }).to.throwException();
}); });

View File

@@ -82,7 +82,7 @@ describe('ol.structs.PriorityQueue', function() {
pq = new ol.structs.PriorityQueue(function(element) { pq = new ol.structs.PriorityQueue(function(element) {
return Math.abs(element - target); return Math.abs(element - target);
}, goog.identityFunction); }, goog.identityFunction);
var element, i; var i;
for (i = 0; i < 32; ++i) { for (i = 0; i < 32; ++i) {
pq.enqueue(Math.random()); pq.enqueue(Math.random());
} }

View File

@@ -63,6 +63,7 @@ describe('ol.TileRange', function() {
var tileRange = new ol.TileRange.boundingTileRange( var tileRange = new ol.TileRange.boundingTileRange(
new ol.TileCoord(3, 1, 3), new ol.TileCoord(3, 1, 3),
new ol.TileCoord(4, 2, 0)); new ol.TileCoord(4, 2, 0));
tileRange = tileRange; // suppress gjslint warning about unused variable
}).to.throwException(); }).to.throwException();
}); });
}); });