0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-28 14:33:11 +01:00
nodejs/test/known_issues/test-vm-ownpropertysymbols.js
Antoine du Hamel 6d92cc736d
test: add trailing commas in test/known_issues
PR-URL: https://github.com/nodejs/node/pull/46408
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2023-02-01 10:46:55 +01:00

29 lines
960 B
JavaScript

'use strict';
require('../common');
const vm = require('vm');
const assert = require('assert');
const sym1 = Symbol('1');
const sym2 = Symbol('2');
const sandbox = {
a: true,
[sym1]: true,
};
Object.defineProperty(sandbox, 'b', { value: true });
Object.defineProperty(sandbox, sym2, { value: true });
const ctx = vm.createContext(sandbox);
// Sanity check
// Please uncomment these when the test is no longer broken
// assert.deepStrictEqual(Reflect.ownKeys(sandbox), ['a', 'b', sym1, sym2]);
// assert.deepStrictEqual(Object.getOwnPropertyNames(sandbox), ['a', 'b']);
// assert.deepStrictEqual(Object.getOwnPropertySymbols(sandbox), [sym1, sym2]);
const nativeSym = vm.runInNewContext('Object.getOwnPropertySymbols(this);');
const ownSym = vm.runInContext('Object.getOwnPropertySymbols(this);', ctx);
const restSym = ownSym.filter((sym) => !nativeSym.includes(sym));
// This should not fail
assert.deepStrictEqual(Array.from(restSym), [sym1, sym2]);