2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2015-12-24 01:02:12 +01:00
|
|
|
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);
|
2016-04-20 00:37:45 +02:00
|
|
|
assert.strictEqual(result[0], 'ok');
|
|
|
|
assert.strictEqual(result[1], 'ok=test');
|