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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma/Expressions/11.12-4.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,37 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +
    1.10 +/**
    1.11 +   File Name:          11.12-4.js
    1.12 +   ECMA Section:       11.12
    1.13 +   Description:
    1.14 +
    1.15 +   The grammar for a ConditionalExpression in ECMAScript is a little bit
    1.16 +   different from that in C and Java, which each allow the second
    1.17 +   subexpression to be an Expression but restrict the third expression to
    1.18 +   be a ConditionalExpression.  The motivation for this difference in
    1.19 +   ECMAScript is to allow an assignment expression to be governed by either
    1.20 +   arm of a conditional and to eliminate the confusing and fairly useless
    1.21 +   case of a comma expression as the center expression.
    1.22 +
    1.23 +   Author:             christine@netscape.com
    1.24 +   Date:               12 november 1997
    1.25 +*/
    1.26 +
    1.27 +var SECTION = "11.12-4";
    1.28 +var VERSION = "ECMA_1";
    1.29 +startTest();
    1.30 +writeHeaderToLog( SECTION + " Conditional operator ( ? : )");
    1.31 +
    1.32 +// the following expression should NOT be an error in JS.
    1.33 +
    1.34 +new TestCase( SECTION,
    1.35 +	      "true ? MYVAR1 = 'PASSED' : MYVAR1 = 'FAILED'; MYVAR1",
    1.36 +	      "PASSED",
    1.37 +	      eval("true ? MYVAR1 = 'PASSED' : MYVAR1 = 'FAILED'; MYVAR1") );
    1.38 +
    1.39 +test();
    1.40 +

mercurial