|
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-4.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-4"; |
|
25 var VERSION = "ECMA_1"; |
|
26 startTest(); |
|
27 writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); |
|
28 |
|
29 // the following expression should NOT be an error in JS. |
|
30 |
|
31 new TestCase( SECTION, |
|
32 "true ? MYVAR1 = 'PASSED' : MYVAR1 = 'FAILED'; MYVAR1", |
|
33 "PASSED", |
|
34 eval("true ? MYVAR1 = 'PASSED' : MYVAR1 = 'FAILED'; MYVAR1") ); |
|
35 |
|
36 test(); |
|
37 |