~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/switch-002.js

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 *  File Name:          switch-002.js
 
3
 *  ECMA Section:
 
4
 *  Description:        The switch Statement
 
5
 *
 
6
 *  A simple switch test with no abrupt completions.
 
7
 *
 
8
 *  Author:             christine@netscape.com
 
9
 *  Date:               11 August 1998
 
10
 *
 
11
 */
 
12
    var SECTION = "switch-002";
 
13
    var VERSION = "ECMA_2";
 
14
    var TITLE   = "The switch statement";
 
15
 
 
16
    startTest();
 
17
    writeHeaderToLog( SECTION + " "+ TITLE);
 
18
 
 
19
    var tc = 0;
 
20
    var testcases = new Array();
 
21
 
 
22
    SwitchTest( 0, 6 );
 
23
    SwitchTest( 1, 4 );
 
24
    SwitchTest( 2, 56 );
 
25
    SwitchTest( 3, 48 );
 
26
    SwitchTest( 4, 64 );
 
27
    SwitchTest( true, 32 );
 
28
    SwitchTest( false, 32 );
 
29
    SwitchTest( null, 32 );
 
30
    SwitchTest( void 0, 32 );
 
31
    SwitchTest( "0", 32 );
 
32
 
 
33
    test();
 
34
 
 
35
    function SwitchTest( input, expect ) {
 
36
        var result = 0;
 
37
 
 
38
        switch ( input ) {
 
39
            case 0:
 
40
                result += 2;
 
41
            case 1:
 
42
                result += 4;
 
43
                break;
 
44
            case 2:
 
45
                result += 8;
 
46
            case 3:
 
47
                result += 16;
 
48
            default:
 
49
                result += 32;
 
50
                break;
 
51
            case 4:
 
52
                result += 64;
 
53
        }
 
54
 
 
55
        testcases[tc++] = new TestCase(
 
56
            SECTION,
 
57
            "switch with no breaks:  input is " + input,
 
58
            expect,
 
59
            result );
 
60
    }