Debian Codegraph @

rhino/testsrc/tests/js1_2/statements/switch.js

raw symbols SCIP
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 gTestfile = 'switch.js';
7
8 /**
9 Filename: switch.js
10 Description: 'Tests the switch statement'
11
12 http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696
13
14 Author: Nick Lerissa
15 Date: March 19, 1998
16 */
17
18 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
19 var VERSION = 'no version';
20 var TITLE = 'statements: switch';
21 var BUGNUMBER="323696";
22
23 startTest();
24 writeHeaderToLog("Executing script: switch.js");
25 writeHeaderToLog( SECTION + " "+ TITLE);
26
27
28 var var1 = "match string";
29 var match1 = false;
30 var match2 = false;
31 var match3 = false;
32
33 switch (var1)
34 {
35 case "match string":
36 match1 = true;
37 case "bad string 1":
38 match2 = true;
39 break;
40 case "bad string 2":
41 match3 = true;
42 }
43
44 new TestCase ( SECTION, 'switch statement',
45 true, match1);
46
47 new TestCase ( SECTION, 'switch statement',
48 true, match2);
49
50 new TestCase ( SECTION, 'switch statement',
51 false, match3);
52
53 var var2 = 3;
54
55 var match1 = false;
56 var match2 = false;
57 var match3 = false;
58 var match4 = false;
59 var match5 = false;
60
61 switch (var2)
62 {
63 case 1:
64 /* switch (var1)
65 {
66 case "foo":
67 match1 = true;
68 break;
69 case 3:
70 match2 = true;
71 break;
72 }*/
73 match3 = true;
74 break;
75 case 2:
76 match4 = true;
77 break;
78 case 3:
79 match5 = true;
80 break;
81 }
82 new TestCase ( SECTION, 'switch statement',
83 false, match1);
84
85 new TestCase ( SECTION, 'switch statement',
86 false, match2);
87
88 new TestCase ( SECTION, 'switch statement',
89 false, match3);
90
91 new TestCase ( SECTION, 'switch statement',
92 false, match4);
93
94 new TestCase ( SECTION, 'switch statement',
95 true, match5);
96
97 test();