~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/dowhile-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:          dowhile-002
 
3
 *  ECMA Section:
 
4
 *  Description:        do...while statements
 
5
 *
 
6
 *  Verify that code after a labeled break is not executed.  Verify that
 
7
 *  a labeled break breaks you out of the whole labeled block, and not
 
8
 *  just the current iteration statement.
 
9
 *
 
10
 *  Author:             christine@netscape.com
 
11
 *  Date:               11 August 1998
 
12
 */
 
13
    var SECTION = "dowhile-002";
 
14
    var VERSION = "ECMA_2";
 
15
    var TITLE   = "do...while with a labeled continue statement";
 
16
 
 
17
    startTest();
 
18
    writeHeaderToLog( SECTION + " "+ TITLE);
 
19
 
 
20
    var tc = 0;
 
21
    var testcases = new Array();
 
22
 
 
23
    LabeledContinue( 0, 1 );
 
24
    LabeledContinue( 1, 1 );
 
25
    LabeledContinue( -1, 1 );
 
26
    LabeledContinue( 5, 5 );
 
27
 
 
28
    test();
 
29
 
 
30
// The labeled statment contains statements after the labeled break.
 
31
// Verify that the statements after the break are not executed.
 
32
 
 
33
function LabeledContinue( limit, expect ) {
 
34
    i = 0;
 
35
    result1 = "pass";
 
36
    result2 = "pass";
 
37
 
 
38
    woohoo: {
 
39
        do {
 
40
            i++;
 
41
            if ( ! (i < limit) ) {
 
42
                break woohoo;
 
43
                result1 = "fail: evaluated statement after a labeled break";
 
44
            }
 
45
        } while ( true );
 
46
 
 
47
        result2 = "failed:  broke out of loop, but not out of labeled block";
 
48
    }
 
49
 
 
50
    testcases[tc++] = new TestCase(
 
51
        SECTION,
 
52
        "do while ( " + i +" < " + limit +" )",
 
53
        expect,
 
54
        i );
 
55
 
 
56
    testcases[tc++] = new TestCase(
 
57
        SECTION,
 
58
        "breaking out of a do... while loop",
 
59
        "pass",
 
60
        result1 );
 
61
 
 
62
 
 
63
    testcases[tc++] = new TestCase(
 
64
        SECTION,
 
65
        "breaking out of a labeled do...while loop",
 
66
        "pass",
 
67
        result2 );
 
68
}