1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_5/Regress/regress-140974.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,106 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * 1.11 + * Date: 04 May 2002 1.12 + * SUMMARY: |if (false) {var x;} should create the variable x 1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=140974 1.14 + * 1.15 + */ 1.16 +//----------------------------------------------------------------------------- 1.17 +var UBound = 0; 1.18 +var BUGNUMBER = 140974; 1.19 +var TEST_PASSED = 'variable was created'; 1.20 +var TEST_FAILED = 'variable was NOT created'; 1.21 +var summary = '|if (false) {var x;}| should create the variable x'; 1.22 +var status = ''; 1.23 +var statusitems = []; 1.24 +var actual = ''; 1.25 +var actualvalues = []; 1.26 +var expect= ''; 1.27 +var expectedvalues = []; 1.28 + 1.29 + 1.30 +// -------------- THESE TWO SECTIONS TEST THE VARIABLE X -------------- 1.31 +status = inSection(1); 1.32 +actual = TEST_PASSED; 1.33 +try{ X;} catch(e) {actual = TEST_FAILED} 1.34 +expect = TEST_PASSED; 1.35 +addThis(); 1.36 + 1.37 +var X; 1.38 + 1.39 +status = inSection(2); 1.40 +actual = TEST_PASSED; 1.41 +try{ X;} catch(e) {actual = TEST_FAILED} 1.42 +expect = TEST_PASSED; 1.43 +addThis(); 1.44 + 1.45 + 1.46 + 1.47 +// -------------- THESE TWO SECTIONS TEST THE VARIABLE Y -------------- 1.48 +status = inSection(3); 1.49 +actual = TEST_PASSED; 1.50 +try{ Y;} catch(e) {actual = TEST_FAILED} 1.51 +expect = TEST_PASSED; 1.52 +addThis(); 1.53 + 1.54 +if (false) {var Y;}; 1.55 + 1.56 +status = inSection(4); 1.57 +actual = TEST_PASSED; 1.58 +try{ Y;} catch(e) {actual = TEST_FAILED} 1.59 +expect = TEST_PASSED; 1.60 +addThis(); 1.61 + 1.62 + 1.63 + 1.64 +// -------------- THESE TWO SECTIONS TEST THE VARIABLE Z -------------- 1.65 +status = inSection(5); 1.66 +actual = TEST_PASSED; 1.67 +try{ Z;} catch(e) {actual = TEST_FAILED} 1.68 +expect = TEST_PASSED; 1.69 +addThis(); 1.70 + 1.71 +if (false) { for (var Z; false;){} } 1.72 + 1.73 +status = inSection(6); 1.74 +actual = TEST_PASSED; 1.75 +try{ Z;} catch(e) {actual = TEST_FAILED} 1.76 +expect = TEST_PASSED; 1.77 +addThis(); 1.78 + 1.79 + 1.80 + 1.81 + 1.82 +//----------------------------------------------------------------------------- 1.83 +test(); 1.84 +//----------------------------------------------------------------------------- 1.85 + 1.86 + 1.87 + 1.88 +function addThis() 1.89 +{ 1.90 + statusitems[UBound] = status; 1.91 + actualvalues[UBound] = actual; 1.92 + expectedvalues[UBound] = expect; 1.93 + UBound++; 1.94 +} 1.95 + 1.96 + 1.97 +function test() 1.98 +{ 1.99 + enterFunc('test'); 1.100 + printBugNumber(BUGNUMBER); 1.101 + printStatus(summary); 1.102 + 1.103 + for (var i=0; i<UBound; i++) 1.104 + { 1.105 + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 1.106 + } 1.107 + 1.108 + exitFunc ('test'); 1.109 +}