modify all equals() functions in Util.js (Size, Pixel, LonLat, Bounds) such that if a null value is passed in, they return false. Tests updated to make sure this is true.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@608 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-06-17 14:12:56 +00:00
parent 988cf47bdd
commit 86b99df3f3
5 changed files with 40 additions and 9 deletions
+27 -5
View File
@@ -48,10 +48,15 @@ OpenLayers.Pixel.prototype = {
* @param {OpenLayers.Pixel} px
*
* @return whether or not the point passed in as parameter is equal to this
* note that if px passed in is null, returns false
* @type bool
*/
equals:function(px) {
return ((this.x == px.x) && (this.y == px.y));
var equals = false;
if (px != null) {
equals = ((this.x == px.x) && (this.y == px.y));
}
return equals;
},
/**
@@ -127,11 +132,16 @@ OpenLayers.Size.prototype = {
* @param {OpenLayers.Size} sz
* @returns Boolean value indicating whether the passed-in OpenLayers.Size
* object has the same w and h components as this
* note that if sz passed in is null, returns false
*
* @type bool
*/
equals:function(sz) {
return ((this.w == sz.w) && (this.h == sz.h));
var equals = false;
if (sz != null) {
equals = ((this.w == sz.w) && (this.h == sz.h));
}
return equals;
},
/** @final @type String */
@@ -203,11 +213,16 @@ OpenLayers.LonLat.prototype = {
* @param {OpenLayers.LonLat} ll
* @returns Boolean value indicating whether the passed-in OpenLayers.LonLat
* object has the same lon and lat components as this
* note that if ll passed in is null, returns false
*
* @type bool
*/
equals:function(ll) {
return ((this.lon == ll.lon) && (this.lat == ll.lat));
var equals = false;
if (ll != null) {
equals = ((this.lon == ll.lon) && (this.lat == ll.lat));
}
return equals;
},
/** @final @type String */
@@ -282,12 +297,19 @@ OpenLayers.Bounds.prototype = {
* @param {OpenLayers.Bounds} bounds
* @returns Boolean value indicating whether the passed-in OpenLayers.Bounds
* object has the same left, right, top, bottom components as this
* note that if bounds passed in is null, returns false
*
* @type bool
*/
equals:function(bounds) {
return ((this.left == bounds.left) && (this.right == bounds.right) &&
(this.top == bounds.top) && (this.bottom == bounds.bottom));
var equals = false;
if (bounds != null) {
equals = ((this.left == bounds.left) &&
(this.right == bounds.right) &&
(this.top == bounds.top) &&
(this.bottom == bounds.bottom));
}
return equals;
},
/**