From e8654181389b3db76f10c04641ee34adcff67b07 Mon Sep 17 00:00:00 2001 From: conectado Date: Sun, 7 Oct 2018 15:20:11 -0300 Subject: [PATCH] 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 Reviewed-By: John-David Dalton Reviewed-By: James M Snell Reviewed-By: Refael Ackermann --- test/parallel/test-vm-context-property-forwarding.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/parallel/test-vm-context-property-forwarding.js b/test/parallel/test-vm-context-property-forwarding.js index eca34e9b0987ec..800a9fa2438988 100644 --- a/test/parallel/test-vm-context-property-forwarding.js +++ b/test/parallel/test-vm-context-property-forwarding.js @@ -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);