|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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: 29 April 2003 |
|
9 * SUMMARY: Testing merged if-clauses |
|
10 * |
|
11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=203841 |
|
12 * |
|
13 */ |
|
14 //----------------------------------------------------------------------------- |
|
15 var UBound = 0; |
|
16 var BUGNUMBER = 203841; |
|
17 var summary = 'Testing merged if-clauses'; |
|
18 var status = ''; |
|
19 var statusitems = []; |
|
20 var actual = ''; |
|
21 var actualvalues = []; |
|
22 var expect= ''; |
|
23 var expectedvalues = []; |
|
24 |
|
25 |
|
26 status = inSection(1); |
|
27 var a = 0; |
|
28 var b = 0; |
|
29 var c = 0; |
|
30 if (a == 5, b == 6) { c = 1; } |
|
31 actual = c; |
|
32 expect = 0; |
|
33 addThis(); |
|
34 |
|
35 status = inSection(2); |
|
36 a = 5; |
|
37 b = 0; |
|
38 c = 0; |
|
39 if (a == 5, b == 6) { c = 1; } |
|
40 actual = c; |
|
41 expect = 0; |
|
42 addThis(); |
|
43 |
|
44 status = inSection(3); |
|
45 a = 5; |
|
46 b = 6; |
|
47 c = 0; |
|
48 if (a == 5, b == 6) { c = 1; } |
|
49 actual = c; |
|
50 expect = 1; |
|
51 addThis(); |
|
52 |
|
53 /* |
|
54 * Now get tricky and use the = operator inside the if-clause |
|
55 */ |
|
56 status = inSection(4); |
|
57 a = 0; |
|
58 b = 6; |
|
59 c = 0; |
|
60 if (a = 5, b == 6) { c = 1; } |
|
61 actual = c; |
|
62 expect = 1; |
|
63 addThis(); |
|
64 |
|
65 status = inSection(5); |
|
66 c = 0; |
|
67 if (1, 1 == 6) { c = 1; } |
|
68 actual = c; |
|
69 expect = 0; |
|
70 addThis(); |
|
71 |
|
72 |
|
73 /* |
|
74 * Now some tests involving arrays |
|
75 */ |
|
76 var x=[]; |
|
77 |
|
78 status = inSection(6); // get element case |
|
79 c = 0; |
|
80 if (x[1==2]) { c = 1; } |
|
81 actual = c; |
|
82 expect = 0; |
|
83 addThis(); |
|
84 |
|
85 status = inSection(7); // set element case |
|
86 c = 0; |
|
87 if (x[1==2]=1) { c = 1; } |
|
88 actual = c; |
|
89 expect = 1; |
|
90 addThis(); |
|
91 |
|
92 status = inSection(8); // delete element case |
|
93 c = 0; |
|
94 if (delete x[1==2]) { c = 1; } |
|
95 actual = c; |
|
96 expect = 1; |
|
97 addThis(); |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 //----------------------------------------------------------------------------- |
|
103 test(); |
|
104 //----------------------------------------------------------------------------- |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 function addThis() |
|
110 { |
|
111 statusitems[UBound] = status; |
|
112 actualvalues[UBound] = actual; |
|
113 expectedvalues[UBound] = expect; |
|
114 UBound++; |
|
115 } |
|
116 |
|
117 |
|
118 function test() |
|
119 { |
|
120 enterFunc('test'); |
|
121 printBugNumber(BUGNUMBER); |
|
122 printStatus(summary); |
|
123 |
|
124 for (var i=0; i<UBound; i++) |
|
125 { |
|
126 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
|
127 } |
|
128 |
|
129 exitFunc ('test'); |
|
130 } |