Remove SM staging tests wrongly testing invalid LHS

It is an early error if the LHS of:
- ForOfStatement
- UpdateExpression
- AssignmentExpression
- DestructuringAssignmentTarget
is not simple (i.e. not a function call).
This commit is contained in:
Nicolò Ribaudo 2024-12-13 11:44:05 +01:00 committed by Ms2ger
parent e8c771e9df
commit 43c45f3b37
3 changed files with 1 additions and 177 deletions

View File

@ -1,95 +0,0 @@
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
*/
/*---
includes: [sm/non262.js, sm/non262-shell.js, sm/non262-extensions-shell.js]
flags:
- noStrict
description: |
pending
esid: pending
---*/
//-----------------------------------------------------------------------------
var BUGNUMBER = 609756;
var summary =
"Perform ToNumber on the result of the |fun()| in |fun()++| before " +
"throwing";
print(BUGNUMBER + ": " + summary);
/**************
* BEGIN TEST *
**************/
var hadSideEffect;
function f()
{
return { valueOf: function() { hadSideEffect = true; return 0; } };
}
hadSideEffect = false;
assertThrowsInstanceOf(function() { f()++; }, ReferenceError);
assert.sameValue(hadSideEffect, true);
hadSideEffect = false;
assertThrowsInstanceOf(function() {
for (var i = 0; i < 20; i++)
{
if (i > 18)
f()++;
}
}, ReferenceError);
assert.sameValue(hadSideEffect, true);
hadSideEffect = false;
assertThrowsInstanceOf(function() { f()--; }, ReferenceError);
assert.sameValue(hadSideEffect, true);
hadSideEffect = false;
assertThrowsInstanceOf(function() {
for (var i = 0; i < 20; i++)
{
if (i > 18)
f()--;
}
}, ReferenceError);
assert.sameValue(hadSideEffect, true);
hadSideEffect = false;
assertThrowsInstanceOf(function() { ++f(); }, ReferenceError);
assert.sameValue(hadSideEffect, true);
hadSideEffect = false;
assertThrowsInstanceOf(function() {
for (var i = 0; i < 20; i++)
{
if (i > 18)
++f();
}
}, ReferenceError);
assert.sameValue(hadSideEffect, true);
hadSideEffect = false;
assertThrowsInstanceOf(function() { --f(); }, ReferenceError);
assert.sameValue(hadSideEffect, true);
hadSideEffect = false;
assertThrowsInstanceOf(function() {
for (var i = 0; i < 20; i++)
{
if (i > 18)
--f();
}
}, ReferenceError);
assert.sameValue(hadSideEffect, true);
/******************************************************************************/
print("Tests complete");

View File

@ -1,81 +0,0 @@
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
*/
/*---
includes: [sm/non262.js, sm/non262-shell.js]
flags:
- noStrict
description: |
pending
esid: pending
---*/
var actual;
var expect = "pass";
var x = "fail";
function f() {
var x = "pass";
delete(eval("actual = x"));
}
f();
assert.sameValue(actual, expect);
function g() { return 1 }
function h() { function g() { throw 2; } eval('g()')++; }
assertThrowsValue(h, 2);
var lhs_prefix = ["", "++", "--", "", "", "[", "[y, " ];
var lhs_suffix = [" = 'no'", "", "", "++", "--", ", y] = [3, 4]", "] = [5, 6]"];
for (var i = 0; i < lhs_prefix.length; i++) {
var expected;
if (/\[/.test(lhs_prefix[i])) {
expected = "invalid destructuring target";
} else {
/*
* NB: JSOP_SETCALL throws only JSMSG_ASSIGN_TO_CALL, it does not
* specialize for ++ and -- as the compiler's error reporting does. See
* the next section's forked assert.sameValue code.
*/
expected = "cannot assign to function call";
}
assertThrownErrorContains(
() => eval(lhs_prefix[i] + "eval('x')" + lhs_suffix[i]),
expected);
}
/* Now test for strict mode rejecting any SETCALL variant at compile time. */
for (var i = 0; i < lhs_prefix.length; i++) {
var expected;
if (/\+\+|\-\-/.test(lhs_prefix[i] || lhs_suffix[i]))
expected = "invalid increment/decrement operand";
else if (/\[/.test(lhs_prefix[i]))
expected = "invalid destructuring target";
else
expected = "invalid assignment left-hand side";
assertThrownErrorContains(
() => eval("(function () { 'use strict'; " + lhs_prefix[i] + "foo('x')" + lhs_suffix[i] + "; })"),
expected);
}
/*
* The useless delete is optimized away, but the SETCALL must not be. It's not
* an early error, though.
*/
var fooArg;
function foo(arg) { fooArg = arg; }
assertThrownErrorContains(
() => eval("delete (foo('x') = 42);"),
"cannot assign to function call");
assert.sameValue(fooArg, 'x');
/* Delete of a call expression is not an error at all, even in strict mode. */
function g() {
"use strict";
assert.sameValue(delete Object(), true);
}
g();

View File

@ -40,7 +40,7 @@ function test() {
throw "in lhs";
}
assertThrowsValue(function() {
for ((throwlhs()) of iterable)
for ((throwlhs().x) of iterable)
continue;
}, "in lhs");
assert.sameValue(returnCalled, ++returnCalledExpected);