| OLD | NEW |
| 1 /* | 1 /* |
| 2 Distributed under both the W3C Test Suite License [1] and the W3C | 2 Distributed under both the W3C Test Suite License [1] and the W3C |
| 3 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the | 3 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the |
| 4 policies and contribution forms [3]. | 4 policies and contribution forms [3]. |
| 5 | 5 |
| 6 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license | 6 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license |
| 7 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license | 7 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license |
| 8 [3] http://www.w3.org/2004/10/27-testcases | 8 [3] http://www.w3.org/2004/10/27-testcases |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 function awaitNCallbacks(n, cb, ctx) { | 90 function awaitNCallbacks(n, cb, ctx) { |
| 91 var counter = 0; | 91 var counter = 0; |
| 92 return function() { | 92 return function() { |
| 93 counter++; | 93 counter++; |
| 94 if (counter >= n) { | 94 if (counter >= n) { |
| 95 cb(); | 95 cb(); |
| 96 } | 96 } |
| 97 }; | 97 }; |
| 98 } | 98 } |
| 99 | 99 |
| 100 var fround = (function(){ |
| 101 if (Math.fround) return Math.fround; |
| 102 |
| 103 var arr = new Float32Array(1); |
| 104 return function fround(n) { |
| 105 arr[0] = n; |
| 106 return arr[0]; |
| 107 }; |
| 108 })(); |
| 109 |
| 100 /// IdlArray /// | 110 /// IdlArray /// |
| 101 // Entry point | 111 // Entry point |
| 102 self.IdlArray = function() | 112 self.IdlArray = function() |
| 103 //@{ | 113 //@{ |
| 104 { | 114 { |
| 105 /** | 115 /** |
| 106 * A map from strings to the corresponding named IdlObject, such as | 116 * A map from strings to the corresponding named IdlObject, such as |
| 107 * IdlInterface or IdlException. These are the things that test() will run | 117 * IdlInterface or IdlException. These are the things that test() will run |
| 108 * tests on. | 118 * tests on. |
| 109 */ | 119 */ |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 assert_equals(typeof value, "number"); | 460 assert_equals(typeof value, "number"); |
| 451 return; | 461 return; |
| 452 | 462 |
| 453 case "unsigned long long": | 463 case "unsigned long long": |
| 454 case "DOMTimeStamp": | 464 case "DOMTimeStamp": |
| 455 assert_equals(typeof value, "number"); | 465 assert_equals(typeof value, "number"); |
| 456 assert_true(0 <= value, "unsigned long long is negative"); | 466 assert_true(0 <= value, "unsigned long long is negative"); |
| 457 return; | 467 return; |
| 458 | 468 |
| 459 case "float": | 469 case "float": |
| 470 assert_equals(typeof value, "number"); |
| 471 assert_equals(value, fround(value), "float rounded to 32-bit float s
hould be itself"); |
| 472 assert_not_equals(value, Infinity); |
| 473 assert_not_equals(value, -Infinity); |
| 474 assert_not_equals(value, NaN); |
| 475 return; |
| 476 |
| 477 case "DOMHighResTimeStamp": |
| 460 case "double": | 478 case "double": |
| 461 case "DOMHighResTimeStamp": | 479 assert_equals(typeof value, "number"); |
| 480 assert_not_equals(value, Infinity); |
| 481 assert_not_equals(value, -Infinity); |
| 482 assert_not_equals(value, NaN); |
| 483 return; |
| 484 |
| 462 case "unrestricted float": | 485 case "unrestricted float": |
| 486 assert_equals(typeof value, "number"); |
| 487 assert_equals(value, fround(value), "unrestricted float rounded to 3
2-bit float should be itself"); |
| 488 return; |
| 489 |
| 463 case "unrestricted double": | 490 case "unrestricted double": |
| 464 // TODO: distinguish these cases | |
| 465 assert_equals(typeof value, "number"); | 491 assert_equals(typeof value, "number"); |
| 466 return; | 492 return; |
| 467 | 493 |
| 468 case "DOMString": | 494 case "DOMString": |
| 469 case "ByteString": | |
| 470 case "USVString": | |
| 471 // TODO: https://github.com/w3c/testharness.js/issues/92 | |
| 472 assert_equals(typeof value, "string"); | 495 assert_equals(typeof value, "string"); |
| 473 return; | 496 return; |
| 474 | 497 |
| 498 case "ByteString": |
| 499 assert_equals(typeof value, "string"); |
| 500 assert_regexp_match(value, /^[\x00-\x7F]*$/); |
| 501 return; |
| 502 |
| 503 case "USVString": |
| 504 assert_equals(typeof value, "string"); |
| 505 assert_regexp_match(value, /^([\x00-\ud7ff\ue000-\uffff]|[\ud800-\ud
bff][\udc00-\udfff])*$/); |
| 506 return; |
| 507 |
| 475 case "object": | 508 case "object": |
| 476 assert_true(typeof value == "object" || typeof value == "function",
"wrong type: not object or function"); | 509 assert_true(typeof value == "object" || typeof value == "function",
"wrong type: not object or function"); |
| 477 return; | 510 return; |
| 478 } | 511 } |
| 479 | 512 |
| 480 if (!(type in this.members)) | 513 if (!(type in this.members)) |
| 481 { | 514 { |
| 482 throw "Unrecognized type " + type; | 515 throw "Unrecognized type " + type; |
| 483 } | 516 } |
| 484 | 517 |
| (...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1763 /** An array of values produced by the "typedef" production. */ | 1796 /** An array of values produced by the "typedef" production. */ |
| 1764 this.values = obj.values; | 1797 this.values = obj.values; |
| 1765 | 1798 |
| 1766 } | 1799 } |
| 1767 //@} | 1800 //@} |
| 1768 | 1801 |
| 1769 IdlTypedef.prototype = Object.create(IdlObject.prototype); | 1802 IdlTypedef.prototype = Object.create(IdlObject.prototype); |
| 1770 | 1803 |
| 1771 }()); | 1804 }()); |
| 1772 // vim: set expandtab shiftwidth=4 tabstop=4 foldmarker=@{,@} foldmethod=marker: | 1805 // vim: set expandtab shiftwidth=4 tabstop=4 foldmarker=@{,@} foldmethod=marker: |
| OLD | NEW |