File indexing completed on 2024-04-28 15:28:37

0001    function StripSpaces( s ) {
0002         for ( var currentChar = 0, strippedString="";
0003                 currentChar < s.length; currentChar++ )
0004         {
0005             if (!IsWhiteSpace(s.charAt(currentChar))) {
0006                 strippedString += s.charAt(currentChar);
0007             }
0008         }
0009         return strippedString;
0010     }
0011 
0012     function IsWhiteSpace( string ) {
0013         var cc = string.charCodeAt(0);
0014         switch (cc) {
0015             case (0x0009):
0016             case (0x000B):
0017             case (0x000C):
0018             case (0x0020):
0019             case (0x000A):
0020             case (0x000D):
0021             case ( 59 ): // let's strip out semicolons, too
0022                 return true;
0023                 break;
0024             default:
0025                 return false;
0026         }
0027     }
0028 
0029 
0030 shouldBe("StripSpaces(eval.toString())","\"functioneval(){[nativecode]}\"");
0031 shouldBe("StripSpaces(parseInt.toString())","\"functionparseInt(){[nativecode]}\"");
0032 shouldBe("StripSpaces(parseFloat.toString())","\"functionparseFloat(){[nativecode]}\"");
0033 shouldBe("StripSpaces(isNaN.toString())","\"functionisNaN(){[nativecode]}\"");
0034 shouldBe("StripSpaces(isFinite.toString())","\"functionisFinite(){[nativecode]}\"");
0035 shouldBe("StripSpaces(escape.toString())","\"functionescape(){[nativecode]}\"");
0036 shouldBe("StripSpaces(unescape.toString())","\"functionunescape(){[nativecode]}\"");
0037 shouldBe("StripSpaces(kjsprint.toString())","\"functionkjsprint(){[nativecode]}\"");
0038 
0039 shouldBe("StripSpaces(Object.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
0040 shouldBe("StripSpaces(Object.prototype.toLocaleString.toString())","\"functiontoLocaleString(){[nativecode]}\"");
0041 shouldBe("StripSpaces(Object.prototype.valueOf.toString())","\"functionvalueOf(){[nativecode]}\"");
0042 shouldBe("StripSpaces(Object.prototype.hasOwnProperty.toString())","\"functionhasOwnProperty(){[nativecode]}\"");
0043 shouldBe("StripSpaces(Object.prototype.isPrototypeOf.toString())","\"functionisPrototypeOf(){[nativecode]}\"");
0044 shouldBe("StripSpaces(Object.prototype.propertyIsEnumerable.toString())","\"functionpropertyIsEnumerable(){[nativecode]}\"");
0045 
0046 shouldBe("StripSpaces(Function.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
0047 shouldBe("StripSpaces(Function.prototype.apply.toString())","\"functionapply(){[nativecode]}\"");
0048 shouldBe("StripSpaces(Function.prototype.call.toString())","\"functioncall(){[nativecode]}\"");
0049 
0050 shouldBe("StripSpaces(Array.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
0051 shouldBe("StripSpaces(Array.prototype.toLocaleString.toString())","\"functiontoLocaleString(){[nativecode]}\"");
0052 shouldBe("StripSpaces(Array.prototype.concat.toString())","\"functionconcat(){[nativecode]}\"");
0053 shouldBe("StripSpaces(Array.prototype.join.toString())","\"functionjoin(){[nativecode]}\"");
0054 shouldBe("StripSpaces(Array.prototype.pop.toString())","\"functionpop(){[nativecode]}\"");
0055 shouldBe("StripSpaces(Array.prototype.push.toString())","\"functionpush(){[nativecode]}\"");
0056 shouldBe("StripSpaces(Array.prototype.reverse.toString())","\"functionreverse(){[nativecode]}\"");
0057 shouldBe("StripSpaces(Array.prototype.shift.toString())","\"functionshift(){[nativecode]}\"");
0058 shouldBe("StripSpaces(Array.prototype.slice.toString())","\"functionslice(){[nativecode]}\"");
0059 shouldBe("StripSpaces(Array.prototype.sort.toString())","\"functionsort(){[nativecode]}\"");
0060 shouldBe("StripSpaces(Array.prototype.splice.toString())","\"functionsplice(){[nativecode]}\"");
0061 shouldBe("StripSpaces(Array.prototype.unshift.toString())","\"functionunshift(){[nativecode]}\"");
0062 
0063 shouldBe("StripSpaces(String.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
0064 shouldBe("StripSpaces(String.prototype.valueOf.toString())","\"functionvalueOf(){[nativecode]}\"");
0065 shouldBe("StripSpaces(String.prototype.charAt.toString())","\"functioncharAt(){[nativecode]}\"");
0066 shouldBe("StripSpaces(String.prototype.charCodeAt.toString())","\"functioncharCodeAt(){[nativecode]}\"");
0067 shouldBe("StripSpaces(String.prototype.concat.toString())","\"functionconcat(){[nativecode]}\"");
0068 shouldBe("StripSpaces(String.prototype.indexOf.toString())","\"functionindexOf(){[nativecode]}\"");
0069 shouldBe("StripSpaces(String.prototype.lastIndexOf.toString())","\"functionlastIndexOf(){[nativecode]}\"");
0070 shouldBe("StripSpaces(String.prototype.match.toString())","\"functionmatch(){[nativecode]}\"");
0071 shouldBe("StripSpaces(String.prototype.replace.toString())","\"functionreplace(){[nativecode]}\"");
0072 shouldBe("StripSpaces(String.prototype.search.toString())","\"functionsearch(){[nativecode]}\"");
0073 shouldBe("StripSpaces(String.prototype.slice.toString())","\"functionslice(){[nativecode]}\"");
0074 shouldBe("StripSpaces(String.prototype.split.toString())","\"functionsplit(){[nativecode]}\"");
0075 shouldBe("StripSpaces(String.prototype.substr.toString())","\"functionsubstr(){[nativecode]}\"");
0076 shouldBe("StripSpaces(String.prototype.substring.toString())","\"functionsubstring(){[nativecode]}\"");
0077 shouldBe("StripSpaces(String.prototype.toLowerCase.toString())","\"functiontoLowerCase(){[nativecode]}\"");
0078 shouldBe("StripSpaces(String.prototype.toUpperCase.toString())","\"functiontoUpperCase(){[nativecode]}\"");
0079 shouldBe("StripSpaces(String.prototype.big.toString())","\"functionbig(){[nativecode]}\"");
0080 shouldBe("StripSpaces(String.prototype.small.toString())","\"functionsmall(){[nativecode]}\"");
0081 shouldBe("StripSpaces(String.prototype.blink.toString())","\"functionblink(){[nativecode]}\"");
0082 shouldBe("StripSpaces(String.prototype.bold.toString())","\"functionbold(){[nativecode]}\"");
0083 shouldBe("StripSpaces(String.prototype.fixed.toString())","\"functionfixed(){[nativecode]}\"");
0084 shouldBe("StripSpaces(String.prototype.italics.toString())","\"functionitalics(){[nativecode]}\"");
0085 shouldBe("StripSpaces(String.prototype.strike.toString())","\"functionstrike(){[nativecode]}\"");
0086 shouldBe("StripSpaces(String.prototype.sub.toString())","\"functionsub(){[nativecode]}\"");
0087 shouldBe("StripSpaces(String.prototype.sup.toString())","\"functionsup(){[nativecode]}\"");
0088 shouldBe("StripSpaces(String.prototype.fontcolor.toString())","\"functionfontcolor(){[nativecode]}\"");
0089 shouldBe("StripSpaces(String.prototype.fontsize.toString())","\"functionfontsize(){[nativecode]}\"");
0090 shouldBe("StripSpaces(String.prototype.anchor.toString())","\"functionanchor(){[nativecode]}\"");
0091 shouldBe("StripSpaces(String.prototype.link.toString())","\"functionlink(){[nativecode]}\"");
0092 
0093 shouldBe("StripSpaces(Boolean.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
0094 shouldBe("StripSpaces(Boolean.prototype.valueOf.toString())","\"functionvalueOf(){[nativecode]}\"");
0095 
0096 shouldBe("StripSpaces(Number.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
0097 shouldBe("StripSpaces(Number.prototype.toLocaleString.toString())","\"functiontoLocaleString(){[nativecode]}\"");
0098 shouldBe("StripSpaces(Number.prototype.valueOf.toString())","\"functionvalueOf(){[nativecode]}\"");
0099 shouldBe("StripSpaces(Number.prototype.toFixed.toString())","\"functiontoFixed(){[nativecode]}\"");
0100 shouldBe("StripSpaces(Number.prototype.toExponential.toString())","\"functiontoExponential(){[nativecode]}\"");
0101 shouldBe("StripSpaces(Number.prototype.toPrecision.toString())","\"functiontoPrecision(){[nativecode]}\"");
0102 
0103 shouldBe("StripSpaces(Math.abs.toString())","\"functionabs(){[nativecode]}\"");
0104 shouldBe("StripSpaces(Math.acos.toString())","\"functionacos(){[nativecode]}\"");
0105 shouldBe("StripSpaces(Math.asin.toString())","\"functionasin(){[nativecode]}\"");
0106 shouldBe("StripSpaces(Math.atan.toString())","\"functionatan(){[nativecode]}\"");
0107 shouldBe("StripSpaces(Math.atan2.toString())","\"functionatan2(){[nativecode]}\"");
0108 shouldBe("StripSpaces(Math.ceil.toString())","\"functionceil(){[nativecode]}\"");
0109 shouldBe("StripSpaces(Math.cos.toString())","\"functioncos(){[nativecode]}\"");
0110 shouldBe("StripSpaces(Math.exp.toString())","\"functionexp(){[nativecode]}\"");
0111 shouldBe("StripSpaces(Math.floor.toString())","\"functionfloor(){[nativecode]}\"");
0112 shouldBe("StripSpaces(Math.log.toString())","\"functionlog(){[nativecode]}\"");
0113 shouldBe("StripSpaces(Math.max.toString())","\"functionmax(){[nativecode]}\"");
0114 shouldBe("StripSpaces(Math.min.toString())","\"functionmin(){[nativecode]}\"");
0115 shouldBe("StripSpaces(Math.pow.toString())","\"functionpow(){[nativecode]}\"");
0116 shouldBe("StripSpaces(Math.random.toString())","\"functionrandom(){[nativecode]}\"");
0117 shouldBe("StripSpaces(Math.round.toString())","\"functionround(){[nativecode]}\"");
0118 shouldBe("StripSpaces(Math.sin.toString())","\"functionsin(){[nativecode]}\"");
0119 shouldBe("StripSpaces(Math.sqrt.toString())","\"functionsqrt(){[nativecode]}\"");
0120 shouldBe("StripSpaces(Math.tan.toString())","\"functiontan(){[nativecode]}\"");
0121 
0122 shouldBe("StripSpaces(Date.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
0123 shouldBe("StripSpaces(Date.prototype.toUTCString.toString())","\"functiontoUTCString(){[nativecode]}\"");
0124 shouldBe("StripSpaces(Date.prototype.toDateString.toString())","\"functiontoDateString(){[nativecode]}\"");
0125 shouldBe("StripSpaces(Date.prototype.toTimeString.toString())","\"functiontoTimeString(){[nativecode]}\"");
0126 shouldBe("StripSpaces(Date.prototype.toLocaleString.toString())","\"functiontoLocaleString(){[nativecode]}\"");
0127 shouldBe("StripSpaces(Date.prototype.toLocaleDateString.toString())","\"functiontoLocaleDateString(){[nativecode]}\"");
0128 shouldBe("StripSpaces(Date.prototype.toLocaleTimeString.toString())","\"functiontoLocaleTimeString(){[nativecode]}\"");
0129 shouldBe("StripSpaces(Date.prototype.valueOf.toString())","\"functionvalueOf(){[nativecode]}\"");
0130 shouldBe("StripSpaces(Date.prototype.getTime.toString())","\"functiongetTime(){[nativecode]}\"");
0131 shouldBe("StripSpaces(Date.prototype.getFullYear.toString())","\"functiongetFullYear(){[nativecode]}\"");
0132 shouldBe("StripSpaces(Date.prototype.getUTCFullYear.toString())","\"functiongetUTCFullYear(){[nativecode]}\"");
0133 shouldBe("StripSpaces(Date.prototype.toGMTString.toString())","\"functiontoGMTString(){[nativecode]}\"");
0134 shouldBe("StripSpaces(Date.prototype.getMonth.toString())","\"functiongetMonth(){[nativecode]}\"");
0135 shouldBe("StripSpaces(Date.prototype.getUTCMonth.toString())","\"functiongetUTCMonth(){[nativecode]}\"");
0136 shouldBe("StripSpaces(Date.prototype.getDate.toString())","\"functiongetDate(){[nativecode]}\"");
0137 shouldBe("StripSpaces(Date.prototype.getUTCDate.toString())","\"functiongetUTCDate(){[nativecode]}\"");
0138 shouldBe("StripSpaces(Date.prototype.getDay.toString())","\"functiongetDay(){[nativecode]}\"");
0139 shouldBe("StripSpaces(Date.prototype.getUTCDay.toString())","\"functiongetUTCDay(){[nativecode]}\"");
0140 shouldBe("StripSpaces(Date.prototype.getHours.toString())","\"functiongetHours(){[nativecode]}\"");
0141 shouldBe("StripSpaces(Date.prototype.getUTCHours.toString())","\"functiongetUTCHours(){[nativecode]}\"");
0142 shouldBe("StripSpaces(Date.prototype.getMinutes.toString())","\"functiongetMinutes(){[nativecode]}\"");
0143 shouldBe("StripSpaces(Date.prototype.getUTCMinutes.toString())","\"functiongetUTCMinutes(){[nativecode]}\"");
0144 shouldBe("StripSpaces(Date.prototype.getSeconds.toString())","\"functiongetSeconds(){[nativecode]}\"");
0145 shouldBe("StripSpaces(Date.prototype.getUTCSeconds.toString())","\"functiongetUTCSeconds(){[nativecode]}\"");
0146 shouldBe("StripSpaces(Date.prototype.getMilliseconds.toString())","\"functiongetMilliseconds(){[nativecode]}\"");
0147 shouldBe("StripSpaces(Date.prototype.getUTCMilliseconds.toString())","\"functiongetUTCMilliseconds(){[nativecode]}\"");
0148 shouldBe("StripSpaces(Date.prototype.getTimezoneOffset.toString())","\"functiongetTimezoneOffset(){[nativecode]}\"");
0149 shouldBe("StripSpaces(Date.prototype.setTime.toString())","\"functionsetTime(){[nativecode]}\"");
0150 shouldBe("StripSpaces(Date.prototype.setMilliseconds.toString())","\"functionsetMilliseconds(){[nativecode]}\"");
0151 shouldBe("StripSpaces(Date.prototype.setUTCMilliseconds.toString())","\"functionsetUTCMilliseconds(){[nativecode]}\"");
0152 shouldBe("StripSpaces(Date.prototype.setSeconds.toString())","\"functionsetSeconds(){[nativecode]}\"");
0153 shouldBe("StripSpaces(Date.prototype.setUTCSeconds.toString())","\"functionsetUTCSeconds(){[nativecode]}\"");
0154 shouldBe("StripSpaces(Date.prototype.setMinutes.toString())","\"functionsetMinutes(){[nativecode]}\"");
0155 shouldBe("StripSpaces(Date.prototype.setUTCMinutes.toString())","\"functionsetUTCMinutes(){[nativecode]}\"");
0156 shouldBe("StripSpaces(Date.prototype.setHours.toString())","\"functionsetHours(){[nativecode]}\"");
0157 shouldBe("StripSpaces(Date.prototype.setUTCHours.toString())","\"functionsetUTCHours(){[nativecode]}\"");
0158 shouldBe("StripSpaces(Date.prototype.setDate.toString())","\"functionsetDate(){[nativecode]}\"");
0159 shouldBe("StripSpaces(Date.prototype.setUTCDate.toString())","\"functionsetUTCDate(){[nativecode]}\"");
0160 shouldBe("StripSpaces(Date.prototype.setMonth.toString())","\"functionsetMonth(){[nativecode]}\"");
0161 shouldBe("StripSpaces(Date.prototype.setUTCMonth.toString())","\"functionsetUTCMonth(){[nativecode]}\"");
0162 shouldBe("StripSpaces(Date.prototype.setFullYear.toString())","\"functionsetFullYear(){[nativecode]}\"");
0163 shouldBe("StripSpaces(Date.prototype.setUTCFullYear.toString())","\"functionsetUTCFullYear(){[nativecode]}\"");
0164 shouldBe("StripSpaces(Date.prototype.setYear.toString())","\"functionsetYear(){[nativecode]}\"");
0165 shouldBe("StripSpaces(Date.prototype.getYear.toString())","\"functiongetYear(){[nativecode]}\"");
0166 shouldBe("StripSpaces(Date.prototype.toGMTString.toString())","\"functiontoGMTString(){[nativecode]}\"");
0167 
0168 shouldBe("StripSpaces(RegExp.prototype.exec.toString())","\"functionexec(){[nativecode]}\"");
0169 shouldBe("StripSpaces(RegExp.prototype.test.toString())","\"functiontest(){[nativecode]}\"");
0170 shouldBe("StripSpaces(RegExp.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
0171 
0172 shouldBe("StripSpaces(Error.prototype.toString.toString())","\"functiontoString(){[nativecode]}\"");
0173 
0174 
0175 function testConstructor(name) {
0176     shouldBe("StripSpaces(" + name + " .toString())", "\"function" + name + "(){[nativecode]}\"");
0177 }
0178 
0179 testConstructor("Object");
0180 testConstructor("Function");
0181 testConstructor("Array");
0182 testConstructor("Boolean");
0183 testConstructor("String");
0184 testConstructor("Number");
0185 testConstructor("Date");
0186 testConstructor("RegExp");
0187 testConstructor("Error");
0188 testConstructor("EvalError");
0189 testConstructor("RangeError");
0190 testConstructor("ReferenceError");
0191 testConstructor("SyntaxError");
0192 testConstructor("TypeError");
0193 testConstructor("URIError");