Fix JS keyword rename test to actually test for renaming

Assigning to a property in JS always works, as it just creates a new
property if there is no existing one, and so can't be used for testing
for its existence.

Set the property value in C code and try accessing it from JS instead.

Also check that not only the property with the expected name exists, but
also that the property with the renamed name does not.

See #2943.
This commit is contained in:
Vadim Zeitlin 2024-09-09 18:04:19 +02:00 committed by Olly Betts
parent f15d6b2d5e
commit 5a1d7ae035
2 changed files with 14 additions and 1 deletions

View File

@ -2,4 +2,11 @@ var keyword_rename = require("keyword_rename")
keyword_rename._instanceof(1)
keyword_rename._finally(1)
keyword_rename._yield(0)
keyword_rename.yield = 0
var s = keyword_rename.make_S_with_yield(17);
if (s.yield != 17)
throw new Error;
if (s._yield == 17)
throw new Error;

View File

@ -47,6 +47,12 @@ struct S {
int yield;
};
struct S make_S_with_yield(int yield) {
struct S s;
s.yield = yield;
return s;
}
%}