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/
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.
11 * The Original Code is Mozilla Communicator client code, released March
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
24 ECMA Section: The if statement
27 The production IfStatement : if ( Expression ) Statement else Statement
28 is evaluated as follows:
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.
36 7.Evaluate the second Statement.
39 Author: christine@netscape.com
40 Date: 12 november 1997
43 var SECTION = "12.5-2";
44 var VERSION = "ECMA_1";
46 var TITLE = "The if statement" ;
48 writeHeaderToLog( SECTION + " "+ TITLE);
50 var testcases = new Array();
52 testcases[tc++] = new TestCase( SECTION,
53 "var MYVAR; if ( true ) MYVAR='PASSED'; MYVAR",
55 eval("var MYVAR; if ( true ) MYVAR='PASSED'; MYVAR") );
57 testcases[tc++] = new TestCase( SECTION,
58 "var MYVAR; if ( false ) MYVAR='FAILED'; MYVAR;",
60 eval("var MYVAR=\"PASSED\"; if ( false ) MYVAR='FAILED'; MYVAR;") );
62 testcases[tc++] = new TestCase( SECTION,
63 "var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; MYVAR",
65 eval("var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; MYVAR") );
67 testcases[tc++] = new TestCase( SECTION,
68 "var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; MYVAR",
70 eval("var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; MYVAR") );
72 testcases[tc++] = new TestCase( SECTION,
73 "var MYVAR; if ( 1 ) MYVAR='PASSED'; MYVAR",
75 eval("var MYVAR; if ( 1 ) MYVAR='PASSED'; MYVAR") );
77 testcases[tc++] = new TestCase( SECTION,
78 "var MYVAR; if ( 0 ) MYVAR='FAILED'; MYVAR;",
80 eval("var MYVAR=\"PASSED\"; if ( 0 ) MYVAR='FAILED'; MYVAR;") );
85 for ( tc=0; tc < testcases.length; tc++ ) {
86 testcases[tc].passed = writeTestCaseResult(
89 testcases[tc].description +" = "+
90 testcases[tc].actual );
92 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";