make sure passed in values are floats... if they are strings, parse them. just in case. add test for this

git-svn-id: http://svn.openlayers.org/trunk/openlayers@1412 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-09-07 02:31:37 +00:00
parent 74f5b814eb
commit 00e354511e
2 changed files with 10 additions and 3 deletions

View File

@@ -193,8 +193,8 @@ OpenLayers.LonLat.prototype = {
* @param {float} lat
*/
initialize: function(lon, lat) {
this.lon = lon;
this.lat = lat;
this.lon = parseFloat(lon);
this.lat = parseFloat(lat);
},
/**

View File

@@ -6,12 +6,19 @@
var lonlat;
function test_01_LonLat_constructor (t) {
t.plan( 4 );
t.plan( 8 );
lonlat = new OpenLayers.LonLat(6, 5);
t.ok( lonlat instanceof OpenLayers.LonLat, "new OpenLayers.LonLat returns LonLat object" );
t.eq( lonlat.CLASS_NAME, "OpenLayers.LonLat", "lonlat.CLASS_NAME is set correctly");
t.eq( lonlat.lon, 6, "lonlat.lon is set correctly");
t.eq( lonlat.lat, 5, "lonlat.lat is set correctly");
lonlat = new OpenLayers.LonLat("6", "5");
t.ok( lonlat instanceof OpenLayers.LonLat, "new OpenLayers.LonLat returns LonLat object" );
t.eq( lonlat.CLASS_NAME, "OpenLayers.LonLat", "lonlat.CLASS_NAME is set correctly");
t.eq( lonlat.lon, 6, "lonlat.lon is set correctly");
t.eq( lonlat.lat, 5, "lonlat.lat is set correctly");
}
function test_02_LonLat_toString(t) {