mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
bcb1d9c39a
PR-URL: https://github.com/nodejs/node/pull/12603 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
19 lines
747 B
JavaScript
19 lines
747 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const v8 = require('v8');
|
|
const 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: Unexpected token %$/);
|
|
assert.throws(function() { vm.runInThisContext('%_IsSmi(45)'); },
|
|
/^SyntaxError: Unexpected token %$/);
|