1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_5/Regress/regress-203841.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,130 @@ 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: 29 April 2003 1.12 + * SUMMARY: Testing merged if-clauses 1.13 + * 1.14 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=203841 1.15 + * 1.16 + */ 1.17 +//----------------------------------------------------------------------------- 1.18 +var UBound = 0; 1.19 +var BUGNUMBER = 203841; 1.20 +var summary = 'Testing merged if-clauses'; 1.21 +var status = ''; 1.22 +var statusitems = []; 1.23 +var actual = ''; 1.24 +var actualvalues = []; 1.25 +var expect= ''; 1.26 +var expectedvalues = []; 1.27 + 1.28 + 1.29 +status = inSection(1); 1.30 +var a = 0; 1.31 +var b = 0; 1.32 +var c = 0; 1.33 +if (a == 5, b == 6) { c = 1; } 1.34 +actual = c; 1.35 +expect = 0; 1.36 +addThis(); 1.37 + 1.38 +status = inSection(2); 1.39 +a = 5; 1.40 +b = 0; 1.41 +c = 0; 1.42 +if (a == 5, b == 6) { c = 1; } 1.43 +actual = c; 1.44 +expect = 0; 1.45 +addThis(); 1.46 + 1.47 +status = inSection(3); 1.48 +a = 5; 1.49 +b = 6; 1.50 +c = 0; 1.51 +if (a == 5, b == 6) { c = 1; } 1.52 +actual = c; 1.53 +expect = 1; 1.54 +addThis(); 1.55 + 1.56 +/* 1.57 + * Now get tricky and use the = operator inside the if-clause 1.58 + */ 1.59 +status = inSection(4); 1.60 +a = 0; 1.61 +b = 6; 1.62 +c = 0; 1.63 +if (a = 5, b == 6) { c = 1; } 1.64 +actual = c; 1.65 +expect = 1; 1.66 +addThis(); 1.67 + 1.68 +status = inSection(5); 1.69 +c = 0; 1.70 +if (1, 1 == 6) { c = 1; } 1.71 +actual = c; 1.72 +expect = 0; 1.73 +addThis(); 1.74 + 1.75 + 1.76 +/* 1.77 + * Now some tests involving arrays 1.78 + */ 1.79 +var x=[]; 1.80 + 1.81 +status = inSection(6); // get element case 1.82 +c = 0; 1.83 +if (x[1==2]) { c = 1; } 1.84 +actual = c; 1.85 +expect = 0; 1.86 +addThis(); 1.87 + 1.88 +status = inSection(7); // set element case 1.89 +c = 0; 1.90 +if (x[1==2]=1) { c = 1; } 1.91 +actual = c; 1.92 +expect = 1; 1.93 +addThis(); 1.94 + 1.95 +status = inSection(8); // delete element case 1.96 +c = 0; 1.97 +if (delete x[1==2]) { c = 1; } 1.98 +actual = c; 1.99 +expect = 1; 1.100 +addThis(); 1.101 + 1.102 + 1.103 + 1.104 + 1.105 +//----------------------------------------------------------------------------- 1.106 +test(); 1.107 +//----------------------------------------------------------------------------- 1.108 + 1.109 + 1.110 + 1.111 + 1.112 +function addThis() 1.113 +{ 1.114 + statusitems[UBound] = status; 1.115 + actualvalues[UBound] = actual; 1.116 + expectedvalues[UBound] = expect; 1.117 + UBound++; 1.118 +} 1.119 + 1.120 + 1.121 +function test() 1.122 +{ 1.123 + enterFunc('test'); 1.124 + printBugNumber(BUGNUMBER); 1.125 + printStatus(summary); 1.126 + 1.127 + for (var i=0; i<UBound; i++) 1.128 + { 1.129 + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 1.130 + } 1.131 + 1.132 + exitFunc ('test'); 1.133 +}