js/src/tests/js1_2/statements/switch.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_2/statements/switch.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,96 @@
     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 +   Filename:     switch.js
    1.12 +   Description:  'Tests the switch statement'
    1.13 +
    1.14 +   http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696
    1.15 +
    1.16 +   Author:       Nick Lerissa
    1.17 +   Date:         March 19, 1998
    1.18 +*/
    1.19 +
    1.20 +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
    1.21 +var VERSION = 'no version';
    1.22 +var TITLE   = 'statements: switch';
    1.23 +var BUGNUMBER="323696";
    1.24 +
    1.25 +startTest();
    1.26 +writeHeaderToLog("Executing script: switch.js");
    1.27 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.28 +
    1.29 +
    1.30 +var var1 = "match string";
    1.31 +var match1 = false;
    1.32 +var match2 = false;
    1.33 +var match3 = false;
    1.34 +
    1.35 +switch (var1)
    1.36 +{
    1.37 +case "match string":
    1.38 +  match1 = true;
    1.39 +case "bad string 1":
    1.40 +  match2 = true;
    1.41 +  break;
    1.42 +case "bad string 2":
    1.43 +  match3 = true;
    1.44 +}
    1.45 +
    1.46 +new TestCase ( SECTION, 'switch statement',
    1.47 +	       true, match1);
    1.48 +
    1.49 +new TestCase ( SECTION, 'switch statement',
    1.50 +	       true, match2);
    1.51 +
    1.52 +new TestCase ( SECTION, 'switch statement',
    1.53 +	       false, match3);
    1.54 +
    1.55 +var var2 = 3;
    1.56 +
    1.57 +var match1 = false;
    1.58 +var match2 = false;
    1.59 +var match3 = false;
    1.60 +var match4 = false;
    1.61 +var match5 = false;
    1.62 +
    1.63 +switch (var2)
    1.64 +{
    1.65 +case 1:
    1.66 +/*	        switch (var1)
    1.67 +  {
    1.68 +  case "foo":
    1.69 +  match1 = true;
    1.70 +  break;
    1.71 +  case 3:
    1.72 +  match2 = true;
    1.73 +  break;
    1.74 +  }*/
    1.75 +  match3 = true;
    1.76 +  break;
    1.77 +case 2:
    1.78 +  match4 = true;
    1.79 +  break;
    1.80 +case 3:
    1.81 +  match5 = true;
    1.82 +  break;
    1.83 +}
    1.84 +new TestCase ( SECTION, 'switch statement',
    1.85 +	       false, match1);
    1.86 +
    1.87 +new TestCase ( SECTION, 'switch statement',
    1.88 +	       false, match2);
    1.89 +
    1.90 +new TestCase ( SECTION, 'switch statement',
    1.91 +	       false, match3);
    1.92 +
    1.93 +new TestCase ( SECTION, 'switch statement',
    1.94 +	       false, match4);
    1.95 +
    1.96 +new TestCase ( SECTION, 'switch statement',
    1.97 +	       true, match5);
    1.98 +
    1.99 +test();

mercurial