Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1326)

Unified Diff: test/mjsunit/harmony/object-literals-super.js

Issue 718473002: ES6: Add support for super in object literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/mjsunit/harmony/object-literals-super.js
diff --git a/test/mjsunit/harmony/object-literals-super.js b/test/mjsunit/harmony/object-literals-super.js
new file mode 100644
index 0000000000000000000000000000000000000000..e29dcf628319b84fb4d921b869d6b581be954efd
--- /dev/null
+++ b/test/mjsunit/harmony/object-literals-super.js
@@ -0,0 +1,122 @@
+// 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-classes --allow-natives-syntax
+
+
+(function TestHomeObject() {
+ var object = {
+ method() {
+ return super.method();
+ },
+ get getter() {
+ return super.getter;
+ },
+ set setter(v) {
+ super.setter = v;
+ },
+ get accessor() {
+ return super.accessor;
+ },
+ set accessor(v) {
+ super.accessor = v;
+ },
+ property: function() {
+ super.property();
+ },
+
+ methodNoSuper() {},
+ get getterNoSuper() {},
+ set setterNoSuper(v) {},
+ get accessorNoSuper() {},
+ set accessorNoSuper(v) {},
+ propertyNoSuper: function() {}
+ };
+
+ print(object.method[%HomeObjectSymbol()])
+
+ assertEquals(object, object.method[%HomeObjectSymbol()]);
+ var desc = Object.getOwnPropertyDescriptor(object, 'getter');
+ assertEquals(object, desc.get[%HomeObjectSymbol()]);
+ desc = Object.getOwnPropertyDescriptor(object, 'setter');
+ assertEquals(object, desc.set[%HomeObjectSymbol()]);
+ desc = Object.getOwnPropertyDescriptor(object, 'accessor');
+ assertEquals(object, desc.get[%HomeObjectSymbol()]);
+ assertEquals(object, desc.set[%HomeObjectSymbol()]);
+ assertEquals(object, object.property[%HomeObjectSymbol()]);
+
+ assertEquals(undefined, object.methodNoSuper[%HomeObjectSymbol()]);
+ desc = Object.getOwnPropertyDescriptor(object, 'getterNoSuper');
+ assertEquals(undefined, desc.get[%HomeObjectSymbol()]);
+ desc = Object.getOwnPropertyDescriptor(object, 'setterNoSuper');
+ assertEquals(undefined, desc.set[%HomeObjectSymbol()]);
+ desc = Object.getOwnPropertyDescriptor(object, 'accessorNoSuper');
+ assertEquals(undefined, desc.get[%HomeObjectSymbol()]);
+ assertEquals(undefined, desc.set[%HomeObjectSymbol()]);
+ assertEquals(undefined, object.propertyNoSuper[%HomeObjectSymbol()]);
+})();
+
+
+(function TestMethod() {
+ var object = {
+ __proto__: {
+ method(x) {
+ return 'proto' + x;
+ }
+ },
+ method(x) {
+ return super.method(x);
+ }
+ };
+ assertEquals('proto42', object.method(42));
+})();
+
+
+(function TestGetter() {
+ var object = {
+ __proto__: {
+ _x: 42,
+ get x() {
+ return 'proto' + this._x;
+ }
+ },
+ get x() {
+ return super.x;
+ }
+ };
+ assertEquals('proto42', object.x);
+})();
+
+
+(function TestSetter() {
+ var object = {
+ __proto__: {
+ _x: 0,
+ set x(v) {
+ return this._x = v;
+ }
+ },
+ set x(v) {
+ super.x = v;
+ }
+ };
+ assertEquals(1, object.x = 1);
+ assertEquals(1, object._x);
+ assertEquals(0, Object.getPrototypeOf(object)._x);
+})();
+
+
+(function TestMethodAsProperty() {
+ var object = {
+ __proto__: {
+ method: function(x) {
+ return 'proto' + x;
+ }
+ },
+ method: function(x) {
+ return super.method(x);
+ }
+ };
+ assertEquals('proto42', object.method(42));
+})();
« src/hydrogen.cc ('K') | « test/cctest/test-parsing.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698