v8/test/mjsunit/harmony/object-literals-property-shorthand.js
arv@chromium.org a36dee4d14 ES6: Implement object literal property shorthand
This allows the following:

var x = 1;
var o = {x};

This is under the --harmony-object-literals flag.

BUG=v8:3584
LOG=y
R=marja@chromium.org, rossberg@chromium.org

Review URL: https://codereview.chromium.org/584993002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24291 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-09-29 14:15:48 +00:00

52 lines
1.0 KiB
JavaScript

// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-object-literals
(function TestBasics() {
var x = 1;
var object = {x};
assertEquals(1, object.x);
})();
(function TestDescriptor() {
var x = 1;
var object = {x};
var descr = Object.getOwnPropertyDescriptor(object, 'x');
assertEquals(1, descr.value);
assertTrue(descr.enumerable);
assertTrue(descr.writable);
assertTrue(descr.configurable);
})();
(function TestNotDefined() {
'use strict';
assertThrows(function() {
return {notDefined};
}, ReferenceError);
})();
(function TestLet() {
var let = 1;
var object = {let};
assertEquals(1, object.let);
})();
(function TestYieldInFunction() {
var yield = 1;
var object = {yield};
assertEquals(1, object.yield);
})();
(function TestToString() {
function f(x) { return {x}; }
assertEquals('function f(x) { return {x}; }', f.toString());
})();