OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="resources/js-test-pre.js"></script> | 2 <script src="resources/js-test-pre.js"></script> |
3 <script> | 3 <script> |
4 description("Exercise WebIDL type conversions."); | 4 description("Exercise WebIDL type conversions."); |
5 | 5 |
6 quiet = true; | 6 quiet = true; |
7 evalAndLog("converter = window.internals.typeConversions()"); | 7 evalAndLog("converter = window.internals.typeConversions()"); |
8 debug(""); | 8 debug(""); |
9 | 9 |
10 function verifyAttribute(attribute) | 10 function verifyAttribute(attribute) |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 convertThrows(type, "-Number.MAX_VALUE"); | 318 convertThrows(type, "-Number.MAX_VALUE"); |
319 convert(type, "1.99", "1"); | 319 convert(type, "1.99", "1"); |
320 convertThrows(type, "-1.99"); | 320 convertThrows(type, "-1.99"); |
321 convertThrows(type, "Infinity"); | 321 convertThrows(type, "Infinity"); |
322 convertThrows(type, "-Infinity"); | 322 convertThrows(type, "-Infinity"); |
323 convertThrows(type, "NaN"); | 323 convertThrows(type, "NaN"); |
324 testNonNumericToNumericEnforceRange(type); | 324 testNonNumericToNumericEnforceRange(type); |
325 convertThrows(type, "{valueOf:function(){throw new Error('custom');}}"); | 325 convertThrows(type, "{valueOf:function(){throw new Error('custom');}}"); |
326 debug(""); | 326 debug(""); |
327 | 327 |
| 328 type = "testByte"; |
| 329 verifyAttribute(type); |
| 330 convert(type, "0"); |
| 331 convert(type, "-1"); |
| 332 convert(type, "1"); |
| 333 convert(type, "0x7F"); |
| 334 convert(type, "0x80", "-0x80"); |
| 335 convert(type, "-0x7F"); |
| 336 convert(type, "-0x80"); |
| 337 convert(type, "-0x81", "0x7F"); |
| 338 convert(type, "0x1234", "0x34"); |
| 339 convert(type, "Number.MIN_VALUE", "0"); |
| 340 convert(type, "-Number.MIN_VALUE", "0"); |
| 341 convert(type, "Number.MAX_VALUE", "0"); |
| 342 convert(type, "-Number.MAX_VALUE", "0"); |
| 343 convert(type, "1.99", "1"); |
| 344 convert(type, "-1.99", "-1"); |
| 345 convert(type, "4660.99", "0x34"); |
| 346 convert(type, "Infinity", "0"); |
| 347 convert(type, "-Infinity", "0"); |
| 348 convert(type, "NaN", "0"); |
| 349 testNonNumericToNumeric(type); |
| 350 convertThrows(type, "{valueOf:function(){throw new Error('custom');}}"); |
| 351 debug(""); |
| 352 |
| 353 type = "testEnforceRangeByte"; |
| 354 verifyAttribute(type); |
| 355 convert(type, "0"); |
| 356 convert(type, "-1"); |
| 357 convert(type, "1"); |
| 358 convert(type, "0x7F"); |
| 359 convertThrows(type, "0x80"); |
| 360 convert(type, "-0x7F"); |
| 361 convert(type, "-0x80"); |
| 362 convertThrows(type, "-0x81"); |
| 363 convertThrows(type, "0x1234"); |
| 364 convert(type, "Number.MIN_VALUE", "0"); |
| 365 convert(type, "-Number.MIN_VALUE", "0"); |
| 366 convertThrows(type, "Number.MAX_VALUE"); |
| 367 convertThrows(type, "-Number.MAX_VALUE"); |
| 368 convert(type, "1.99", "1"); |
| 369 convert(type, "-1.99", "-1"); |
| 370 convertThrows(type, "4660.99"); |
| 371 convertThrows(type, "Infinity"); |
| 372 convertThrows(type, "-Infinity"); |
| 373 convertThrows(type, "NaN"); |
| 374 testNonNumericToNumericEnforceRange(type); |
| 375 convertThrows(type, "{valueOf:function(){throw new Error('custom');}}"); |
| 376 debug(""); |
| 377 |
| 378 type = "testOctet"; |
| 379 verifyAttribute(type); |
| 380 convert(type, "0"); |
| 381 convert(type, "-1", "0xFF"); |
| 382 convert(type, "1"); |
| 383 convert(type, "0x7F"); |
| 384 convert(type, "0x80"); |
| 385 convert(type, "0xFF"); |
| 386 convert(type, "0x100", "0"); |
| 387 convert(type, "0x101", "1"); |
| 388 convert(type, "-0x80", "0x80"); |
| 389 convert(type, "-0x81", "0x7F"); |
| 390 convert(type, "0x1234", "0x34"); |
| 391 convert(type, "Number.MAX_VALUE", "0"); |
| 392 convert(type, "Number.MIN_VALUE", "0"); |
| 393 convert(type, "-Number.MAX_VALUE", "0"); |
| 394 convert(type, "-Number.MIN_VALUE", "0"); |
| 395 convert(type, "1.99", "1"); |
| 396 convert(type, "-1.99", "0xFF"); |
| 397 convert(type, "4660.99", "0x34"); |
| 398 convert(type, "Infinity", "0"); |
| 399 convert(type, "-Infinity", "0"); |
| 400 convert(type, "NaN", "0"); |
| 401 testNonNumericToNumeric(type); |
| 402 convertThrows(type, "{valueOf:function(){throw new Error('custom');}}"); |
| 403 debug(""); |
| 404 |
| 405 type = "testEnforceRangeOctet"; |
| 406 verifyAttribute(type); |
| 407 convert(type, "0"); |
| 408 convertThrows(type, "-1"); |
| 409 convert(type, "1"); |
| 410 convert(type, "0x7F"); |
| 411 convert(type, "0x80"); |
| 412 convert(type, "0xFF"); |
| 413 convertThrows(type, "0x100"); |
| 414 convertThrows(type, "0x101"); |
| 415 convertThrows(type, "-0x80"); |
| 416 convertThrows(type, "-0x81"); |
| 417 convertThrows(type, "0x1234"); |
| 418 convertThrows(type, "Number.MAX_VALUE"); |
| 419 convert(type, "Number.MIN_VALUE", "0"); |
| 420 convertThrows(type, "-Number.MAX_VALUE"); |
| 421 convert(type, "-Number.MIN_VALUE", "0"); |
| 422 convert(type, "1.99", "1"); |
| 423 convertThrows(type, "-1.99"); |
| 424 convertThrows(type, "4660.99"); |
| 425 convertThrows(type, "Infinity"); |
| 426 convertThrows(type, "-Infinity"); |
| 427 convertThrows(type, "NaN"); |
| 428 testNonNumericToNumericEnforceRange(type); |
| 429 convertThrows(type, "{valueOf:function(){throw new Error('custom');}}"); |
| 430 debug(""); |
| 431 |
328 </script> | 432 </script> |
329 <script src="resources/js-test-post.js"></script> | 433 <script src="resources/js-test-post.js"></script> |
OLD | NEW |