node/test/parallel/test-vm-symbols.js
Adrian Estrada 7c0d5d5fd9 test: improve code in test-vm-symbols
* use const instead of var
* use assert.strictEqual instead of assert.equal

PR-URL: https://github.com/nodejs/node/pull/10429
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2016-12-26 12:33:08 +01:00

26 lines
585 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const vm = require('vm');
const symbol = Symbol();
function Document() {
this[symbol] = 'foo';
}
Document.prototype.getSymbolValue = function() {
return this[symbol];
};
const context = new Document();
vm.createContext(context);
assert.strictEqual(context.getSymbolValue(), 'foo',
'should return symbol-keyed value from the outside');
assert.strictEqual(vm.runInContext('this.getSymbolValue()', context), 'foo',
'should return symbol-keyed value from the inside');