Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | File Name: 7.7.3.js |
michael@0 | 9 | ECMA Section: 7.7.3 Numeric Literals |
michael@0 | 10 | |
michael@0 | 11 | Description: A numeric literal stands for a value of the Number type |
michael@0 | 12 | This value is determined in two steps: first a |
michael@0 | 13 | mathematical value (MV) is derived from the literal; |
michael@0 | 14 | second, this mathematical value is rounded, ideally |
michael@0 | 15 | using IEEE 754 round-to-nearest mode, to a reprentable |
michael@0 | 16 | value of of the number type. |
michael@0 | 17 | |
michael@0 | 18 | Author: christine@netscape.com |
michael@0 | 19 | Date: 16 september 1997 |
michael@0 | 20 | */ |
michael@0 | 21 | var SECTION = "7.7.3"; |
michael@0 | 22 | var VERSION = "ECMA_1"; |
michael@0 | 23 | startTest(); |
michael@0 | 24 | var TITLE = "Numeric Literals"; |
michael@0 | 25 | |
michael@0 | 26 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 27 | |
michael@0 | 28 | new TestCase( SECTION, "0", 0, 0 ); |
michael@0 | 29 | new TestCase( SECTION, "1", 1, 1 ); |
michael@0 | 30 | new TestCase( SECTION, "2", 2, 2 ); |
michael@0 | 31 | new TestCase( SECTION, "3", 3, 3 ); |
michael@0 | 32 | new TestCase( SECTION, "4", 4, 4 ); |
michael@0 | 33 | new TestCase( SECTION, "5", 5, 5 ); |
michael@0 | 34 | new TestCase( SECTION, "6", 6, 6 ); |
michael@0 | 35 | new TestCase( SECTION, "7", 7, 7 ); |
michael@0 | 36 | new TestCase( SECTION, "8", 8, 8 ); |
michael@0 | 37 | new TestCase( SECTION, "9", 9, 9 ); |
michael@0 | 38 | |
michael@0 | 39 | new TestCase( SECTION, "0.", 0, 0. ); |
michael@0 | 40 | new TestCase( SECTION, "1.", 1, 1. ); |
michael@0 | 41 | new TestCase( SECTION, "2.", 2, 2. ); |
michael@0 | 42 | new TestCase( SECTION, "3.", 3, 3. ); |
michael@0 | 43 | new TestCase( SECTION, "4.", 4, 4. ); |
michael@0 | 44 | |
michael@0 | 45 | new TestCase( SECTION, "0.e0", 0, 0.e0 ); |
michael@0 | 46 | new TestCase( SECTION, "1.e1", 10, 1.e1 ); |
michael@0 | 47 | new TestCase( SECTION, "2.e2", 200, 2.e2 ); |
michael@0 | 48 | new TestCase( SECTION, "3.e3", 3000, 3.e3 ); |
michael@0 | 49 | new TestCase( SECTION, "4.e4", 40000, 4.e4 ); |
michael@0 | 50 | |
michael@0 | 51 | new TestCase( SECTION, "0.1e0", .1, 0.1e0 ); |
michael@0 | 52 | new TestCase( SECTION, "1.1e1", 11, 1.1e1 ); |
michael@0 | 53 | new TestCase( SECTION, "2.2e2", 220, 2.2e2 ); |
michael@0 | 54 | new TestCase( SECTION, "3.3e3", 3300, 3.3e3 ); |
michael@0 | 55 | new TestCase( SECTION, "4.4e4", 44000, 4.4e4 ); |
michael@0 | 56 | |
michael@0 | 57 | new TestCase( SECTION, ".1e0", .1, .1e0 ); |
michael@0 | 58 | new TestCase( SECTION, ".1e1", 1, .1e1 ); |
michael@0 | 59 | new TestCase( SECTION, ".2e2", 20, .2e2 ); |
michael@0 | 60 | new TestCase( SECTION, ".3e3", 300, .3e3 ); |
michael@0 | 61 | new TestCase( SECTION, ".4e4", 4000, .4e4 ); |
michael@0 | 62 | |
michael@0 | 63 | new TestCase( SECTION, "0e0", 0, 0e0 ); |
michael@0 | 64 | new TestCase( SECTION, "1e1", 10, 1e1 ); |
michael@0 | 65 | new TestCase( SECTION, "2e2", 200, 2e2 ); |
michael@0 | 66 | new TestCase( SECTION, "3e3", 3000, 3e3 ); |
michael@0 | 67 | new TestCase( SECTION, "4e4", 40000, 4e4 ); |
michael@0 | 68 | |
michael@0 | 69 | new TestCase( SECTION, "0e0", 0, 0e0 ); |
michael@0 | 70 | new TestCase( SECTION, "1e1", 10, 1e1 ); |
michael@0 | 71 | new TestCase( SECTION, "2e2", 200, 2e2 ); |
michael@0 | 72 | new TestCase( SECTION, "3e3", 3000, 3e3 ); |
michael@0 | 73 | new TestCase( SECTION, "4e4", 40000, 4e4 ); |
michael@0 | 74 | |
michael@0 | 75 | new TestCase( SECTION, "0E0", 0, 0E0 ); |
michael@0 | 76 | new TestCase( SECTION, "1E1", 10, 1E1 ); |
michael@0 | 77 | new TestCase( SECTION, "2E2", 200, 2E2 ); |
michael@0 | 78 | new TestCase( SECTION, "3E3", 3000, 3E3 ); |
michael@0 | 79 | new TestCase( SECTION, "4E4", 40000, 4E4 ); |
michael@0 | 80 | |
michael@0 | 81 | new TestCase( SECTION, "1.e-1", 0.1, 1.e-1 ); |
michael@0 | 82 | new TestCase( SECTION, "2.e-2", 0.02, 2.e-2 ); |
michael@0 | 83 | new TestCase( SECTION, "3.e-3", 0.003, 3.e-3 ); |
michael@0 | 84 | new TestCase( SECTION, "4.e-4", 0.0004, 4.e-4 ); |
michael@0 | 85 | |
michael@0 | 86 | new TestCase( SECTION, "0.1e-0", .1, 0.1e-0 ); |
michael@0 | 87 | new TestCase( SECTION, "1.1e-1", 0.11, 1.1e-1 ); |
michael@0 | 88 | new TestCase( SECTION, "2.2e-2", .022, 2.2e-2 ); |
michael@0 | 89 | new TestCase( SECTION, "3.3e-3", .0033, 3.3e-3 ); |
michael@0 | 90 | new TestCase( SECTION, "4.4e-4", .00044, 4.4e-4 ); |
michael@0 | 91 | |
michael@0 | 92 | new TestCase( SECTION, ".1e-0", .1, .1e-0 ); |
michael@0 | 93 | new TestCase( SECTION, ".1e-1", .01, .1e-1 ); |
michael@0 | 94 | new TestCase( SECTION, ".2e-2", .002, .2e-2 ); |
michael@0 | 95 | new TestCase( SECTION, ".3e-3", .0003, .3e-3 ); |
michael@0 | 96 | new TestCase( SECTION, ".4e-4", .00004, .4e-4 ); |
michael@0 | 97 | |
michael@0 | 98 | new TestCase( SECTION, "1.e+1", 10, 1.e+1 ); |
michael@0 | 99 | new TestCase( SECTION, "2.e+2", 200, 2.e+2 ); |
michael@0 | 100 | new TestCase( SECTION, "3.e+3", 3000, 3.e+3 ); |
michael@0 | 101 | new TestCase( SECTION, "4.e+4", 40000, 4.e+4 ); |
michael@0 | 102 | |
michael@0 | 103 | new TestCase( SECTION, "0.1e+0", .1, 0.1e+0 ); |
michael@0 | 104 | new TestCase( SECTION, "1.1e+1", 11, 1.1e+1 ); |
michael@0 | 105 | new TestCase( SECTION, "2.2e+2", 220, 2.2e+2 ); |
michael@0 | 106 | new TestCase( SECTION, "3.3e+3", 3300, 3.3e+3 ); |
michael@0 | 107 | new TestCase( SECTION, "4.4e+4", 44000, 4.4e+4 ); |
michael@0 | 108 | |
michael@0 | 109 | new TestCase( SECTION, ".1e+0", .1, .1e+0 ); |
michael@0 | 110 | new TestCase( SECTION, ".1e+1", 1, .1e+1 ); |
michael@0 | 111 | new TestCase( SECTION, ".2e+2", 20, .2e+2 ); |
michael@0 | 112 | new TestCase( SECTION, ".3e+3", 300, .3e+3 ); |
michael@0 | 113 | new TestCase( SECTION, ".4e+4", 4000, .4e+4 ); |
michael@0 | 114 | |
michael@0 | 115 | new TestCase( SECTION, "0x0", 0, 0x0 ); |
michael@0 | 116 | new TestCase( SECTION, "0x1", 1, 0x1 ); |
michael@0 | 117 | new TestCase( SECTION, "0x2", 2, 0x2 ); |
michael@0 | 118 | new TestCase( SECTION, "0x3", 3, 0x3 ); |
michael@0 | 119 | new TestCase( SECTION, "0x4", 4, 0x4 ); |
michael@0 | 120 | new TestCase( SECTION, "0x5", 5, 0x5 ); |
michael@0 | 121 | new TestCase( SECTION, "0x6", 6, 0x6 ); |
michael@0 | 122 | new TestCase( SECTION, "0x7", 7, 0x7 ); |
michael@0 | 123 | new TestCase( SECTION, "0x8", 8, 0x8 ); |
michael@0 | 124 | new TestCase( SECTION, "0x9", 9, 0x9 ); |
michael@0 | 125 | new TestCase( SECTION, "0xa", 10, 0xa ); |
michael@0 | 126 | new TestCase( SECTION, "0xb", 11, 0xb ); |
michael@0 | 127 | new TestCase( SECTION, "0xc", 12, 0xc ); |
michael@0 | 128 | new TestCase( SECTION, "0xd", 13, 0xd ); |
michael@0 | 129 | new TestCase( SECTION, "0xe", 14, 0xe ); |
michael@0 | 130 | new TestCase( SECTION, "0xf", 15, 0xf ); |
michael@0 | 131 | |
michael@0 | 132 | new TestCase( SECTION, "0X0", 0, 0X0 ); |
michael@0 | 133 | new TestCase( SECTION, "0X1", 1, 0X1 ); |
michael@0 | 134 | new TestCase( SECTION, "0X2", 2, 0X2 ); |
michael@0 | 135 | new TestCase( SECTION, "0X3", 3, 0X3 ); |
michael@0 | 136 | new TestCase( SECTION, "0X4", 4, 0X4 ); |
michael@0 | 137 | new TestCase( SECTION, "0X5", 5, 0X5 ); |
michael@0 | 138 | new TestCase( SECTION, "0X6", 6, 0X6 ); |
michael@0 | 139 | new TestCase( SECTION, "0X7", 7, 0X7 ); |
michael@0 | 140 | new TestCase( SECTION, "0X8", 8, 0X8 ); |
michael@0 | 141 | new TestCase( SECTION, "0X9", 9, 0X9 ); |
michael@0 | 142 | new TestCase( SECTION, "0Xa", 10, 0Xa ); |
michael@0 | 143 | new TestCase( SECTION, "0Xb", 11, 0Xb ); |
michael@0 | 144 | new TestCase( SECTION, "0Xc", 12, 0Xc ); |
michael@0 | 145 | new TestCase( SECTION, "0Xd", 13, 0Xd ); |
michael@0 | 146 | new TestCase( SECTION, "0Xe", 14, 0Xe ); |
michael@0 | 147 | new TestCase( SECTION, "0Xf", 15, 0Xf ); |
michael@0 | 148 | |
michael@0 | 149 | new TestCase( SECTION, "0x0", 0, 0x0 ); |
michael@0 | 150 | new TestCase( SECTION, "0x1", 1, 0x1 ); |
michael@0 | 151 | new TestCase( SECTION, "0x2", 2, 0x2 ); |
michael@0 | 152 | new TestCase( SECTION, "0x3", 3, 0x3 ); |
michael@0 | 153 | new TestCase( SECTION, "0x4", 4, 0x4 ); |
michael@0 | 154 | new TestCase( SECTION, "0x5", 5, 0x5 ); |
michael@0 | 155 | new TestCase( SECTION, "0x6", 6, 0x6 ); |
michael@0 | 156 | new TestCase( SECTION, "0x7", 7, 0x7 ); |
michael@0 | 157 | new TestCase( SECTION, "0x8", 8, 0x8 ); |
michael@0 | 158 | new TestCase( SECTION, "0x9", 9, 0x9 ); |
michael@0 | 159 | new TestCase( SECTION, "0xA", 10, 0xA ); |
michael@0 | 160 | new TestCase( SECTION, "0xB", 11, 0xB ); |
michael@0 | 161 | new TestCase( SECTION, "0xC", 12, 0xC ); |
michael@0 | 162 | new TestCase( SECTION, "0xD", 13, 0xD ); |
michael@0 | 163 | new TestCase( SECTION, "0xE", 14, 0xE ); |
michael@0 | 164 | new TestCase( SECTION, "0xF", 15, 0xF ); |
michael@0 | 165 | |
michael@0 | 166 | new TestCase( SECTION, "0X0", 0, 0X0 ); |
michael@0 | 167 | new TestCase( SECTION, "0X1", 1, 0X1 ); |
michael@0 | 168 | new TestCase( SECTION, "0X2", 2, 0X2 ); |
michael@0 | 169 | new TestCase( SECTION, "0X3", 3, 0X3 ); |
michael@0 | 170 | new TestCase( SECTION, "0X4", 4, 0X4 ); |
michael@0 | 171 | new TestCase( SECTION, "0X5", 5, 0X5 ); |
michael@0 | 172 | new TestCase( SECTION, "0X6", 6, 0X6 ); |
michael@0 | 173 | new TestCase( SECTION, "0X7", 7, 0X7 ); |
michael@0 | 174 | new TestCase( SECTION, "0X8", 8, 0X8 ); |
michael@0 | 175 | new TestCase( SECTION, "0X9", 9, 0X9 ); |
michael@0 | 176 | new TestCase( SECTION, "0XA", 10, 0XA ); |
michael@0 | 177 | new TestCase( SECTION, "0XB", 11, 0XB ); |
michael@0 | 178 | new TestCase( SECTION, "0XC", 12, 0XC ); |
michael@0 | 179 | new TestCase( SECTION, "0XD", 13, 0XD ); |
michael@0 | 180 | new TestCase( SECTION, "0XE", 14, 0XE ); |
michael@0 | 181 | new TestCase( SECTION, "0XF", 15, 0XF ); |
michael@0 | 182 | |
michael@0 | 183 | |
michael@0 | 184 | new TestCase( SECTION, "00", 0, 00 ); |
michael@0 | 185 | new TestCase( SECTION, "01", 1, 01 ); |
michael@0 | 186 | new TestCase( SECTION, "02", 2, 02 ); |
michael@0 | 187 | new TestCase( SECTION, "03", 3, 03 ); |
michael@0 | 188 | new TestCase( SECTION, "04", 4, 04 ); |
michael@0 | 189 | new TestCase( SECTION, "05", 5, 05 ); |
michael@0 | 190 | new TestCase( SECTION, "06", 6, 06 ); |
michael@0 | 191 | new TestCase( SECTION, "07", 7, 07 ); |
michael@0 | 192 | |
michael@0 | 193 | new TestCase( SECTION, "000", 0, 000 ); |
michael@0 | 194 | new TestCase( SECTION, "011", 9, 011 ); |
michael@0 | 195 | new TestCase( SECTION, "022", 18, 022 ); |
michael@0 | 196 | new TestCase( SECTION, "033", 27, 033 ); |
michael@0 | 197 | new TestCase( SECTION, "044", 36, 044 ); |
michael@0 | 198 | new TestCase( SECTION, "055", 45, 055 ); |
michael@0 | 199 | new TestCase( SECTION, "066", 54, 066 ); |
michael@0 | 200 | new TestCase( SECTION, "077", 63, 077 ); |
michael@0 | 201 | |
michael@0 | 202 | new TestCase( SECTION, "0.00000000001", 0.00000000001, 0.00000000001 ); |
michael@0 | 203 | new TestCase( SECTION, "0.00000000001e-2", 0.0000000000001, 0.00000000001e-2 ); |
michael@0 | 204 | |
michael@0 | 205 | |
michael@0 | 206 | new TestCase( SECTION, |
michael@0 | 207 | "123456789012345671.9999", |
michael@0 | 208 | "123456789012345660", |
michael@0 | 209 | 123456789012345671.9999 +""); |
michael@0 | 210 | new TestCase( SECTION, |
michael@0 | 211 | "123456789012345672", |
michael@0 | 212 | "123456789012345660", |
michael@0 | 213 | 123456789012345672 +""); |
michael@0 | 214 | |
michael@0 | 215 | new TestCase( SECTION, |
michael@0 | 216 | "123456789012345672.000000000000000000000000000", |
michael@0 | 217 | "123456789012345660", |
michael@0 | 218 | 123456789012345672.000000000000000000000000000 +""); |
michael@0 | 219 | |
michael@0 | 220 | new TestCase( SECTION, |
michael@0 | 221 | "123456789012345672.01", |
michael@0 | 222 | "123456789012345680", |
michael@0 | 223 | 123456789012345672.01 +""); |
michael@0 | 224 | |
michael@0 | 225 | new TestCase( SECTION, |
michael@0 | 226 | "123456789012345672.000000000000000000000000001+'' == 123456789012345680 || 123456789012345660", |
michael@0 | 227 | true, |
michael@0 | 228 | ( 123456789012345672.00000000000000000000000000 +"" == 1234567890 * 100000000 + 12345680 ) |
michael@0 | 229 | || |
michael@0 | 230 | ( 123456789012345672.00000000000000000000000000 +"" == 1234567890 * 100000000 + 12345660) ); |
michael@0 | 231 | |
michael@0 | 232 | new TestCase( SECTION, |
michael@0 | 233 | "123456789012345673", |
michael@0 | 234 | "123456789012345680", |
michael@0 | 235 | 123456789012345673 +"" ); |
michael@0 | 236 | |
michael@0 | 237 | new TestCase( SECTION, |
michael@0 | 238 | "-123456789012345671.9999", |
michael@0 | 239 | "-123456789012345660", |
michael@0 | 240 | -123456789012345671.9999 +"" ); |
michael@0 | 241 | |
michael@0 | 242 | new TestCase( SECTION, |
michael@0 | 243 | "-123456789012345672", |
michael@0 | 244 | "-123456789012345660", |
michael@0 | 245 | -123456789012345672+""); |
michael@0 | 246 | |
michael@0 | 247 | new TestCase( SECTION, |
michael@0 | 248 | "-123456789012345672.000000000000000000000000000", |
michael@0 | 249 | "-123456789012345660", |
michael@0 | 250 | -123456789012345672.000000000000000000000000000 +""); |
michael@0 | 251 | |
michael@0 | 252 | new TestCase( SECTION, |
michael@0 | 253 | "-123456789012345672.01", |
michael@0 | 254 | "-123456789012345680", |
michael@0 | 255 | -123456789012345672.01 +"" ); |
michael@0 | 256 | |
michael@0 | 257 | new TestCase( SECTION, |
michael@0 | 258 | "-123456789012345672.000000000000000000000000001 == -123456789012345680 or -123456789012345660", |
michael@0 | 259 | true, |
michael@0 | 260 | (-123456789012345672.000000000000000000000000001 +"" == -1234567890 * 100000000 -12345680) |
michael@0 | 261 | || |
michael@0 | 262 | (-123456789012345672.000000000000000000000000001 +"" == -1234567890 * 100000000 -12345660)); |
michael@0 | 263 | |
michael@0 | 264 | new TestCase( SECTION, |
michael@0 | 265 | -123456789012345673, |
michael@0 | 266 | "-123456789012345680", |
michael@0 | 267 | -123456789012345673 +""); |
michael@0 | 268 | |
michael@0 | 269 | new TestCase( SECTION, |
michael@0 | 270 | "12345678901234567890", |
michael@0 | 271 | "12345678901234567000", |
michael@0 | 272 | 12345678901234567890 +"" ); |
michael@0 | 273 | |
michael@0 | 274 | |
michael@0 | 275 | /* |
michael@0 | 276 | new TestCase( SECTION, "12345678901234567", "12345678901234567", 12345678901234567+"" ); |
michael@0 | 277 | new TestCase( SECTION, "123456789012345678", "123456789012345678", 123456789012345678+"" ); |
michael@0 | 278 | new TestCase( SECTION, "1234567890123456789", "1234567890123456789", 1234567890123456789+"" ); |
michael@0 | 279 | new TestCase( SECTION, "12345678901234567890", "12345678901234567890", 12345678901234567890+"" ); |
michael@0 | 280 | new TestCase( SECTION, "123456789012345678900", "123456789012345678900", 123456789012345678900+"" ); |
michael@0 | 281 | new TestCase( SECTION, "1234567890123456789000", "1234567890123456789000", 1234567890123456789000+"" ); |
michael@0 | 282 | */ |
michael@0 | 283 | new TestCase( SECTION, "0x1", 1, 0x1 ); |
michael@0 | 284 | new TestCase( SECTION, "0x10", 16, 0x10 ); |
michael@0 | 285 | new TestCase( SECTION, "0x100", 256, 0x100 ); |
michael@0 | 286 | new TestCase( SECTION, "0x1000", 4096, 0x1000 ); |
michael@0 | 287 | new TestCase( SECTION, "0x10000", 65536, 0x10000 ); |
michael@0 | 288 | new TestCase( SECTION, "0x100000", 1048576, 0x100000 ); |
michael@0 | 289 | new TestCase( SECTION, "0x1000000", 16777216, 0x1000000 ); |
michael@0 | 290 | new TestCase( SECTION, "0x10000000", 268435456, 0x10000000 ); |
michael@0 | 291 | /* |
michael@0 | 292 | new TestCase( SECTION, "0x100000000", 4294967296, 0x100000000 ); |
michael@0 | 293 | new TestCase( SECTION, "0x1000000000", 68719476736, 0x1000000000 ); |
michael@0 | 294 | new TestCase( SECTION, "0x10000000000", 1099511627776, 0x10000000000 ); |
michael@0 | 295 | */ |
michael@0 | 296 | |
michael@0 | 297 | test(); |