mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 17:10:40 +00:00

V8 may cache compiled scripts, and it is not safe to assume that the V8 flags can be changed after an isolate has been created. In this particular case, since we are using the same script multiple times, the test would fail if V8 cached the result of the compilation. Ref: https://github.com/nodejs/node/issues/6280 Fixes: https://github.com/nodejs/node/issues/6258 PR-URL: https://github.com/nodejs/node/pull/6316 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com> Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
17 lines
665 B
JavaScript
17 lines
665 B
JavaScript
'use strict';
|
|
require('../common');
|
|
var assert = require('assert');
|
|
var v8 = require('v8');
|
|
var vm = require('vm');
|
|
|
|
// Note: changing V8 flags after an isolate started is not guaranteed to work.
|
|
// Specifically here, V8 may cache compiled scripts between the flip of the
|
|
// flag. We use a different script each time to work around this problem.
|
|
v8.setFlagsFromString('--allow_natives_syntax');
|
|
assert(eval('%_IsSmi(42)'));
|
|
assert(vm.runInThisContext('%_IsSmi(43)'));
|
|
|
|
v8.setFlagsFromString('--noallow_natives_syntax');
|
|
assert.throws(function() { eval('%_IsSmi(44)'); }, SyntaxError);
|
|
assert.throws(function() { vm.runInThisContext('%_IsSmi(45)'); }, SyntaxError);
|