js/src/tests/js1_8/regress/regress-499524.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 -*- */
     3 /*
     4  * Any copyright is dedicated to the Public Domain.
     5  * http://creativecommons.org/licenses/publicdomain/
     6  */
     8 function isSyntaxError(code) {
     9   try {
    10     eval(code);
    11     return false;
    12   } catch (exception) {
    13     if (SyntaxError.prototype.isPrototypeOf(exception))
    14       return true;
    15     throw exception;
    16   };
    17 };
    19 /* 
    20  * Duplicate parameter names must be tolerated (as per ES3), unless
    21  * the parameter list uses destructuring, in which case we claim the
    22  * user has opted in to a modicum of sanity, and we forbid duplicate
    23  * parameter names.
    24  */
    25 assertEq(isSyntaxError("function f(x,x){}"),                false);
    27 assertEq(isSyntaxError("function f(x,[x]){})"),             true);
    28 assertEq(isSyntaxError("function f(x,{y:x}){})"),           true);
    29 assertEq(isSyntaxError("function f(x,{x}){})"),             true);
    31 assertEq(isSyntaxError("function f([x],x){})"),             true);
    32 assertEq(isSyntaxError("function f({y:x},x){})"),           true);
    33 assertEq(isSyntaxError("function f({x},x){})"),             true);
    35 assertEq(isSyntaxError("function f([x,x]){}"),              true);
    36 assertEq(isSyntaxError("function f({x,x}){}"),              true);
    37 assertEq(isSyntaxError("function f({y:x,z:x}){}"),          true);
    39 assertEq(isSyntaxError("function f(x,x,[y]){}"),            true);
    40 assertEq(isSyntaxError("function f(x,x,{y}){}"),            true);
    41 assertEq(isSyntaxError("function f([y],x,x){}"),            true);
    42 assertEq(isSyntaxError("function f({y},x,x){}"),            true);
    44 assertEq(isSyntaxError("function f(a,b,c,d,e,f,g,h,b,[y]){}"),  true);
    45 assertEq(isSyntaxError("function f([y],a,b,c,d,e,f,g,h,a){}"),  true);
    46 assertEq(isSyntaxError("function f([a],b,c,d,e,f,g,h,i,a){}"),  true);
    47 assertEq(isSyntaxError("function f(a,b,c,d,e,f,g,h,i,[a]){}"),  true);
    48 assertEq(isSyntaxError("function f(a,b,c,d,e,f,g,h,i,[a]){}"),  true);
    50 reportCompare(true, true);

mercurial