js/src/tests/ecma/Expressions/11.12-2-n.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     7 /**
     8    File Name:          11.12-2-n.js
     9    ECMA Section:       11.12
    10    Description:
    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.
    20    Author:             christine@netscape.com
    21    Date:               12 november 1997
    22 */
    24 var SECTION = "11.12-2-n";
    25 var VERSION = "ECMA_1";
    26 startTest();
    27 writeHeaderToLog( SECTION + " Conditional operator ( ? : )");
    29 // the following expression should be an error in JS.
    31 DESCRIPTION = "var MYVAR =  true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR";
    32 EXPECTED = "error";
    34 new TestCase( SECTION,
    35               "var MYVAR =  true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR",
    36               "error",
    37               eval("var MYVAR =  true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR") );
    39 test();

mercurial