rollback added semicolons from r4151. no ; after a regular function declaration. also some small coding standards whitespace.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@4157 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2007-08-31 15:15:07 +00:00
parent 8ae2a01b66
commit d6de04cddd
5 changed files with 63 additions and 60 deletions

View File

@@ -30,7 +30,7 @@
t.ok( map.events instanceof OpenLayers.Events, "map.events is an OpenLayers.Events" ); t.ok( map.events instanceof OpenLayers.Events, "map.events is an OpenLayers.Events" );
t.ok( map.getMaxExtent() instanceof OpenLayers.Bounds, "map.maxExtent is an OpenLayers.Bounds" ); t.ok( map.getMaxExtent() instanceof OpenLayers.Bounds, "map.maxExtent is an OpenLayers.Bounds" );
t.ok( map.getNumZoomLevels() > 0, "map has a default numZoomLevels" ); t.ok( map.getNumZoomLevels() > 0, "map has a default numZoomLevels" );
}; }
function test_02_Map_center(t) { function test_02_Map_center(t) {
t.plan(3); t.plan(3);
@@ -44,7 +44,7 @@
t.ok( map.getCenter() instanceof OpenLayers.LonLat, "map.getCenter returns a LonLat"); t.ok( map.getCenter() instanceof OpenLayers.LonLat, "map.getCenter returns a LonLat");
t.eq( map.getZoom(), 0, "map.zoom is correct after calling setCenter"); t.eq( map.getZoom(), 0, "map.zoom is correct after calling setCenter");
t.ok( map.getCenter().equals(ll), "map center is correct after calling setCenter"); t.ok( map.getCenter().equals(ll), "map center is correct after calling setCenter");
}; }
function test_03_Map_add_layers(t) { function test_03_Map_add_layers(t) {
t.plan(6); t.plan(6);
@@ -64,7 +64,7 @@
"layer1 zIndex is set" ); "layer1 zIndex is set" );
t.eq( parseInt(layer2.div.style.zIndex), map.Z_INDEX_BASE['BaseLayer'] + 5, t.eq( parseInt(layer2.div.style.zIndex), map.Z_INDEX_BASE['BaseLayer'] + 5,
"layer2 zIndex is set" ); "layer2 zIndex is set" );
}; }
function test_04_Map_options(t) { function test_04_Map_options(t) {
t.plan(3); t.plan(3);
@@ -72,7 +72,7 @@
t.eq( map.numZoomLevels, 6, "map.numZoomLevels set correctly via options hashtable" ); t.eq( map.numZoomLevels, 6, "map.numZoomLevels set correctly via options hashtable" );
t.eq( map.maxResolution, 3.14159, "map.maxResolution set correctly via options hashtable" ); t.eq( map.maxResolution, 3.14159, "map.maxResolution set correctly via options hashtable" );
t.eq( map.theme, 'foo', "map theme set correctly." ); t.eq( map.theme, 'foo', "map theme set correctly." );
}; }
function test_05_Map_center(t) { function test_05_Map_center(t) {
t.plan(4); t.plan(4);
@@ -100,7 +100,7 @@
t.ok( lonlat.equals(zero), "map center is correct after calling zoomToFullExtent" ); t.ok( lonlat.equals(zero), "map center is correct after calling zoomToFullExtent" );
*/ */
}; }
function test_06_Map_zoomend_event (t) { function test_06_Map_zoomend_event (t) {
t.plan(2); t.plan(2);
@@ -117,7 +117,7 @@
map.setCenter(new OpenLayers.LonLat(2, 1), 0); map.setCenter(new OpenLayers.LonLat(2, 1), 0);
map.zoomIn(); map.zoomIn();
map.zoomOut(); map.zoomOut();
}; }
function test_07_Map_add_remove_popup (t) { function test_07_Map_add_remove_popup (t) {
t.plan(4); t.plan(4);
@@ -195,7 +195,7 @@
t.ok( newPixel instanceof OpenLayers.Pixel, "getPixelFromLonLat returns valid OpenLayers.Pixel" ); t.ok( newPixel instanceof OpenLayers.Pixel, "getPixelFromLonLat returns valid OpenLayers.Pixel" );
t.ok( newPixel.equals(pixel), "2nd translation to pixel and back to lonlat is consistent"); t.ok( newPixel.equals(pixel), "2nd translation to pixel and back to lonlat is consistent");
}; }
*/ */
function test_09_Map_isValidLonLat(t) { function test_09_Map_isValidLonLat(t) {
@@ -211,7 +211,7 @@
t.ok( !map.isValidLonLat(null), "null lonlat is not valid" ); t.ok( !map.isValidLonLat(null), "null lonlat is not valid" );
t.ok( map.isValidLonLat(new OpenLayers.LonLat(33862, 717606)), "lonlat outside max extent is valid" ); t.ok( map.isValidLonLat(new OpenLayers.LonLat(33862, 717606)), "lonlat outside max extent is valid" );
t.ok( !map.isValidLonLat(new OpenLayers.LonLat(10, 10)), "lonlat outside max extent is not valid" ); t.ok( !map.isValidLonLat(new OpenLayers.LonLat(10, 10)), "lonlat outside max extent is not valid" );
}; }
function test_10_Map_getLayer(t) { function test_10_Map_getLayer(t) {
t.plan( 2 ); t.plan( 2 );
@@ -230,7 +230,7 @@
gotLayer = map.getLayer("chicken"); gotLayer = map.getLayer("chicken");
t.ok( gotLayer == null, "getLayer correctly returns null when layer not found"); t.ok( gotLayer == null, "getLayer correctly returns null when layer not found");
}; }
function test_11_Map_double_addLayer(t) { function test_11_Map_double_addLayer(t) {
t.plan( 1 ); t.plan( 1 );
@@ -245,7 +245,7 @@
t.eq( map.layers.length, 1, "Map does not allow double adding of layers." ); t.eq( map.layers.length, 1, "Map does not allow double adding of layers." );
}; }
function test_12_Map_setBaseLayer(t) { function test_12_Map_setBaseLayer(t) {
t.plan( 4 ); t.plan( 4 );
@@ -274,7 +274,7 @@
map.setBaseLayer(wmslayer2); map.setBaseLayer(wmslayer2);
t.ok(map.baseLayer == wmslayer2, "setbaselayer correctly sets 'baseLayer' property"); t.ok(map.baseLayer == wmslayer2, "setbaselayer correctly sets 'baseLayer' property");
}; }
function test_13_Map_setBaseLayer_after_pan (t) { function test_13_Map_setBaseLayer_after_pan (t) {
t.plan(1); t.plan(1);
@@ -293,7 +293,7 @@
map.pan(0, -200); map.pan(0, -200);
map.setBaseLayer(wmsLayer); map.setBaseLayer(wmsLayer);
t.eq(map.layerContainerDiv.style.top, "0px", "layerContainer is recentered after setBaseLayer"); t.eq(map.layerContainerDiv.style.top, "0px", "layerContainer is recentered after setBaseLayer");
}; }
function test_14_Map_moveLayer (t) { function test_14_Map_moveLayer (t) {
t.plan(10); t.plan(10);
@@ -333,7 +333,7 @@
"layer div has the right zIndex after moving up" ); "layer div has the right zIndex after moving up" );
t.eq( map.getLayerIndex(wmslayer3), 0, "top layer is now on the bottom" ); t.eq( map.getLayerIndex(wmslayer3), 0, "top layer is now on the bottom" );
t.eq( ct, 3, "raiseLayer triggered changelayer the right # of times" ); t.eq( ct, 3, "raiseLayer triggered changelayer the right # of times" );
}; }
function test_15_Map_setCenter(t) { function test_15_Map_setCenter(t) {
t.plan(1); t.plan(1);
@@ -347,7 +347,7 @@
var ll = new OpenLayers.LonLat(-100,-150); var ll = new OpenLayers.LonLat(-100,-150);
map.setCenter(ll, 0); map.setCenter(ll, 0);
t.ok(map.getCenter().equals(new OpenLayers.LonLat(0,0)), "safely sets out-of-bounds lonlat"); t.ok(map.getCenter().equals(new OpenLayers.LonLat(0,0)), "safely sets out-of-bounds lonlat");
}; }
function test_16_Map_defaultTheme(t) { function test_16_Map_defaultTheme(t) {
t.plan(5); t.plan(5);
@@ -371,7 +371,7 @@
map = new OpenLayers.Map('map'); map = new OpenLayers.Map('map');
t.eq(links.length, document.getElementsByTagName('link').length, t.eq(links.length, document.getElementsByTagName('link').length,
"calling the map constructor twice with the same theme doesn't add duplicate link nodes"); "calling the map constructor twice with the same theme doesn't add duplicate link nodes");
}; }
function test_17_Map_customTheme(t) { function test_17_Map_customTheme(t) {
t.plan(5); t.plan(5);
@@ -395,7 +395,7 @@
t.ok(themeNode != null, "a link node with the theme href was added"); t.ok(themeNode != null, "a link node with the theme href was added");
t.eq(themeNode.rel, "stylesheet", "node added has rel set to stylesheet"); t.eq(themeNode.rel, "stylesheet", "node added has rel set to stylesheet");
t.eq(themeNode.type, "text/css", "node added has type set to text/css"); t.eq(themeNode.type, "text/css", "node added has type set to text/css");
}; }
function test_18_Map_noTheme(t) { function test_18_Map_noTheme(t) {
t.plan(1); t.plan(1);
@@ -407,7 +407,7 @@
map = new OpenLayers.Map('map', options); map = new OpenLayers.Map('map', options);
t.eq(nodeCount, head.childNodes.length, "with no theme, a node is not added to document head" ); t.eq(nodeCount, head.childNodes.length, "with no theme, a node is not added to document head" );
}; }
function test_19_Map_getControl(t) { function test_19_Map_getControl(t) {
t.plan(2); t.plan(2);
@@ -422,7 +422,7 @@
gotControl = map1.getControl("bogus id"); gotControl = map1.getControl("bogus id");
t.ok(gotControl == null, "getControl() for bad id returns null"); t.ok(gotControl == null, "getControl() for bad id returns null");
}; }
function test_19_Map_removeControl(t) { function test_19_Map_removeControl(t) {
t.plan(6); t.plan(6);
@@ -470,7 +470,7 @@
map1.removeControl(control); map1.removeControl(control);
newNumControls = map1.controls.length; newNumControls = map1.controls.length;
t.ok( newNumControls == oldNumControls, "removing bad controlid doesnt crash or decrease control count") t.ok( newNumControls == oldNumControls, "removing bad controlid doesnt crash or decrease control count")
}; }
function test_99_Map_destroy (t) { function test_99_Map_destroy (t) {
t.plan( 3 ); t.plan( 3 );
@@ -479,7 +479,7 @@
t.eq( map.layers, null, "map.layers is null after destroy" ); t.eq( map.layers, null, "map.layers is null after destroy" );
t.eq( map.controls, null, "map.controls is null after destroy" ); t.eq( map.controls, null, "map.controls is null after destroy" );
t.eq( map.viewPortDiv, null, "map's viewportDiv nullified"); t.eq( map.viewPortDiv, null, "map's viewportDiv nullified");
}; }
</script> </script>
</head> </head>

View File

@@ -13,7 +13,7 @@
t.ok( marker.icon instanceof OpenLayers.Icon, "new marker.Icon returns Icon object" ); t.ok( marker.icon instanceof OpenLayers.Icon, "new marker.Icon returns Icon object" );
t.ok( marker.lonlat instanceof OpenLayers.LonLat, "new marker.lonlat returns LonLat object" ); t.ok( marker.lonlat instanceof OpenLayers.LonLat, "new marker.lonlat returns LonLat object" );
t.ok( marker.lonlat.equals(ll), "marker.lonlat returns correct" ); t.ok( marker.lonlat.equals(ll), "marker.lonlat returns correct" );
}; }
function test_02_Marker_onScreen(t) { function test_02_Marker_onScreen(t) {
t.plan( 2 ); t.plan( 2 );
@@ -44,7 +44,7 @@
t.ok( !marker2.onScreen(), "marker knows it's offscreen" ); t.ok( !marker2.onScreen(), "marker knows it's offscreen" );
map.destroy(); map.destroy();
}; }
function test_03_Marker_setOpacity(t) { function test_03_Marker_setOpacity(t) {
t.plan( 2 ); t.plan( 2 );
@@ -72,7 +72,7 @@
t.eq(parseFloat(marker.icon.imageDiv.style.opacity), 0.5, "marker.setOpacity() works"); t.eq(parseFloat(marker.icon.imageDiv.style.opacity), 0.5, "marker.setOpacity() works");
map.destroy(); map.destroy();
}; }
function test_04_Marker_moveTo(t) { function test_04_Marker_moveTo(t) {
t.plan( 6 ); t.plan( 6 );
@@ -105,7 +105,7 @@
t.eq(marker.lonlat.lon, map.getExtent().left, "on left edge of map"); t.eq(marker.lonlat.lon, map.getExtent().left, "on left edge of map");
t.eq(marker.lonlat.lat, map.getExtent().top, "on top edge of map"); t.eq(marker.lonlat.lat, map.getExtent().top, "on top edge of map");
map.destroy(); map.destroy();
}; }
</script> </script>
</head> </head>

View File

@@ -25,7 +25,7 @@
popup = new OpenLayers.Popup(); popup = new OpenLayers.Popup();
var newID = popup.id; var newID = popup.id;
t.ok(newID != firstID, "default id generator creating unique ids"); t.ok(newID != firstID, "default id generator creating unique ids");
}; }
function test_02_Popup_constructor (t) { function test_02_Popup_constructor (t) {
t.plan( 5 ); t.plan( 5 );
@@ -49,7 +49,7 @@
t.ok(popup.lonlat.equals(ll), "popup.lonlat set correctly"); t.ok(popup.lonlat.equals(ll), "popup.lonlat set correctly");
t.ok(popup.size.equals(sz), "popup.size set correctly"); t.ok(popup.size.equals(sz), "popup.size set correctly");
t.eq(popup.contentHTML, content, "contentHTML porpoerty of set correctly"); t.eq(popup.contentHTML, content, "contentHTML porpoerty of set correctly");
}; }
function test_03_Popup_draw(t) { function test_03_Popup_draw(t) {
t.plan( 17 ); t.plan( 17 );
@@ -104,7 +104,7 @@
popup.moveTo(new OpenLayers.Pixel(x, y)); popup.moveTo(new OpenLayers.Pixel(x, y));
t.eq(popup.div.style.left, x + "px", "moveTo updates left position of popup.div correctly"); t.eq(popup.div.style.left, x + "px", "moveTo updates left position of popup.div correctly");
t.eq(popup.div.style.top, y + "px", "moveTo updates top position of popup.div correctly"); t.eq(popup.div.style.top, y + "px", "moveTo updates top position of popup.div correctly");
}; }
</script> </script>
</head> </head>

View File

@@ -9,7 +9,7 @@
t.plan(1); t.plan(1);
var r = new OpenLayers.Renderer(); var r = new OpenLayers.Renderer();
t.ok( r instanceof OpenLayers.Renderer, "new OpenLayers.Renderer returns REnderer object" ); t.ok( r instanceof OpenLayers.Renderer, "new OpenLayers.Renderer returns REnderer object" );
}; }
/* /*
function test_01_Renderer_drawGeometry(t) { function test_01_Renderer_drawGeometry(t) {
@@ -155,7 +155,7 @@ function test_01_Renderer_drawGeometry(t) {
r.drawGeometry(geometry, style); r.drawGeometry(geometry, style);
t.ok(properDraw, "drawGeometry called drawPolygon when passed a multi-polygon"); t.ok(properDraw, "drawGeometry called drawPolygon when passed a multi-polygon");
}; }
*/ */
</script> </script>

View File

@@ -9,7 +9,7 @@
t.plan( 1 ); t.plan( 1 );
t.ok( OpenLayers.Util.getImagesLocation(), "../img/", t.ok( OpenLayers.Util.getImagesLocation(), "../img/",
"getImagesLocation()" ); "getImagesLocation()" );
}; }
function test_02_Util_Strings(t) { function test_02_Util_Strings(t) {
t.plan(5); t.plan(5);
@@ -28,7 +28,7 @@
t.eq(trimmedStr.startsWith("dolphin"), false, "String.startsWith correctly does not find turkey"); t.eq(trimmedStr.startsWith("dolphin"), false, "String.startsWith correctly does not find turkey");
}; }
function test_03_Util_Array(t) { function test_03_Util_Array(t) {
t.plan( 1 ); t.plan( 1 );
@@ -37,7 +37,7 @@
OpenLayers.Util.removeItem(array, 3); OpenLayers.Util.removeItem(array, 3);
t.eq( array.toString(), "1,2,4,5", "Util.removeItem works"); t.eq( array.toString(), "1,2,4,5", "Util.removeItem works");
}; }
function test_04_Util_createDiv(t) { function test_04_Util_createDiv(t) {
t.plan( 24 ); t.plan( 24 );
@@ -98,7 +98,7 @@
t.ok( !div.style.opacity, "element.style.opacity set correctly"); t.ok( !div.style.opacity, "element.style.opacity set correctly");
t.ok( !div.style.filter, "element.style.filter set correctly"); t.ok( !div.style.filter, "element.style.filter set correctly");
}; }
function test_05_Util_createImage(t) { function test_05_Util_createImage(t) {
t.plan( 22 ); t.plan( 22 );
@@ -151,7 +151,7 @@
t.ok( !image.style.opacity, "element.style.opacity default unset"); t.ok( !image.style.opacity, "element.style.opacity default unset");
t.ok( !image.style.filter, "element.style.filter default unset"); t.ok( !image.style.filter, "element.style.filter default unset");
}; }
function test_06_Util_applyDefaults(t) { function test_06_Util_applyDefaults(t) {
@@ -173,14 +173,15 @@
t.eq( to["a"], "abra", "key present in to but not from maintained"); t.eq( to["a"], "abra", "key present in to but not from maintained");
t.eq( to["b"], "blorg", "key present in to and from, maintained in to"); t.eq( to["b"], "blorg", "key present in to and from, maintained in to");
t.eq( to["c"], "press", "key present in from and not to successfully copied to to"); t.eq( to["c"], "press", "key present in from and not to successfully copied to to");
}; }
function test_07_Util_getParameterString(t) { function test_07_Util_getParameterString(t) {
t.plan( 4 ); t.plan( 4 );
var params = { foo: "bar", var params = {
chicken: 1.5 'foo': "bar",
}; 'chicken': 1.5
};
t.eq( OpenLayers.Util.getParameterString(params), "foo=bar&chicken=1.5", "getParameterString returns correctly"); t.eq( OpenLayers.Util.getParameterString(params), "foo=bar&chicken=1.5", "getParameterString returns correctly");
t.eq( OpenLayers.Util.getParameterString({'a:':'b='}), "a%3A=b%3D", "getParameterString returns correctly with non-ascii keys/values"); t.eq( OpenLayers.Util.getParameterString({'a:':'b='}), "a%3A=b%3D", "getParameterString returns correctly with non-ascii keys/values");
@@ -193,7 +194,7 @@
var params = { foo: ["bar","baz,"] }; var params = { foo: ["bar","baz,"] };
t.eq( OpenLayers.Util.getParameterString(params), "foo=bar,baz%2C", "getParameterString returns with list of CSVs when given a list. "); t.eq( OpenLayers.Util.getParameterString(params), "foo=bar,baz%2C", "getParameterString returns with list of CSVs when given a list. ");
}; }
function test_08_Util_createAlphaImageDiv(t) { function test_08_Util_createAlphaImageDiv(t) {
t.plan( 19 ); t.plan( 19 );
@@ -274,10 +275,9 @@
t.ok(true); t.ok(true);
} }
}; }
function test_09_Util_modifyDOMElement(t) { function test_09_Util_modifyDOMElement(t) {
t.plan( 10 ); t.plan( 10 );
var id = "boo"; var id = "boo";
@@ -306,7 +306,7 @@
t.eq( parseFloat(element.style.opacity), opacity, "element.style.opacity set correctly"); t.eq( parseFloat(element.style.opacity), opacity, "element.style.opacity set correctly");
var filterString = 'alpha(opacity=' + (opacity * 100) + ')'; var filterString = 'alpha(opacity=' + (opacity * 100) + ')';
t.eq( element.style.filter, filterString, "element.style.filter set correctly"); t.eq( element.style.filter, filterString, "element.style.filter set correctly");
}; }
function test_09_Util_modifyAlphaImageDiv(t) { function test_09_Util_modifyAlphaImageDiv(t) {
t.plan( 19 ); t.plan( 19 );
@@ -387,10 +387,9 @@
t.ok(true); t.ok(true);
} }
}; }
function test_10_Util_upperCaseObject(t) { function test_10_Util_upperCaseObject(t) {
t.plan(8); t.plan(8);
var aKey = "chicken"; var aKey = "chicken";
@@ -418,7 +417,7 @@
t.eq(uObj[aKey.toUpperCase()], aValue, "new uppercase value present"); t.eq(uObj[aKey.toUpperCase()], aValue, "new uppercase value present");
t.eq(uObj[bKey.toUpperCase()], bValue, "new uppercase value present"); t.eq(uObj[bKey.toUpperCase()], bValue, "new uppercase value present");
}; }
function test_11_Util_createUniqueID(t) { function test_11_Util_createUniqueID(t) {
t.plan(2); t.plan(2);
@@ -428,7 +427,7 @@
var id = OpenLayers.Util.createUniqueID("chicken"); var id = OpenLayers.Util.createUniqueID("chicken");
t.ok( id.startsWith("chicken"), "OpenLayers.Util.createUniqueID starts id correctly"); t.ok( id.startsWith("chicken"), "OpenLayers.Util.createUniqueID starts id correctly");
}; }
function test_12_Util_limitSigDigs(t) { function test_12_Util_limitSigDigs(t) {
t.plan(7); t.plan(7);
@@ -450,7 +449,7 @@
x = 0; x = 0;
t.eq(x.limitSigDigs(2), 0, "correctly handles 0 number"); t.eq(x.limitSigDigs(2), 0, "correctly handles 0 number");
}; }
function test_13_Util_normalizeScale(t) { function test_13_Util_normalizeScale(t) {
t.plan(2); t.plan(2);
@@ -462,7 +461,7 @@
//funky scale //funky scale
var scale = 5; var scale = 5;
t.eq( OpenLayers.Util.normalizeScale(scale), 1/5, "normalizing a wrong scale works!"); t.eq( OpenLayers.Util.normalizeScale(scale), 1/5, "normalizing a wrong scale works!");
}; }
function test_13_Util_getScaleResolutionTranslation(t) { function test_13_Util_getScaleResolutionTranslation(t) {
t.plan(4); t.plan(4);
@@ -482,10 +481,11 @@
scale = 150000000; scale = 150000000;
resolution = OpenLayers.Util.getResolutionFromScale(scale); resolution = OpenLayers.Util.getResolutionFromScale(scale);
t.eq(OpenLayers.Util.getScaleFromResolution(resolution), scale, "scale->resolution->scale works"); t.eq(OpenLayers.Util.getScaleFromResolution(resolution), scale, "scale->resolution->scale works");
}; }
function test_14_Util_getImgLocation(t) { function test_14_Util_getImgLocation(t) {
t.plan(3); t.plan(3);
OpenLayers.ImgPath = "foo/"; OpenLayers.ImgPath = "foo/";
t.eq(OpenLayers.Util.getImagesLocation(), "foo/", "ImgPath works as expected."); t.eq(OpenLayers.Util.getImagesLocation(), "foo/", "ImgPath works as expected.");
OpenLayers.ImgPath = null; OpenLayers.ImgPath = null;
@@ -493,7 +493,7 @@
OpenLayers.ImgPath = ''; OpenLayers.ImgPath = '';
t.eq(OpenLayers.Util.getImagesLocation().substr(OpenLayers.Util.getImagesLocation().length-4,4), "img/", "ImgPath works as expected when set to ''."); t.eq(OpenLayers.Util.getImagesLocation().substr(OpenLayers.Util.getImagesLocation().length-4,4), "img/", "ImgPath works as expected when set to ''.");
}; }
function test_15_Util_isEquivalentUrl(t) { function test_15_Util_isEquivalentUrl(t) {
t.plan(8); t.plan(8);
@@ -554,18 +554,20 @@
url2 = "../tests/../tests/foo.html?bar=now#go"; url2 = "../tests/../tests/foo.html?bar=now#go";
t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "relative vs. absolute paths works"); t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "relative vs. absolute paths works");
}; }
function test_Util_createUniqueIDSeq(t) { function test_Util_createUniqueIDSeq(t) {
t.plan(1); t.plan(1);
OpenLayers.Util.lastSeqID = 0; OpenLayers.Util.lastSeqID = 0;
OpenLayers.Util.createDiv(); OpenLayers.Util.createDiv();
OpenLayers.Util.createDiv(); OpenLayers.Util.createDiv();
t.eq(OpenLayers.Util.createDiv().id, "OpenLayersDiv3", "Div created is sequential, starting at lastSeqID in Util."); t.eq(OpenLayers.Util.createDiv().id, "OpenLayersDiv3", "Div created is sequential, starting at lastSeqID in Util.");
}; }
function test_Util_getParameters(t) { function test_Util_getParameters(t) {
t.plan(6); t.plan(6);
t.eq(OpenLayers.Util.getParameters('http://www.example.com'), {}, t.eq(OpenLayers.Util.getParameters('http://www.example.com'), {},
"getParameters works when args = ''"); "getParameters works when args = ''");
t.eq(OpenLayers.Util.getParameters('http://www.example.com?'), {}, t.eq(OpenLayers.Util.getParameters('http://www.example.com?'), {},
@@ -582,7 +584,7 @@
t.eq(OpenLayers.Util.getParameters('http://www.example.com?foo=bar,pub,disco'), t.eq(OpenLayers.Util.getParameters('http://www.example.com?foo=bar,pub,disco'),
{'foo': ['bar', 'pub', 'disco']}, {'foo': ['bar', 'pub', 'disco']},
"getParameters works with a comma-separated value (parses into array)"); "getParameters works with a comma-separated value (parses into array)");
}; }
function test_Util_getArgs(t) { function test_Util_getArgs(t) {
//DEPRECATED -- to be removed in 3.0 //DEPRECATED -- to be removed in 3.0
@@ -607,10 +609,11 @@
OpenLayers.Console.warn = temp; OpenLayers.Console.warn = temp;
OpenLayers.Util.getParameters = temp2; OpenLayers.Util.getParameters = temp2;
}; }
function tests_Util_extend(t) { function tests_Util_extend(t) {
t.plan(5); t.plan(5);
var source = { var source = {
num: Math.random(), num: Math.random(),
obj: { obj: {
@@ -633,7 +636,7 @@
t.eq(destination.toString(), "source", t.eq(destination.toString(), "source",
"extend properly sets custom toString method"); "extend properly sets custom toString method");
t.eq(window.property, undefined, "Property variable not clobbered."); t.eq(window.property, undefined, "Property variable not clobbered.");
}; }
function test_XX_Util_Try(t) { function test_XX_Util_Try(t) {
t.plan(7); t.plan(7);
@@ -641,24 +644,24 @@
var func1 = function() { var func1 = function() {
t.ok(true, "func1 executed"); t.ok(true, "func1 executed");
throw "error"; throw "error";
} };
var func2 = function() { var func2 = function() {
t.ok(true, "func2 executed"); t.ok(true, "func2 executed");
throw "error"; throw "error";
} };
g_TestVal3 = {}; g_TestVal3 = {};
var func3 = function() { var func3 = function() {
t.ok(true, "func3 executed"); t.ok(true, "func3 executed");
return g_TestVal3; return g_TestVal3;
} };
g_TestVal4 = {}; g_TestVal4 = {};
var func4 = function() { var func4 = function() {
t.fail("func4 should *not* be executed"); t.fail("func4 should *not* be executed");
return g_TestVal4; return g_TestVal4;
} };
var ret = OpenLayers.Util.Try(func1, func2); var ret = OpenLayers.Util.Try(func1, func2);
t.ok(ret == null, "if all functions throw exceptions, null returned"); t.ok(ret == null, "if all functions throw exceptions, null returned");
@@ -666,7 +669,7 @@
var ret = OpenLayers.Util.Try(func1, func2, func3, func4); var ret = OpenLayers.Util.Try(func1, func2, func3, func4);
t.ok(ret == g_TestVal3, "try returns first sucessfully executed function's return"); t.ok(ret == g_TestVal3, "try returns first sucessfully executed function's return");
}; }
</script> </script>
</head> </head>