Merge pull request #7 from fredj/3320

Replace OpenLayers.Console.error with exceptions. r=elemoine,bbinet (closes #3320)
This commit is contained in:
Frédéric Junod
2011-10-06 02:03:48 -07:00
55 changed files with 91 additions and 924 deletions

View File

@@ -594,7 +594,7 @@
}
function test_Bounds_add(t) {
t.plan( 8 );
t.plan( 6 );
origBounds = new OpenLayers.Bounds(1,2,3,4);
testBounds = origBounds.clone();
@@ -606,19 +606,19 @@
t.ok( bounds.equals(b), "bounds is set correctly");
//null values
OpenLayers.Lang.setCode('en');
var desiredMsg = "You must pass both x and y values to the add function.";
OpenLayers.Console.error = function(msg) {
t.eq(msg, desiredMsg, "error correctly reported");
try {
bounds = testBounds.add(null, 50);
} catch(e) {
t.ok("exception thrown when passing null value to add()");
}
bounds = testBounds.add(null, 50);
t.ok( testBounds.equals(origBounds), "testBounds is not modified by erroneous add operation (null x)");
t.ok(bounds == null, "returns null on erroneous add operation (null x)");
bounds = testBounds.add(5, null);
try {
bounds = testBounds.add(5, null);
} catch(e) {
t.ok("exception thrown when passing null value to add()");
}
t.ok( testBounds.equals(origBounds), "testBounds is not modified by erroneous add operation (null y)");
t.ok(bounds == null, "returns null on erroneous add operation (null y)");
}
function test_Bounds_scale(t) {

View File

@@ -52,7 +52,7 @@
}
function test_LonLat_add(t) {
t.plan(10);
t.plan(8);
origLL = new OpenLayers.LonLat(10,100);
lonlatA = origLL.clone();
@@ -64,19 +64,19 @@
t.ok( addpx.equals(ll), "addpx is set correctly");
//null values
OpenLayers.Lang.setCode('en');
var desiredMsg = "You must pass both lon and lat values to the add function.";
OpenLayers.Console.error = function(msg) {
t.eq(msg, desiredMsg, "error correctly reported");
try {
addpx = lonlatA.add(null, 50);
} catch(e) {
t.ok("exception thrown when passing null value to add()");
}
addpx = lonlatA.add(null, 50);
t.ok( lonlatA.equals(origLL), "lonlatA is not modified by erroneous add operation (null lon)");
t.ok(addpx == null, "returns null on erroneous add operation (null lon)");
addpx = lonlatA.add(5, null);
try {
addpx = lonlatA.add(5, null);
} catch(e) {
t.ok("exception thrown when passing null value to add()");
}
t.ok( lonlatA.equals(origLL), "lonlatA is not modified by erroneous add operation (null lat)");
t.ok(addpx == null, "returns null on erroneous add operation (null lat)");
// string values
addpx = origLL.clone().add("5", "50");

View File

@@ -72,7 +72,7 @@
}
function test_Pixel_add(t) {
t.plan( 8 );
t.plan( 6 );
var origPX = new OpenLayers.Pixel(5,6);
var oldPixel = origPX.clone();
@@ -85,19 +85,19 @@
t.ok( pixel.equals(px), "returned pixel is correct");
//null values
OpenLayers.Lang.setCode('en');
var desiredMsg = "You must pass both x and y values to the add function.";
OpenLayers.Console.error = function(msg) {
t.eq(msg, desiredMsg, "error correctly reported");
try {
pixel = oldPixel.add(null, 50);
} catch(e) {
t.ok("exception thrown when passing null value to add()");
}
pixel = oldPixel.add(null, 50);
t.ok( oldPixel.equals(origPX), "oldPixel is not modified by erroneous add operation (null x)");
t.ok(pixel == null, "returns null on erroneous add operation (null x)");
addpx = oldPixel.add(5, null);
try {
addpx = oldPixel.add(5, null);
} catch(e) {
t.ok("exception thrown when passing null value to add()");
}
t.ok( oldPixel.equals(origPX), "oldPixel is not modified by erroneous add operation (null y)");
t.ok(pixel == null, "returns null on erroneous add operation (null y)");
}
function test_Pixel_offset(t) {

View File

@@ -692,9 +692,12 @@
{map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'}
);
map.addLayers([layer,layer]);
t.eq( map.layers.length, 1, "Map does not allow double adding of layers." );
map.addLayers([layer]);
try {
map.addLayers([layer]);
} catch(e) {
t.ok(true, "Map does not allow double adding of layers." );
}
map.destroy();
}