mirror of
https://github.com/nodejs/node.git
synced 2024-11-25 08:19:38 +01:00
4e58211bb7
Per the discussion in https://github.com/iojs/io.js/pull/272, upstream V8 has disabled Harmony object literals for the time being. Do the same for feature parity. PR-URL: https://github.com/iojs/io.js/pull/272 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Domenic Denicola <domenic@domenicdenicola.com>
32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
var common = require('../common');
|
|
var assert = require('assert');
|
|
var spawnSync = require('child_process').spawnSync;
|
|
var v8 = require('v8');
|
|
|
|
// --harmony_classes implies --harmony_scoping; ensure that scoping still works
|
|
// when classes are disabled.
|
|
assert.throws(function() { eval('"use strict"; class C {}'); }, SyntaxError);
|
|
eval('"use strict"; let x = 42'); // Should not throw.
|
|
eval('"use strict"; const y = 42'); // Should not throw.
|
|
|
|
v8.setFlagsFromString('--harmony_classes');
|
|
eval('"use strict"; class C {}'); // Should not throw.
|
|
eval('"use strict"; let x = 42'); // Should not throw.
|
|
eval('"use strict"; const y = 42'); // Should not throw.
|
|
|
|
// Verify that the --harmony_classes flag unlocks classes again.
|
|
var args = ['--harmony_classes', '--use_strict', '-p', 'class C {}'];
|
|
var cp = spawnSync(process.execPath, args);
|
|
assert.equal(cp.status, 0);
|
|
assert.equal(cp.stdout.toString('utf8').trim(), '[Function: C]');
|
|
|
|
// Now do the same for --harmony_object_literals.
|
|
assert.throws(function() { eval('({ f() {} })'); }, SyntaxError);
|
|
v8.setFlagsFromString('--harmony_object_literals');
|
|
eval('({ f() {} })');
|
|
|
|
var args = ['--harmony_object_literals', '-p', '({ f() {} })'];
|
|
var cp = spawnSync(process.execPath, args);
|
|
assert.equal(cp.status, 0);
|
|
assert.equal(cp.stdout.toString('utf8').trim(), '{ f: [Function: f] }');
|