]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_2/Exceptions/expression-001.js
2 File Name: expression-001.js
3 Corresponds to: ecma/Expressions/11.12-2-n.js
7 The grammar for a ConditionalExpression in ECMAScript is a little bit
8 different from that in C and Java, which each allow the second
9 subexpression to be an Expression but restrict the third expression to
10 be a ConditionalExpression. The motivation for this difference in
11 ECMAScript is to allow an assignment expression to be governed by either
12 arm of a conditional and to eliminate the confusing and fairly useless
13 case of a comma expression as the center expression.
15 Author: christine@netscape.com
16 Date: 09 september 1998
18 var SECTION
= "expression-001";
19 var VERSION
= "JS1_4";
20 var TITLE
= "Conditional operator ( ? : )"
22 writeHeaderToLog( SECTION
+ " " + TITLE
);
25 var testcases
= new Array();
27 // the following expression should be an error in JS.
30 var exception
= "No exception was thrown";
33 eval("var MY_VAR = true ? \"EXPR1\", \"EXPR2\" : \"EXPR3\"");
36 exception
= e
.toString();
39 testcases
[tc
++] = new TestCase(
41 "comma expression in a conditional statement "+
42 "(threw "+ exception
+")",