Created
December 28, 2016 21:25
-
-
Save AnnaMag/f676154dc5e4e8c5b952fe1318013c31 to your computer and use it in GitHub Desktop.
Test for changes in the Node.js's Copy Properties (accessor property check)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
require('../common'); | |
const vm = require('vm'); | |
const assert = require('assert'); | |
var x = { value : 13}; | |
Object.defineProperty(x, 'p0', {value : 12}); | |
Object.defineProperty(x, 'p1', { | |
set : function(value) { this.value = value; }, | |
get : function() { return this.value; }, | |
}); | |
const context = vm.createContext(x); | |
const code = `y = Object.getOwnPropertyDescriptor(this, 'p1'); | |
var c=3; | |
Object.getOwnPropertyNames(y) | |
`; | |
const res = vm.runInContext(code, context); | |
console.log(res) // {value, y, c} included, {p0, p1} absent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment