|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 |
|
7 /** |
|
8 File Name: 11.12-2-n.js |
|
9 ECMA Section: 11.12 |
|
10 Description: |
|
11 |
|
12 The grammar for a ConditionalExpression in ECMAScript is a little bit |
|
13 different from that in C and Java, which each allow the second |
|
14 subexpression to be an Expression but restrict the third expression to |
|
15 be a ConditionalExpression. The motivation for this difference in |
|
16 ECMAScript is to allow an assignment expression to be governed by either |
|
17 arm of a conditional and to eliminate the confusing and fairly useless |
|
18 case of a comma expression as the center expression. |
|
19 |
|
20 Author: christine@netscape.com |
|
21 Date: 12 november 1997 |
|
22 */ |
|
23 |
|
24 var SECTION = "11.12-2-n"; |
|
25 var VERSION = "ECMA_1"; |
|
26 startTest(); |
|
27 writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); |
|
28 |
|
29 // the following expression should be an error in JS. |
|
30 |
|
31 DESCRIPTION = "var MYVAR = true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR"; |
|
32 EXPECTED = "error"; |
|
33 |
|
34 new TestCase( SECTION, |
|
35 "var MYVAR = true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR", |
|
36 "error", |
|
37 eval("var MYVAR = true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR") ); |
|
38 |
|
39 test(); |
|
40 |