Cast values containing numbers into Number objects in Filter and SLD

format to ensure correct comparison of scale denominators against map 
scale  and filters against features. Introduces a new 
OpenLayers.String.numericIf function. r=fredj,tschaub (closes #1874)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@8927 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2009-03-01 22:19:17 +00:00
parent e58d820685
commit a80e1e52c2
5 changed files with 75 additions and 8 deletions

View File

@@ -195,6 +195,42 @@
}
}
function test_Number_numericIf(t) {
var cases = [
{value: "3", expect: 3},
{value: "+3", expect: 3},
{value: "-3", expect: -3},
{value: "3.0", expect: 3},
{value: "+3.0", expect: 3},
{value: "-3.0", expect: -3},
{value: "6.02e23", expect: 6.02e23},
{value: "+1.0e-100", expect: 1e-100},
{value: "-1.0e+100", expect: -1e100},
{value: "1E100", expect: 1e100},
{value: null, expect: null},
{value: true, expect: true},
{value: false, expect: false},
{value: undefined, expect: undefined},
{value: "", expect: ""},
{value: "3 ", expect: "3 "},
{value: " 3", expect: " 3"},
{value: "1e", expect: "1e"},
{value: "1+e", expect: "1+e"},
{value: "1-e", expect: "1-e"}
];
t.plan(cases.length);
var func = OpenLayers.String.numericIf;
var obj, val, got, exp;
for(var i=0; i<cases.length; ++i) {
obj = cases[i];
val = obj.value;
exp = obj.expect;
got = func(val);
t.eq(got, exp, "'" + val + "' returns " + exp);
}
}
function test_Number_limitSigDigs(t) {