~ubuntu-branches/ubuntu/saucy/mozjs17/saucy

« back to all changes in this revision

Viewing changes to js/src/tests/js1_2/statements/switch.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

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