test: add test for a vm indexed property
Adds a single test for a vm with an indexed property. PR-URL: https://github.com/nodejs/node/pull/23318 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
parent
972d0beb59
commit
b409eaaf25
@ -32,3 +32,14 @@ assert.strictEqual(vm.runInContext('x;', ctx), 3);
|
||||
vm.runInContext('y = 4;', ctx);
|
||||
assert.strictEqual(sandbox.y, 4);
|
||||
assert.strictEqual(ctx.y, 4);
|
||||
|
||||
// Test `IndexedPropertyGetterCallback` and `IndexedPropertyDeleterCallback`
|
||||
const x = { get 1() { return 5; } };
|
||||
const pd_expected = Object.getOwnPropertyDescriptor(x, 1);
|
||||
const ctx2 = vm.createContext(x);
|
||||
const pd_actual = Object.getOwnPropertyDescriptor(ctx2, 1);
|
||||
|
||||
assert.deepStrictEqual(pd_actual, pd_expected);
|
||||
assert.strictEqual(ctx2[1], 5);
|
||||
delete ctx2[1];
|
||||
assert.strictEqual(ctx2[1], undefined);
|
||||
|
Loading…
x
Reference in New Issue
Block a user