mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
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:
1 parent
972d0beb59
commit
b409eaaf25
1 file changed
+11
@@ -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);
|
||||
Reference in new issue
Block a user