1'use strict';
2
3// https://github.com/nodejs/node/issues/31808
4// function declarations currently call [[Set]] instead of [[DefineOwnProperty]]
5// in VM contexts, which violates the ECMA-262 specification:
6// https://tc39.es/ecma262/#sec-createglobalfunctionbinding
7
8const common = require('../common');
9const vm = require('vm');
10const assert = require('assert');
11
12const ctx = vm.createContext();
13Object.defineProperty(ctx, 'x', {
14  enumerable: true,
15  configurable: true,
16  get: common.mustNotCall('ctx.x getter must not be called'),
17  set: common.mustNotCall('ctx.x setter must not be called'),
18});
19
20vm.runInContext('function x() {}', ctx);
21assert.strictEqual(typeof ctx.x, 'function');
22