]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/Statements/12.5-1.js
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
44 var SECTION
= "12.5-1";
45 var VERSION
= "ECMA_1";
47 var TITLE
= "The if statment";
49 writeHeaderToLog( SECTION
+ " "+ TITLE
);
52 var testcases
= new Array();
54 testcases
[tc
++] = new TestCase( SECTION
,
55 "var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';",
57 eval("var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';") );
59 testcases
[tc
++] = new TestCase( SECTION
,
60 "var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';",
62 eval("var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';") );
64 testcases
[tc
++] = new TestCase( SECTION
,
65 "var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';",
67 eval("var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") );
69 testcases
[tc
++] = new TestCase( SECTION
,
70 "var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';",
72 eval("var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") );
74 testcases
[tc
++] = new TestCase( SECTION
,
75 "var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';",
77 eval("var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';") );
79 testcases
[tc
++] = new TestCase( SECTION
,
80 "var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';",
82 eval("var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';") );
87 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
88 testcases
[tc
].passed
= writeTestCaseResult(
91 testcases
[tc
].description
+" = "+
92 testcases
[tc
].actual
);
94 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";