Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
6 /*
7 * Date: 01 May 2001
8 *
9 * SUMMARY: Regression test for Bugzilla bug 74474
10 *"switch() misbehaves with duplicated labels"
11 *
12 * See ECMA3 Section 12.11, "The switch Statement"
13 * See http://bugzilla.mozilla.org/show_bug.cgi?id=74474
14 */
15 //-----------------------------------------------------------------------------
16 var UBound = 0;
17 var BUGNUMBER = 74474;
18 var summary = 'Testing switch statements with duplicate labels';
19 var status = '';
20 var statusitems = [ ];
21 var actual = '';
22 var actualvalues = [ ];
23 var expect= '';
24 var expectedvalues = [ ];
27 status = 'Section A of test: the string literal "1" as a duplicate label';
28 actual = '';
29 switch ('1')
30 {
31 case '1':
32 actual += 'a';
33 case '1':
34 actual += 'b';
35 }
36 expect = 'ab';
37 addThis();
40 status = 'Section B of test: the numeric literal 1 as a duplicate label';
41 actual = '';
42 switch (1)
43 {
44 case 1:
45 actual += 'a';
46 case 1:
47 actual += 'b';
48 }
49 expect = 'ab';
50 addThis();
53 status = 'Section C of test: the numeric literal 1 as a duplicate label, via a function parameter';
54 tryThis(1);
55 function tryThis(x)
56 {
57 actual = '';
59 switch (x)
60 {
61 case x:
62 actual += 'a';
63 case x:
64 actual += 'b';
65 }
66 }
67 expect = 'ab';
68 addThis();
72 //---------------------------------------------------------------------------------
73 test();
74 //---------------------------------------------------------------------------------
78 function addThis()
79 {
80 statusitems[UBound] = status;
81 actualvalues[UBound] = actual;
82 expectedvalues[UBound] = expect;
83 UBound++;
84 }
87 function test()
88 {
89 enterFunc ('test');
90 printBugNumber(BUGNUMBER);
91 printStatus (summary);
93 for (var i = 0; i < UBound; i++)
94 {
95 reportCompare(expectedvalues[i], actualvalues[i], getStatus(i));
96 }
98 exitFunc ('test');
99 }
102 function getStatus(i)
103 {
104 return statusitems[i];
105 }