Changeset 202609 in webkit
- Timestamp:
- Jun 28, 2016 9:17:36 PM (8 years ago)
- Location:
- trunk/LayoutTests
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r202599 r202609 1 2016-06-28 David Kilzer <ddkilzer@apple.com> 2 3 Enhance shouldNotThrow()/shouldThrow() to accept functions and a descriptive message 4 <https://webkit.org/b/159232> 5 6 Reviewed by Brent Fulgham. 7 8 Based on a Blink change (patch by <hongchan@chromium.org>): 9 <https://src.chromium.org/viewvc/blink?view=revision&revision=192204> 10 11 Currently, shouldNotThrow() and shouldThrow() take the following 12 arguments: 13 14 shouldNotThrow(evalString) 15 shouldThrow(evalString, expectedExceptionString) 16 17 The challenges with this design are: 18 19 1) The 'evalString' must capture every variable that it 20 needs, which means the code can be long, and concatenated 21 into a single line. It would be really nice to be able 22 to use an (anonymous) function to capture variables 23 instead. 24 2) The 'evalString' is literally printed out in the test 25 results, which isn't always the most descriptive. A 26 descriptive message would make it clearer what failed. 27 3) When changing a shouldThrow() into a shouldNotThrow() 28 or copying/pasting code, it's possible to forget to 29 remove 'expectedExceptionString' from the function call. 30 31 This patch changes the methods to take the following arguments: 32 33 shouldNotThrow(evalString|function [, message]) 34 shouldThrow(evalString|function, expectedExceptionString [, message]) 35 36 If 'function' is passed in, then it is invoked instead of 37 evaluated, and 'message' replaces the literal code in the 38 pass/fail output. 39 40 This patch also adds the global 'didFailSomeTests' variable to 41 js-test.js, which already exists in js-test-pre.js. This was 42 added to js-test-pre.js in r153203 by Oliver Hunt to 43 LayoutTests/fast/js/resources/js-test-pre.js. 44 45 * fast/canvas/webgl/canvas-supports-context-expected.txt: 46 * fast/canvas/webgl/gl-bind-attrib-location-before-compile-test-expected.txt: 47 * fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt: 48 * fast/dom/getElementsByClassName/ASCII-case-insensitive-expected.txt: 49 * storage/indexeddb/cursor-basics-expected.txt: 50 * storage/indexeddb/cursor-basics-private-expected.txt: 51 - Update expected results to include "Some tests fail." since 52 some subtests actually do fail during these tests. 53 54 * fast/css/parsing-css-lang.html: 55 * fast/css/parsing-css-matches-1.html: 56 * fast/css/parsing-css-matches-2.html: 57 * fast/css/parsing-css-matches-3.html: 58 * fast/css/parsing-css-matches-4.html: 59 * fast/css/parsing-css-not-1.html: 60 * fast/css/parsing-css-not-2.html: 61 * fast/css/parsing-css-not-3.html: 62 * fast/css/parsing-css-not-4.html: 63 * fast/css/parsing-css-nth-child-of-1.html: 64 * fast/css/parsing-css-nth-child-of-2.html: 65 * fast/css/parsing-css-nth-last-child-of-1.html: 66 * fast/css/parsing-css-nth-last-child-of-2.html: 67 * js/script-tests/arrowfunction-supercall.js: 68 - Remove expectedExceptionString from shouldNotThrow() calls 69 after they were changed from shouldThrow() calls. 70 71 * resources/js-test-pre.js: 72 (shouldNotThrow): Change to invoke first argument if it is a 73 function, else use eval() as before. Use second argurment in 74 place of first argument (if set) when printing results. NOTE: 75 Care was taken not to add any lines of code to prevent changes 76 to test results. 77 (shouldThrow): Ditto. Reformat code. 78 * resources/js-test.js: Declare 'didFailSomeTests'. 79 (testFailed): Set 'didFailSomeTests' to true when a test fails. 80 (shouldNotThrow): Same changes as js-test-pre.js. 81 (shouldThrow): Ditto. 82 (isSuccessfullyParsed): Output a message if 'didFailSomeTests' 83 is true. 84 1 85 2016-06-28 Jiewen Tan <jiewen_tan@apple.com> 2 86 -
trunk/LayoutTests/fast/canvas/webgl/canvas-supports-context-expected.txt
r155137 r202609 116 116 117 117 PASS successfullyParsed is true 118 Some tests failed. 118 119 119 120 TEST COMPLETE -
trunk/LayoutTests/fast/canvas/webgl/gl-bind-attrib-location-before-compile-test-expected.txt
r168112 r202609 24 24 25 25 PASS successfullyParsed is true 26 Some tests failed. 26 27 27 28 TEST COMPLETE -
trunk/LayoutTests/fast/css-grid-layout/grid-element-auto-repeat-get-set-expected.txt
r201399 r202609 58 58 PASS window.getComputedStyle(element, '').getPropertyValue('grid-template-columns') is "none" 59 59 PASS successfullyParsed is true 60 Some tests failed. 60 61 61 62 TEST COMPLETE -
trunk/LayoutTests/fast/css/parsing-css-lang.html
r180558 r202609 12 12 13 13 function testValidLanguageRange(languageRangeString, expectedSerializedLanguageRange) { 14 shouldNotThrow('document.querySelector(\':lang(' + languageRangeString.replace(/\\/g, '\\\\') + ')\')' , '"Error: SyntaxError: DOM Exception 12"');14 shouldNotThrow('document.querySelector(\':lang(' + languageRangeString.replace(/\\/g, '\\\\') + ')\')'); 15 15 16 16 var styleContainer = document.getElementById('style-container'); -
trunk/LayoutTests/fast/css/parsing-css-matches-1.html
r177313 r202609 12 12 13 13 function testValidSelector(selectorString, expectedSerializedSelector) { 14 shouldNotThrow('document.querySelector(":matches(' + selectorString.replace(/\\/g, '\\\\') + ')")' , '"Error: SyntaxError: DOM Exception 12"');14 shouldNotThrow('document.querySelector(":matches(' + selectorString.replace(/\\/g, '\\\\') + ')")'); 15 15 16 16 var styleContainer = document.getElementById('style-container'); -
trunk/LayoutTests/fast/css/parsing-css-matches-2.html
r177313 r202609 12 12 13 13 function testValidSelector(selectorString, expectedSerializedSelector) { 14 shouldNotThrow('document.querySelector(":matches(' + selectorString.replace(/\\/g, '\\\\') + ')")' , '"Error: SyntaxError: DOM Exception 12"');14 shouldNotThrow('document.querySelector(":matches(' + selectorString.replace(/\\/g, '\\\\') + ')")'); 15 15 16 16 var styleContainer = document.getElementById('style-container'); -
trunk/LayoutTests/fast/css/parsing-css-matches-3.html
r174259 r202609 12 12 13 13 function testValidSelector(selectorString, expectedSerializedSelector) { 14 shouldNotThrow('document.querySelector(":matches(' + selectorString.replace(/\\/g, '\\\\') + ')")' , '"Error: SyntaxError: DOM Exception 12"');14 shouldNotThrow('document.querySelector(":matches(' + selectorString.replace(/\\/g, '\\\\') + ')")'); 15 15 16 16 var styleContainer = document.getElementById('style-container'); -
trunk/LayoutTests/fast/css/parsing-css-matches-4.html
r177313 r202609 12 12 13 13 function testValidSelector(selectorString, expectedSerializedSelector) { 14 shouldNotThrow('document.querySelector(":matches(' + selectorString.replace(/\\/g, '\\\\') + ')")' , '"Error: SyntaxError: DOM Exception 12"');14 shouldNotThrow('document.querySelector(":matches(' + selectorString.replace(/\\/g, '\\\\') + ')")'); 15 15 16 16 var styleContainer = document.getElementById('style-container'); -
trunk/LayoutTests/fast/css/parsing-css-not-1.html
r177313 r202609 12 12 13 13 function testValidSelector(selectorString, expectedSerializedSelector) { 14 shouldNotThrow('document.querySelector(":not(' + selectorString.replace(/\\/g, '\\\\') + ')")' , '"Error: SyntaxError: DOM Exception 12"');14 shouldNotThrow('document.querySelector(":not(' + selectorString.replace(/\\/g, '\\\\') + ')")'); 15 15 16 16 var styleContainer = document.getElementById('style-container'); -
trunk/LayoutTests/fast/css/parsing-css-not-2.html
r177313 r202609 12 12 13 13 function testValidSelector(selectorString, expectedSerializedSelector) { 14 shouldNotThrow('document.querySelector(":not(' + selectorString.replace(/\\/g, '\\\\') + ')")' , '"Error: SyntaxError: DOM Exception 12"');14 shouldNotThrow('document.querySelector(":not(' + selectorString.replace(/\\/g, '\\\\') + ')")'); 15 15 16 16 var styleContainer = document.getElementById('style-container'); -
trunk/LayoutTests/fast/css/parsing-css-not-3.html
r174535 r202609 12 12 13 13 function testValidSelector(selectorString, expectedSerializedSelector) { 14 shouldNotThrow('document.querySelector(":not(' + selectorString.replace(/\\/g, '\\\\') + ')")' , '"Error: SyntaxError: DOM Exception 12"');14 shouldNotThrow('document.querySelector(":not(' + selectorString.replace(/\\/g, '\\\\') + ')")'); 15 15 16 16 var styleContainer = document.getElementById('style-container'); -
trunk/LayoutTests/fast/css/parsing-css-not-4.html
r177313 r202609 12 12 13 13 function testValidSelector(selectorString, expectedSerializedSelector) { 14 shouldNotThrow('document.querySelector(":not(' + selectorString.replace(/\\/g, '\\\\') + ')")' , '"Error: SyntaxError: DOM Exception 12"');14 shouldNotThrow('document.querySelector(":not(' + selectorString.replace(/\\/g, '\\\\') + ')")'); 15 15 16 16 var styleContainer = document.getElementById('style-container'); -
trunk/LayoutTests/fast/css/parsing-css-nth-child-of-1.html
r173856 r202609 12 12 13 13 function testValidSelector(selectorString, expectedSerializedSelector) { 14 shouldNotThrow('document.querySelector(":nth-child(' + selectorString.replace(/\\/g, '\\\\') + ')")' , '"Error: SyntaxError: DOM Exception 12"');14 shouldNotThrow('document.querySelector(":nth-child(' + selectorString.replace(/\\/g, '\\\\') + ')")'); 15 15 16 16 var styleContainer = document.getElementById('style-container'); -
trunk/LayoutTests/fast/css/parsing-css-nth-child-of-2.html
r173856 r202609 12 12 13 13 function testValidSelector(selectorString, expectedSerializedSelector) { 14 shouldNotThrow('document.querySelector(":nth-child(' + selectorString.replace(/\\/g, '\\\\') + ')")' , '"Error: SyntaxError: DOM Exception 12"');14 shouldNotThrow('document.querySelector(":nth-child(' + selectorString.replace(/\\/g, '\\\\') + ')")'); 15 15 16 16 var styleContainer = document.getElementById('style-container'); -
trunk/LayoutTests/fast/css/parsing-css-nth-last-child-of-1.html
r175848 r202609 12 12 13 13 function testValidSelector(selectorString, expectedSerializedSelector) { 14 shouldNotThrow('document.querySelector(":nth-last-child(' + selectorString.replace(/\\/g, '\\\\') + ')")' , '"Error: SyntaxError: DOM Exception 12"');14 shouldNotThrow('document.querySelector(":nth-last-child(' + selectorString.replace(/\\/g, '\\\\') + ')")'); 15 15 16 16 var styleContainer = document.getElementById('style-container'); -
trunk/LayoutTests/fast/css/parsing-css-nth-last-child-of-2.html
r175848 r202609 12 12 13 13 function testValidSelector(selectorString, expectedSerializedSelector) { 14 shouldNotThrow('document.querySelector(":nth-last-child(' + selectorString.replace(/\\/g, '\\\\') + ')")' , '"Error: SyntaxError: DOM Exception 12"');14 shouldNotThrow('document.querySelector(":nth-last-child(' + selectorString.replace(/\\/g, '\\\\') + ')")'); 15 15 16 16 var styleContainer = document.getElementById('style-container'); -
trunk/LayoutTests/fast/dom/getElementsByClassName/ASCII-case-insensitive-expected.txt
r169358 r202609 4 4 PASS getByClassName('Ä') is "Ä" 5 5 PASS successfullyParsed is true 6 Some tests failed. 6 7 7 8 TEST COMPLETE -
trunk/LayoutTests/js/script-tests/arrowfunction-supercall.js
r200824 r202609 152 152 shouldThrow('(new class extends A { constructor() { ((a = this)=>{ return a; })() } })', '"ReferenceError: Cannot access uninitialized variable."'); 153 153 shouldThrow('(new class extends A { constructor() { ((a = this, b=super())=>{ return a; })() } })', '"ReferenceError: Cannot access uninitialized variable."'); 154 shouldNotThrow('(new class extends A { constructor() { ((a = new.target)=>{ return a; })(); super(); } })' , '"ReferenceError: Cannot access uninitialized variable."');155 shouldNotThrow('(new class extends A { constructor() { ((a = new.target, b=super())=>{ return a; })() } })' , '"ReferenceError: Cannot access uninitialized variable."');154 shouldNotThrow('(new class extends A { constructor() { ((a = new.target)=>{ return a; })(); super(); } })'); 155 shouldNotThrow('(new class extends A { constructor() { ((a = new.target, b=super())=>{ return a; })() } })'); 156 156 157 157 var successfullyParsed = true; -
trunk/LayoutTests/resources/js-test-pre.js
r178756 r202609 584 584 } 585 585 586 function shouldNotThrow(_a ) {586 function shouldNotThrow(_a, _message) { 587 587 try { 588 eval(_a);589 testPassed( _a+ " did not throw exception.");588 typeof _a == "function" ? _a() : eval(_a); 589 testPassed((_message ? _message : _a) + " did not throw exception."); 590 590 } catch (e) { 591 testFailed(_a + " should not throw exception. Threw exception " + e + "."); 592 } 593 } 594 595 function shouldThrow(_a, _e) 596 { 597 var exception; 598 var _av; 599 try { 600 _av = eval(_a); 601 } catch (e) { 602 exception = e; 603 } 604 605 var _ev; 606 if (_e) 607 _ev = eval(_e); 608 609 if (exception) { 610 if (typeof _e == "undefined" || exception == _ev) 611 testPassed(_a + " threw exception " + exception + "."); 591 testFailed((_message ? _message : _a) + " should not throw exception. Threw exception " + e + "."); 592 } 593 } 594 595 function shouldThrow(_a, _e, _message) 596 { 597 var _exception; 598 var _av; 599 try { 600 _av = typeof _a == "function" ? _a() : eval(_a); 601 } catch (e) { 602 _exception = e; 603 } 604 605 var _ev; 606 if (_e) 607 _ev = eval(_e); 608 609 if (_exception) { 610 if (typeof _e == "undefined" || _exception == _ev) 611 testPassed((_message ? _message : _a) + " threw exception " + _exception + "."); 612 else 613 testFailed((_message ? _message : _a) + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Threw exception " + _exception + "."); 614 } else if (typeof _av == "undefined") 615 testFailed((_message ? _message : _a) + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was undefined."); 612 616 else 613 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Threw exception " + exception + "."); 614 } else if (typeof _av == "undefined") 615 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was undefined."); 616 else 617 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was " + _av + "."); 617 testFailed((_message ? _message : _a) + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was " + _av + "."); 618 618 } 619 619 -
trunk/LayoutTests/resources/js-test.js
r196137 r202609 11 11 } 12 12 13 var description, debug, successfullyParsed; 13 var description, debug, didFailSomeTests, successfullyParsed; 14 15 didFailSomeTests = false; 14 16 15 17 var expectingError; // set by shouldHaveError() … … 154 156 function testFailed(msg) 155 157 { 158 didFailSomeTests = true; 156 159 debug('<span><span class="fail">FAIL</span> ' + escapeHTML(msg) + '</span>'); 157 160 } … … 560 563 } 561 564 562 function shouldNotThrow(_a ) {565 function shouldNotThrow(_a, _message) { 563 566 try { 564 eval(_a);565 testPassed( _a+ " did not throw exception.");567 typeof _a == "function" ? _a() : eval(_a); 568 testPassed((_message ? _message : _a) + " did not throw exception."); 566 569 } catch (e) { 567 testFailed(_a + " should not throw exception. Threw exception " + e + "."); 568 } 569 } 570 571 function shouldThrow(_a, _e) 572 { 573 var _exception; 574 var _av; 575 try { 576 _av = eval(_a); 577 } catch (e) { 578 _exception = e; 579 } 580 581 var _ev; 582 if (_e) 583 _ev = eval(_e); 584 585 if (_exception) { 586 if (typeof _e == "undefined" || _exception == _ev) 587 testPassed(_a + " threw exception " + _exception + "."); 570 testFailed((_message ? _message : _a) + " should not throw exception. Threw exception " + e + "."); 571 } 572 } 573 574 function shouldThrow(_a, _e, _message) 575 { 576 var _exception; 577 var _av; 578 try { 579 _av = typeof _a == "function" ? _a() : eval(_a); 580 } catch (e) { 581 _exception = e; 582 } 583 584 var _ev; 585 if (_e) 586 _ev = eval(_e); 587 588 if (_exception) { 589 if (typeof _e == "undefined" || _exception == _ev) 590 testPassed((_message ? _message : _a) + " threw exception " + _exception + "."); 591 else 592 testFailed((_message ? _message : _a) + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Threw exception " + _exception + "."); 593 } else if (typeof _av == "undefined") 594 testFailed((_message ? _message : _a) + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was undefined."); 588 595 else 589 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Threw exception " + _exception + "."); 590 } else if (typeof _av == "undefined") 591 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was undefined."); 592 else 593 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was " + _av + "."); 596 testFailed((_message ? _message : _a) + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was " + _av + "."); 594 597 } 595 598 … … 692 695 successfullyParsed = !unexpectedErrorMessage; 693 696 shouldBeTrue("successfullyParsed"); 697 if (didFailSomeTests) 698 debug("Some tests failed."); 694 699 debug('<br /><span class="pass">TEST COMPLETE</span>'); 695 700 } -
trunk/LayoutTests/storage/indexeddb/cursor-basics-expected.txt
r195181 r202609 83 83 PASS 'value' in cursor is false 84 84 PASS successfullyParsed is true 85 Some tests failed. 85 86 86 87 TEST COMPLETE -
trunk/LayoutTests/storage/indexeddb/cursor-basics-private-expected.txt
r195247 r202609 83 83 PASS 'value' in cursor is false 84 84 PASS successfullyParsed is true 85 Some tests failed. 85 86 86 87 TEST COMPLETE
Note: See TracChangeset
for help on using the changeset viewer.