~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/while-003.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:          while-003
 
3
 *  ECMA Section:
 
4
 *  Description:        while statement
 
5
 *
 
6
 *  The while expression evaluates to true, Statement returns abrupt completion.
 
7
 *
 
8
 *  Author:             christine@netscape.com
 
9
 *  Date:               11 August 1998
 
10
 */
 
11
    var SECTION = "while-003";
 
12
    var VERSION = "ECMA_2";
 
13
    var TITLE   = "while statement";
 
14
 
 
15
    startTest();
 
16
    writeHeaderToLog( SECTION + " "+ TITLE);
 
17
 
 
18
    var tc = 0;
 
19
    var testcases = new Array();
 
20
 
 
21
    DoWhile( new DoWhileObject(
 
22
                "while expression is true",
 
23
                true,
 
24
                "result = \"pass\";" ));
 
25
 
 
26
    DoWhile( new DoWhileObject(
 
27
             "while expression is 1",
 
28
             1,
 
29
            "result = \"pass\";" ));
 
30
 
 
31
    DoWhile( new DoWhileObject(
 
32
             "while expression is new Boolean(false)",
 
33
             new Boolean(false),
 
34
            "result = \"pass\";" ));
 
35
 
 
36
    DoWhile( new DoWhileObject(
 
37
             "while expression is new Object()",
 
38
             new Object(),
 
39
            "result = \"pass\";" ));
 
40
 
 
41
    DoWhile( new DoWhileObject(
 
42
             "while expression is \"hi\"",
 
43
             "hi",
 
44
            "result = \"pass\";" ));
 
45
/*
 
46
    DoWhile( new DoWhileObject(
 
47
             "while expression has a continue in it",
 
48
             "true",
 
49
             "if ( i == void 0 ) i = 0; result=\"pass\"; if ( ++i == 1 ) {continue;} else {break;} result=\"fail\";"
 
50
             ));
 
51
*/
 
52
    test();
 
53
 
 
54
    function DoWhileObject( d, e, s ) {
 
55
        this.description = d;
 
56
        this.whileExpression = e;
 
57
        this.statements = s;
 
58
    }
 
59
 
 
60
    function DoWhile( object ) {
 
61
        result = "fail:  statements in while block were not evaluated";
 
62
 
 
63
        while ( expression = object.whileExpression ) {
 
64
            eval( object.statements );
 
65
            break;
 
66
        }
 
67
 
 
68
        // verify that the while expression was evaluated
 
69
 
 
70
        testcases[tc++] = new TestCase(
 
71
            SECTION,
 
72
            "verify that while expression was evaluated (should be "+
 
73
                object.whileExpression +")",
 
74
            "pass",
 
75
            (object.whileExpression == expression ||
 
76
               ( isNaN(object.whileExpression) && isNaN(expression) )
 
77
             ) ? "pass" : "fail" );
 
78
 
 
79
        testcases[tc++] = new TestCase(
 
80
            SECTION,
 
81
            object.description,
 
82
            "pass",
 
83
            result );
 
84
    }
 
 
b'\\ No newline at end of file'