js/src/tests/ecma/Expressions/11.12-3.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:3d7397e53b92
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-3.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-3";
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 "var MYVAR = true ? ('FAIL1', 'PASSED') : 'FAIL2'; MYVAR",
33 "PASSED",
34 eval("var MYVAR = true ? ('FAIL1', 'PASSED') : 'FAIL2'; MYVAR"));
35
36 test();
37

mercurial