| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
gTestfile = '15.1.2.5-1.js'; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
var SECTION = "15.1.2.5-1"; |
| 54 |
var VERSION = "ECMA_1"; |
| 55 |
startTest(); |
| 56 |
var TITLE = "unescape(string)"; |
| 57 |
|
| 58 |
writeHeaderToLog( SECTION + " "+ TITLE); |
| 59 |
|
| 60 |
new TestCase( SECTION, "unescape.length", 1, unescape.length ); |
| 61 |
new TestCase( SECTION, "unescape.length = null; unescape.length", 1, eval("unescape.length=null; unescape.length") ); |
| 62 |
new TestCase( SECTION, "delete unescape.length", false, delete unescape.length ); |
| 63 |
new TestCase( SECTION, "delete unescape.length; unescape.length", 1, eval("delete unescape.length; unescape.length") ); |
| 64 |
new TestCase( SECTION, "var MYPROPS=''; for ( var p in unescape ) { MYPROPS+= p }; MYPROPS", "prototype", eval("var MYPROPS=''; for ( var p in unescape ) { MYPROPS+= p }; MYPROPS") ); |
| 65 |
|
| 66 |
new TestCase( SECTION, "unescape()", "undefined", unescape() ); |
| 67 |
new TestCase( SECTION, "unescape('')", "", unescape('') ); |
| 68 |
new TestCase( SECTION, "unescape( null )", "null", unescape(null) ); |
| 69 |
new TestCase( SECTION, "unescape( void 0 )", "undefined", unescape(void 0) ); |
| 70 |
new TestCase( SECTION, "unescape( true )", "true", unescape( true ) ); |
| 71 |
new TestCase( SECTION, "unescape( false )", "false", unescape( false ) ); |
| 72 |
|
| 73 |
new TestCase( SECTION, "unescape( new Boolean(true) )", "true", unescape(new Boolean(true)) ); |
| 74 |
new TestCase( SECTION, "unescape( new Boolean(false) )", "false", unescape(new Boolean(false)) ); |
| 75 |
|
| 76 |
new TestCase( SECTION, "unescape( Number.NaN )", "NaN", unescape(Number.NaN) ); |
| 77 |
new TestCase( SECTION, "unescape( -0 )", "0", unescape( -0 ) ); |
| 78 |
new TestCase( SECTION, "unescape( 'Infinity' )", "Infinity", unescape( "Infinity" ) ); |
| 79 |
new TestCase( SECTION, "unescape( Number.POSITIVE_INFINITY )", "Infinity", unescape( Number.POSITIVE_INFINITY ) ); |
| 80 |
new TestCase( SECTION, "unescape( Number.NEGATIVE_INFINITY )", "-Infinity", unescape( Number.NEGATIVE_INFINITY ) ); |
| 81 |
|
| 82 |
var ASCII_TEST_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./"; |
| 83 |
|
| 84 |
new TestCase( SECTION, "unescape( " +ASCII_TEST_STRING+" )", ASCII_TEST_STRING, unescape( ASCII_TEST_STRING ) ); |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { |
| 89 |
new TestCase( SECTION, |
| 90 |
"unescape( %"+ ToHexString(CHARCODE)+" )", |
| 91 |
String.fromCharCode(CHARCODE), |
| 92 |
unescape( "%" + ToHexString(CHARCODE) ) ); |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { |
| 97 |
new TestCase( SECTION, |
| 98 |
"unescape( %u"+ ToHexString(CHARCODE)+" )", |
| 99 |
"%u"+ToHexString(CHARCODE), |
| 100 |
unescape( "%u" + ToHexString(CHARCODE) ) ); |
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
test(); |
| 118 |
|
| 119 |
function ToUnicodeString( n ) { |
| 120 |
var string = ToHexString(n); |
| 121 |
|
| 122 |
for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { |
| 123 |
string = "0" + string; |
| 124 |
} |
| 125 |
|
| 126 |
return string; |
| 127 |
} |
| 128 |
function ToHexString( n ) { |
| 129 |
var hex = new Array(); |
| 130 |
|
| 131 |
for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { |
| 132 |
; |
| 133 |
} |
| 134 |
|
| 135 |
for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { |
| 136 |
hex[index] = Math.floor( n / Math.pow(16,mag) ); |
| 137 |
n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); |
| 138 |
} |
| 139 |
|
| 140 |
hex[hex.length] = n % 16; |
| 141 |
|
| 142 |
var string =""; |
| 143 |
|
| 144 |
for ( var index = 0 ; index < hex.length ; index++ ) { |
| 145 |
switch ( hex[index] ) { |
| 146 |
case 10: |
| 147 |
string += "A"; |
| 148 |
break; |
| 149 |
case 11: |
| 150 |
string += "B"; |
| 151 |
break; |
| 152 |
case 12: |
| 153 |
string += "C"; |
| 154 |
break; |
| 155 |
case 13: |
| 156 |
string += "D"; |
| 157 |
break; |
| 158 |
case 14: |
| 159 |
string += "E"; |
| 160 |
break; |
| 161 |
case 15: |
| 162 |
string += "F"; |
| 163 |
break; |
| 164 |
default: |
| 165 |
string += hex[index]; |
| 166 |
} |
| 167 |
} |
| 168 |
|
| 169 |
if ( string.length == 1 ) { |
| 170 |
string = "0" + string; |
| 171 |
} |
| 172 |
return string; |
| 173 |
} |