1 function StripSpaces( s
) {
2 for ( var currentChar
= 0, strippedString
="";
3 currentChar
< s
.length
; currentChar
++ )
5 if (!IsWhiteSpace(s
.charAt(currentChar
))) {
6 strippedString
+= s
.charAt(currentChar
);
12 function IsWhiteSpace( string
) {
13 var cc
= string
.charCodeAt(0);
21 case ( 59 ): // let's strip out semicolons, too
30 shouldBe("StripSpaces(eval.toString())","\"functioneval(){[nativecode]}\"");
31 shouldBe("StripSpaces(parseInt.toString())","\"functionparseInt(){[nativecode]}\"");
32 shouldBe("StripSpaces(parseFloat.toString())","\"functionparseFloat(){[nativecode]}\"");
33 shouldBe("StripSpaces(isNaN.toString())","\"functionisNaN(){[nativecode]}\"");
34 shouldBe("StripSpaces(isFinite.toString())","\"functionisFinite(){[nativecode]}\"");
35 shouldBe("StripSpaces(escape.toString())","\"functionescape(){[nativecode]}\"");
36 shouldBe("StripSpaces(unescape.toString())","\"functionunescape(){[nativecode]}\"");
38 shouldBe("StripSpaces(Object.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
39 shouldBe("StripSpaces(Object.prototype.toLocaleString.toString())","\"functiontoLocaleString(){[nativecode]}\"");
40 shouldBe("StripSpaces(Object.prototype.valueOf.toString())","\"functionvalueOf(){[nativecode]}\"");
41 shouldBe("StripSpaces(Object.prototype.hasOwnProperty.toString())","\"functionhasOwnProperty(){[nativecode]}\"");
42 shouldBe("StripSpaces(Object.prototype.isPrototypeOf.toString())","\"functionisPrototypeOf(){[nativecode]}\"");
43 shouldBe("StripSpaces(Object.prototype.propertyIsEnumerable.toString())","\"functionpropertyIsEnumerable(){[nativecode]}\"");
45 shouldBe("StripSpaces(Function.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
46 shouldBe("StripSpaces(Function.prototype.apply.toString())","\"functionapply(){[nativecode]}\"");
47 shouldBe("StripSpaces(Function.prototype.call.toString())","\"functioncall(){[nativecode]}\"");
49 shouldBe("StripSpaces(Array.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
50 shouldBe("StripSpaces(Array.prototype.toLocaleString.toString())","\"functiontoLocaleString(){[nativecode]}\"");
51 shouldBe("StripSpaces(Array.prototype.concat.toString())","\"functionconcat(){[nativecode]}\"");
52 shouldBe("StripSpaces(Array.prototype.join.toString())","\"functionjoin(){[nativecode]}\"");
53 shouldBe("StripSpaces(Array.prototype.pop.toString())","\"functionpop(){[nativecode]}\"");
54 shouldBe("StripSpaces(Array.prototype.push.toString())","\"functionpush(){[nativecode]}\"");
55 shouldBe("StripSpaces(Array.prototype.reverse.toString())","\"functionreverse(){[nativecode]}\"");
56 shouldBe("StripSpaces(Array.prototype.shift.toString())","\"functionshift(){[nativecode]}\"");
57 shouldBe("StripSpaces(Array.prototype.slice.toString())","\"functionslice(){[nativecode]}\"");
58 shouldBe("StripSpaces(Array.prototype.sort.toString())","\"functionsort(){[nativecode]}\"");
59 shouldBe("StripSpaces(Array.prototype.splice.toString())","\"functionsplice(){[nativecode]}\"");
60 shouldBe("StripSpaces(Array.prototype.unshift.toString())","\"functionunshift(){[nativecode]}\"");
62 shouldBe("StripSpaces(String.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
63 shouldBe("StripSpaces(String.prototype.valueOf.toString())","\"functionvalueOf(){[nativecode]}\"");
64 shouldBe("StripSpaces(String.prototype.charAt.toString())","\"functioncharAt(){[nativecode]}\"");
65 shouldBe("StripSpaces(String.prototype.charCodeAt.toString())","\"functioncharCodeAt(){[nativecode]}\"");
66 shouldBe("StripSpaces(String.prototype.concat.toString())","\"functionconcat(){[nativecode]}\"");
67 shouldBe("StripSpaces(String.prototype.indexOf.toString())","\"functionindexOf(){[nativecode]}\"");
68 shouldBe("StripSpaces(String.prototype.lastIndexOf.toString())","\"functionlastIndexOf(){[nativecode]}\"");
69 shouldBe("StripSpaces(String.prototype.match.toString())","\"functionmatch(){[nativecode]}\"");
70 shouldBe("StripSpaces(String.prototype.replace.toString())","\"functionreplace(){[nativecode]}\"");
71 shouldBe("StripSpaces(String.prototype.search.toString())","\"functionsearch(){[nativecode]}\"");
72 shouldBe("StripSpaces(String.prototype.slice.toString())","\"functionslice(){[nativecode]}\"");
73 shouldBe("StripSpaces(String.prototype.split.toString())","\"functionsplit(){[nativecode]}\"");
74 shouldBe("StripSpaces(String.prototype.substr.toString())","\"functionsubstr(){[nativecode]}\"");
75 shouldBe("StripSpaces(String.prototype.substring.toString())","\"functionsubstring(){[nativecode]}\"");
76 shouldBe("StripSpaces(String.prototype.toLowerCase.toString())","\"functiontoLowerCase(){[nativecode]}\"");
77 shouldBe("StripSpaces(String.prototype.toUpperCase.toString())","\"functiontoUpperCase(){[nativecode]}\"");
78 shouldBe("StripSpaces(String.prototype.big.toString())","\"functionbig(){[nativecode]}\"");
79 shouldBe("StripSpaces(String.prototype.small.toString())","\"functionsmall(){[nativecode]}\"");
80 shouldBe("StripSpaces(String.prototype.blink.toString())","\"functionblink(){[nativecode]}\"");
81 shouldBe("StripSpaces(String.prototype.bold.toString())","\"functionbold(){[nativecode]}\"");
82 shouldBe("StripSpaces(String.prototype.fixed.toString())","\"functionfixed(){[nativecode]}\"");
83 shouldBe("StripSpaces(String.prototype.italics.toString())","\"functionitalics(){[nativecode]}\"");
84 shouldBe("StripSpaces(String.prototype.strike.toString())","\"functionstrike(){[nativecode]}\"");
85 shouldBe("StripSpaces(String.prototype.sub.toString())","\"functionsub(){[nativecode]}\"");
86 shouldBe("StripSpaces(String.prototype.sup.toString())","\"functionsup(){[nativecode]}\"");
87 shouldBe("StripSpaces(String.prototype.fontcolor.toString())","\"functionfontcolor(){[nativecode]}\"");
88 shouldBe("StripSpaces(String.prototype.fontsize.toString())","\"functionfontsize(){[nativecode]}\"");
89 shouldBe("StripSpaces(String.prototype.anchor.toString())","\"functionanchor(){[nativecode]}\"");
90 shouldBe("StripSpaces(String.prototype.link.toString())","\"functionlink(){[nativecode]}\"");
92 shouldBe("StripSpaces(Boolean.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
93 shouldBe("StripSpaces(Boolean.prototype.valueOf.toString())","\"functionvalueOf(){[nativecode]}\"");
95 shouldBe("StripSpaces(Number.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
96 shouldBe("StripSpaces(Number.prototype.toLocaleString.toString())","\"functiontoLocaleString(){[nativecode]}\"");
97 shouldBe("StripSpaces(Number.prototype.valueOf.toString())","\"functionvalueOf(){[nativecode]}\"");
98 shouldBe("StripSpaces(Number.prototype.toFixed.toString())","\"functiontoFixed(){[nativecode]}\"");
99 shouldBe("StripSpaces(Number.prototype.toExponential.toString())","\"functiontoExponential(){[nativecode]}\"");
100 shouldBe("StripSpaces(Number.prototype.toPrecision.toString())","\"functiontoPrecision(){[nativecode]}\"");
102 shouldBe("StripSpaces(Math.abs.toString())","\"functionabs(){[nativecode]}\"");
103 shouldBe("StripSpaces(Math.acos.toString())","\"functionacos(){[nativecode]}\"");
104 shouldBe("StripSpaces(Math.asin.toString())","\"functionasin(){[nativecode]}\"");
105 shouldBe("StripSpaces(Math.atan.toString())","\"functionatan(){[nativecode]}\"");
106 shouldBe("StripSpaces(Math.atan2.toString())","\"functionatan2(){[nativecode]}\"");
107 shouldBe("StripSpaces(Math.ceil.toString())","\"functionceil(){[nativecode]}\"");
108 shouldBe("StripSpaces(Math.cos.toString())","\"functioncos(){[nativecode]}\"");
109 shouldBe("StripSpaces(Math.exp.toString())","\"functionexp(){[nativecode]}\"");
110 shouldBe("StripSpaces(Math.floor.toString())","\"functionfloor(){[nativecode]}\"");
111 shouldBe("StripSpaces(Math.log.toString())","\"functionlog(){[nativecode]}\"");
112 shouldBe("StripSpaces(Math.max.toString())","\"functionmax(){[nativecode]}\"");
113 shouldBe("StripSpaces(Math.min.toString())","\"functionmin(){[nativecode]}\"");
114 shouldBe("StripSpaces(Math.pow.toString())","\"functionpow(){[nativecode]}\"");
115 shouldBe("StripSpaces(Math.random.toString())","\"functionrandom(){[nativecode]}\"");
116 shouldBe("StripSpaces(Math.round.toString())","\"functionround(){[nativecode]}\"");
117 shouldBe("StripSpaces(Math.sin.toString())","\"functionsin(){[nativecode]}\"");
118 shouldBe("StripSpaces(Math.sqrt.toString())","\"functionsqrt(){[nativecode]}\"");
119 shouldBe("StripSpaces(Math.tan.toString())","\"functiontan(){[nativecode]}\"");
121 shouldBe("StripSpaces(Date.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
122 shouldBe("StripSpaces(Date.prototype.toUTCString.toString())","\"functiontoUTCString(){[nativecode]}\"");
123 shouldBe("StripSpaces(Date.prototype.toDateString.toString())","\"functiontoDateString(){[nativecode]}\"");
124 shouldBe("StripSpaces(Date.prototype.toTimeString.toString())","\"functiontoTimeString(){[nativecode]}\"");
125 shouldBe("StripSpaces(Date.prototype.toLocaleString.toString())","\"functiontoLocaleString(){[nativecode]}\"");
126 shouldBe("StripSpaces(Date.prototype.toLocaleDateString.toString())","\"functiontoLocaleDateString(){[nativecode]}\"");
127 shouldBe("StripSpaces(Date.prototype.toLocaleTimeString.toString())","\"functiontoLocaleTimeString(){[nativecode]}\"");
128 shouldBe("StripSpaces(Date.prototype.valueOf.toString())","\"functionvalueOf(){[nativecode]}\"");
129 shouldBe("StripSpaces(Date.prototype.getTime.toString())","\"functiongetTime(){[nativecode]}\"");
130 shouldBe("StripSpaces(Date.prototype.getFullYear.toString())","\"functiongetFullYear(){[nativecode]}\"");
131 shouldBe("StripSpaces(Date.prototype.getUTCFullYear.toString())","\"functiongetUTCFullYear(){[nativecode]}\"");
132 shouldBe("StripSpaces(Date.prototype.toGMTString.toString())","\"functiontoGMTString(){[nativecode]}\"");
133 shouldBe("StripSpaces(Date.prototype.getMonth.toString())","\"functiongetMonth(){[nativecode]}\"");
134 shouldBe("StripSpaces(Date.prototype.getUTCMonth.toString())","\"functiongetUTCMonth(){[nativecode]}\"");
135 shouldBe("StripSpaces(Date.prototype.getDate.toString())","\"functiongetDate(){[nativecode]}\"");
136 shouldBe("StripSpaces(Date.prototype.getUTCDate.toString())","\"functiongetUTCDate(){[nativecode]}\"");
137 shouldBe("StripSpaces(Date.prototype.getDay.toString())","\"functiongetDay(){[nativecode]}\"");
138 shouldBe("StripSpaces(Date.prototype.getUTCDay.toString())","\"functiongetUTCDay(){[nativecode]}\"");
139 shouldBe("StripSpaces(Date.prototype.getHours.toString())","\"functiongetHours(){[nativecode]}\"");
140 shouldBe("StripSpaces(Date.prototype.getUTCHours.toString())","\"functiongetUTCHours(){[nativecode]}\"");
141 shouldBe("StripSpaces(Date.prototype.getMinutes.toString())","\"functiongetMinutes(){[nativecode]}\"");
142 shouldBe("StripSpaces(Date.prototype.getUTCMinutes.toString())","\"functiongetUTCMinutes(){[nativecode]}\"");
143 shouldBe("StripSpaces(Date.prototype.getSeconds.toString())","\"functiongetSeconds(){[nativecode]}\"");
144 shouldBe("StripSpaces(Date.prototype.getUTCSeconds.toString())","\"functiongetUTCSeconds(){[nativecode]}\"");
145 shouldBe("StripSpaces(Date.prototype.getMilliseconds.toString())","\"functiongetMilliseconds(){[nativecode]}\"");
146 shouldBe("StripSpaces(Date.prototype.getUTCMilliseconds.toString())","\"functiongetUTCMilliseconds(){[nativecode]}\"");
147 shouldBe("StripSpaces(Date.prototype.getTimezoneOffset.toString())","\"functiongetTimezoneOffset(){[nativecode]}\"");
148 shouldBe("StripSpaces(Date.prototype.setTime.toString())","\"functionsetTime(){[nativecode]}\"");
149 shouldBe("StripSpaces(Date.prototype.setMilliseconds.toString())","\"functionsetMilliseconds(){[nativecode]}\"");
150 shouldBe("StripSpaces(Date.prototype.setUTCMilliseconds.toString())","\"functionsetUTCMilliseconds(){[nativecode]}\"");
151 shouldBe("StripSpaces(Date.prototype.setSeconds.toString())","\"functionsetSeconds(){[nativecode]}\"");
152 shouldBe("StripSpaces(Date.prototype.setUTCSeconds.toString())","\"functionsetUTCSeconds(){[nativecode]}\"");
153 shouldBe("StripSpaces(Date.prototype.setMinutes.toString())","\"functionsetMinutes(){[nativecode]}\"");
154 shouldBe("StripSpaces(Date.prototype.setUTCMinutes.toString())","\"functionsetUTCMinutes(){[nativecode]}\"");
155 shouldBe("StripSpaces(Date.prototype.setHours.toString())","\"functionsetHours(){[nativecode]}\"");
156 shouldBe("StripSpaces(Date.prototype.setUTCHours.toString())","\"functionsetUTCHours(){[nativecode]}\"");
157 shouldBe("StripSpaces(Date.prototype.setDate.toString())","\"functionsetDate(){[nativecode]}\"");
158 shouldBe("StripSpaces(Date.prototype.setUTCDate.toString())","\"functionsetUTCDate(){[nativecode]}\"");
159 shouldBe("StripSpaces(Date.prototype.setMonth.toString())","\"functionsetMonth(){[nativecode]}\"");
160 shouldBe("StripSpaces(Date.prototype.setUTCMonth.toString())","\"functionsetUTCMonth(){[nativecode]}\"");
161 shouldBe("StripSpaces(Date.prototype.setFullYear.toString())","\"functionsetFullYear(){[nativecode]}\"");
162 shouldBe("StripSpaces(Date.prototype.setUTCFullYear.toString())","\"functionsetUTCFullYear(){[nativecode]}\"");
163 shouldBe("StripSpaces(Date.prototype.setYear.toString())","\"functionsetYear(){[nativecode]}\"");
164 shouldBe("StripSpaces(Date.prototype.getYear.toString())","\"functiongetYear(){[nativecode]}\"");
165 shouldBe("StripSpaces(Date.prototype.toGMTString.toString())","\"functiontoGMTString(){[nativecode]}\"");
167 shouldBe("StripSpaces(RegExp.prototype.exec.toString())","\"functionexec(){[nativecode]}\"");
168 shouldBe("StripSpaces(RegExp.prototype.test.toString())","\"functiontest(){[nativecode]}\"");
169 shouldBe("StripSpaces(RegExp.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
171 shouldBe("StripSpaces(Error.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");