Move zeroPad function to BaseTypes and add tests for it

This commit is contained in:
Matt Priour
2012-08-08 22:34:26 -05:00
parent 970448effc
commit dc93478e6b
2 changed files with 30 additions and 1 deletions

View File

@@ -278,6 +278,17 @@
OpenLayers.Number.decimalSeparator = ",";
t.eq(format(num, 3), "12.345,679", "changing thousands/decimal separator globally works");
}
function test_Number_zeroPad(t) {
t.plan(6);
var pad = OpenLayers.Number.zeroPad;
t.eq(pad(15, 4), "0015", "left padding works");
t.eq(pad(15, 2), "15", "no left padding when equal to number of digits");
t.eq(pad(15, 1), "15", "no left padding when less than number of digits");
t.eq(pad(10, 5, 2), "01010", "radix modified and padding works");
t.eq(pad(10, 5, 8), "00012", "radix modified and padding works");
t.eq(pad(10, 5, 36), "0000a", "radix modified and padding works");
}
function test_Function_bind(t) {
t.plan(12);