1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * Any copyright is dedicated to the Public Domain.
4 * http://creativecommons.org/licenses/publicdomain/
13 delete(eval("actual = x"));
16 assertEq(actual, expect);
18 function g() { return 1 }
19 function h() { function g() { throw 2; } eval('g()')++; }
28 var lhs_prefix = ["", "++", "--", "", "", "[", "[y, " ];
29 var lhs_suffix = [" = 'no'", "", "", "++", "--", ", y] = [3, 4]", "] = [5, 6]"];
31 for (var i = 0; i < lhs_prefix.length; i++) {
33 eval(lhs_prefix[i] + "eval('x')" + lhs_suffix[i]);
37 * NB: JSOP_SETCALL throws only JSMSG_BAD_LEFTSIDE_OF_ASS, it does not
38 * specialize for ++ and -- as the compiler's error reporting does. See
39 * the next section's forked assertEq code.
41 assertEq(e.message, "invalid assignment left-hand side");
45 /* Destructuring desugars in the obvious way, so y must be 5 here. */
48 /* Now test for strict mode rejecting any SETCALL variant at compile time. */
49 for (var i = 0; i < lhs_prefix.length; i++) {
51 eval("(function () { 'use strict'; " + lhs_prefix[i] + "foo('x')" + lhs_suffix[i] + "; })");
54 if (/\+\+|\-\-/.test(lhs_prefix[i] || lhs_suffix[i]))
55 assertEq(e.message, "invalid increment/decrement operand");
57 assertEq(e.message, "invalid assignment left-hand side");
62 * The useless delete is optimized away, but the SETCALL must not be. It's not
63 * an early error, though.
66 function foo(arg) { fooArg = arg; }
68 eval("delete (foo('x') = 42);");
71 assertEq(e.message, "invalid assignment left-hand side");
73 assertEq(fooArg, 'x');
75 /* We extend ES5 by making delete of a call expression a strict mode error. */
77 eval("(function () { 'use strict'; delete foo('x'); })");
80 assertEq(e.message, "invalid delete operand");
83 reportCompare(0, 0, "ok");