Skip to content

Commit

Permalink
test: add test for a vm indexed property
Browse files Browse the repository at this point in the history
Adds a single test for a vm with an indexed property.

PR-URL: #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>
  • Loading branch information
conectado authored and MylesBorins committed Oct 30, 2018
1 parent 9f4be5d commit e865418
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/parallel/test-vm-context-property-forwarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit e865418

Please sign in to comment.