2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2015-12-23 16:02:12 -08:00
|
|
|
require('../common');
|
2016-12-30 18:38:06 -05:00
|
|
|
const assert = require('assert');
|
|
|
|
const v8 = require('v8');
|
|
|
|
const vm = require('vm');
|
2014-12-09 22:57:48 +01:00
|
|
|
|
2016-04-20 16:03:20 -07:00
|
|
|
// 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.
|
2014-12-09 22:57:48 +01:00
|
|
|
v8.setFlagsFromString('--allow_natives_syntax');
|
|
|
|
assert(eval('%_IsSmi(42)'));
|
2016-04-20 16:03:20 -07:00
|
|
|
assert(vm.runInThisContext('%_IsSmi(43)'));
|
2014-12-09 22:57:48 +01:00
|
|
|
|
|
|
|
v8.setFlagsFromString('--noallow_natives_syntax');
|
2017-04-22 13:43:43 -07:00
|
|
|
assert.throws(function() { eval('%_IsSmi(44)'); },
|
2019-06-17 10:00:31 +02:00
|
|
|
/^SyntaxError: Unexpected token '%'$/);
|
2017-04-22 13:43:43 -07:00
|
|
|
assert.throws(function() { vm.runInThisContext('%_IsSmi(45)'); },
|
2019-06-17 10:00:31 +02:00
|
|
|
/^SyntaxError: Unexpected token '%'$/);
|