• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2require('../common');
3const assert = require('assert');
4const v8 = require('v8');
5const vm = require('vm');
6
7// Note: changing V8 flags after an isolate started is not guaranteed to work.
8// Specifically here, V8 may cache compiled scripts between the flip of the
9// flag. We use a different script each time to work around this problem.
10v8.setFlagsFromString('--allow_natives_syntax');
11assert(eval('%_IsSmi(42)'));
12assert(vm.runInThisContext('%_IsSmi(43)'));
13
14v8.setFlagsFromString('--noallow_natives_syntax');
15assert.throws(function() { eval('%_IsSmi(44)'); },
16              /^SyntaxError: Unexpected token '%'$/);
17assert.throws(function() { vm.runInThisContext('%_IsSmi(45)'); },
18              /^SyntaxError: Unexpected token '%'$/);
19