0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-vm-create-context-accessors.js

29 lines
518 B
JavaScript
Raw Normal View History

'use strict';
require('../common');
2011-09-08 13:42:44 +02:00
var assert = require('assert');
var vm = require('vm');
var ctx = {};
Object.defineProperty(ctx, 'getter', {
get: function() {
return 'ok';
}
});
var val;
Object.defineProperty(ctx, 'setter', {
set: function(_val) {
val = _val;
},
get: function() {
return 'ok=' + val;
}
});
ctx = vm.createContext(ctx);
var result = vm.runInContext('setter = "test";[getter,setter]', ctx);
assert.strictEqual(result[0], 'ok');
assert.strictEqual(result[1], 'ok=test');