11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_cirequire('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ciconst v8 = require('v8');
51cb0ef41Sopenharmony_ciconst vm = require('vm');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci// Note: changing V8 flags after an isolate started is not guaranteed to work.
81cb0ef41Sopenharmony_ci// Specifically here, V8 may cache compiled scripts between the flip of the
91cb0ef41Sopenharmony_ci// flag. We use a different script each time to work around this problem.
101cb0ef41Sopenharmony_civ8.setFlagsFromString('--allow_natives_syntax');
111cb0ef41Sopenharmony_ciassert(eval('%IsSmi(42)'));
121cb0ef41Sopenharmony_ciassert(vm.runInThisContext('%IsSmi(43)'));
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_civ8.setFlagsFromString('--noallow_natives_syntax');
151cb0ef41Sopenharmony_ciassert.throws(function() { eval('%IsSmi(44)'); },
161cb0ef41Sopenharmony_ci              /^SyntaxError: Unexpected token '%'$/);
171cb0ef41Sopenharmony_ciassert.throws(function() { vm.runInThisContext('%IsSmi(45)'); },
181cb0ef41Sopenharmony_ci              /^SyntaxError: Unexpected token '%'$/);
19