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

« back to all changes in this revision

Viewing changes to Source/JavaScriptCore/tests/mozilla/ecma/Statements/12.5-1.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
/* The contents of this file are subject to the Netscape Public
 
2
 * License Version 1.1 (the "License"); you may not use this file
 
3
 * except in compliance with the License. You may obtain a copy of
 
4
 * the License at http://www.mozilla.org/NPL/
 
5
 *
 
6
 * Software distributed under the License is distributed on an "AS
 
7
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
8
 * implied. See the License for the specific language governing
 
9
 * rights and limitations under the License.
 
10
 *
 
11
 * The Original Code is Mozilla Communicator client code, released March
 
12
 * 31, 1998.
 
13
 *
 
14
 * The Initial Developer of the Original Code is Netscape Communications
 
15
 * Corporation. Portions created by Netscape are
 
16
 * Copyright (C) 1998 Netscape Communications Corporation. All
 
17
 * Rights Reserved.
 
18
 *
 
19
 * Contributor(s): 
 
20
 * 
 
21
 */
 
22
/**
 
23
    File Name:          12.5-1.js
 
24
    ECMA Section:       The if statement
 
25
    Description:
 
26
 
 
27
    The production IfStatement : if ( Expression ) Statement else Statement
 
28
    is evaluated as follows:
 
29
 
 
30
    1.Evaluate Expression.
 
31
    2.Call GetValue(Result(1)).
 
32
    3.Call ToBoolean(Result(2)).
 
33
    4.If Result(3) is false, go to step 7.
 
34
    5.Evaluate the first Statement.
 
35
    6.Return Result(5).
 
36
    7.Evaluate the second Statement.
 
37
    8.Return Result(7).
 
38
 
 
39
    Author:             christine@netscape.com
 
40
    Date:               12 november 1997
 
41
*/
 
42
 
 
43
 
 
44
    var SECTION = "12.5-1";
 
45
    var VERSION = "ECMA_1";
 
46
    startTest();
 
47
    var TITLE   = "The if statment";
 
48
 
 
49
    writeHeaderToLog( SECTION + " "+ TITLE);
 
50
 
 
51
 
 
52
    var testcases = new Array();
 
53
 
 
54
    testcases[tc++] = new TestCase(   SECTION,
 
55
                                    "var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';",
 
56
                                    "PASSED",
 
57
                                    eval("var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';") );
 
58
 
 
59
    testcases[tc++] = new TestCase(  SECTION,
 
60
                                    "var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';",
 
61
                                    "PASSED",
 
62
                                    eval("var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';") );
 
63
 
 
64
    testcases[tc++] = new TestCase(   SECTION,
 
65
                                    "var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';",
 
66
                                    "PASSED",
 
67
                                    eval("var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") );
 
68
 
 
69
    testcases[tc++] = new TestCase(  SECTION,
 
70
                                    "var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';",
 
71
                                    "PASSED",
 
72
                                    eval("var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") );
 
73
 
 
74
    testcases[tc++] = new TestCase(   SECTION,
 
75
                                    "var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';",
 
76
                                    "PASSED",
 
77
                                    eval("var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';") );
 
78
 
 
79
    testcases[tc++] = new TestCase(  SECTION,
 
80
                                    "var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';",
 
81
                                    "PASSED",
 
82
                                    eval("var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';") );
 
83
 
 
84
    test();
 
85
 
 
86
function test() {
 
87
    for ( tc=0; tc < testcases.length; tc++ ) {
 
88
        testcases[tc].passed = writeTestCaseResult(
 
89
                            testcases[tc].expect,
 
90
                            testcases[tc].actual,
 
91
                            testcases[tc].description +" = "+
 
92
                            testcases[tc].actual );
 
93
 
 
94
        testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
 
95
    }
 
96
    stopTest();
 
97
    return ( testcases );
 
98
}