add limitSigDigs() function to number's prototype. tests included
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1008 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+28
-1
@@ -393,7 +393,7 @@
|
||||
t.eq(uObj[bKey.toUpperCase()], bValue, "new uppercase value present");
|
||||
}
|
||||
|
||||
function test_10_Util_createUniqueID(t) {
|
||||
function test_11_Util_createUniqueID(t) {
|
||||
t.plan(2);
|
||||
|
||||
var id = OpenLayers.Util.createUniqueID();
|
||||
@@ -402,6 +402,33 @@
|
||||
var id = OpenLayers.Util.createUniqueID("chicken");
|
||||
t.ok( id.startsWith("chicken"), "OpenLayers.Util.createUniqueID starts id correctly");
|
||||
}
|
||||
|
||||
function test_12_Util_limitSigDigs(t) {
|
||||
|
||||
t.plan(7);
|
||||
|
||||
var x;
|
||||
|
||||
x = 123456;
|
||||
t.eq(x.limitSigDigs(3), 123000, "correctly rounds down");
|
||||
|
||||
x = 555555;
|
||||
t.eq(x.limitSigDigs(3), 556000, "correctly rounds up");
|
||||
|
||||
x = 66;
|
||||
t.eq(x.limitSigDigs(3), 66, "correctly handles number smaller than sigdig");
|
||||
|
||||
t.eq(x.limitSigDigs(null), 0, "correctly handles null sigdig");
|
||||
t.eq(x.limitSigDigs(0), 0, "correctly handles 0 sigdig");
|
||||
t.eq(x.limitSigDigs(-1), 0, "correctly handles negative sigdig");
|
||||
|
||||
x = 0;
|
||||
t.eq(x.limitSigDigs(2), 0, "correctly handles 0 number");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user