regress-140974.js (2326B)
1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 /* 7 * 8 * Date: 04 May 2002 9 * SUMMARY: |if (false) {var x;} should create the variable x 10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=140974 11 * 12 */ 13 //----------------------------------------------------------------------------- 14 var UBound = 0; 15 var BUGNUMBER = 140974; 16 var TEST_PASSED = 'variable was created'; 17 var TEST_FAILED = 'variable was NOT created'; 18 var summary = '|if (false) {var x;}| should create the variable x'; 19 var status = ''; 20 var statusitems = []; 21 var actual = ''; 22 var actualvalues = []; 23 var expect= ''; 24 var expectedvalues = []; 25 26 27 // -------------- THESE TWO SECTIONS TEST THE VARIABLE X -------------- 28 status = inSection(1); 29 actual = TEST_PASSED; 30 try{ X;} catch(e) {actual = TEST_FAILED} 31 expect = TEST_PASSED; 32 addThis(); 33 34 var X; 35 36 status = inSection(2); 37 actual = TEST_PASSED; 38 try{ X;} catch(e) {actual = TEST_FAILED} 39 expect = TEST_PASSED; 40 addThis(); 41 42 43 44 // -------------- THESE TWO SECTIONS TEST THE VARIABLE Y -------------- 45 status = inSection(3); 46 actual = TEST_PASSED; 47 try{ Y;} catch(e) {actual = TEST_FAILED} 48 expect = TEST_PASSED; 49 addThis(); 50 51 if (false) {var Y;}; 52 53 status = inSection(4); 54 actual = TEST_PASSED; 55 try{ Y;} catch(e) {actual = TEST_FAILED} 56 expect = TEST_PASSED; 57 addThis(); 58 59 60 61 // -------------- THESE TWO SECTIONS TEST THE VARIABLE Z -------------- 62 status = inSection(5); 63 actual = TEST_PASSED; 64 try{ Z;} catch(e) {actual = TEST_FAILED} 65 expect = TEST_PASSED; 66 addThis(); 67 68 if (false) { for (var Z; false;){} } 69 70 status = inSection(6); 71 actual = TEST_PASSED; 72 try{ Z;} catch(e) {actual = TEST_FAILED} 73 expect = TEST_PASSED; 74 addThis(); 75 76 77 78 79 //----------------------------------------------------------------------------- 80 test(); 81 //----------------------------------------------------------------------------- 82 83 84 85 function addThis() 86 { 87 statusitems[UBound] = status; 88 actualvalues[UBound] = actual; 89 expectedvalues[UBound] = expect; 90 UBound++; 91 } 92 93 94 function test() 95 { 96 printBugNumber(BUGNUMBER); 97 printStatus(summary); 98 99 for (var i=0; i<UBound; i++) 100 { 101 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 102 } 103 }