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

Unified Diff: test/mjsunit/proto-accessor.js

Issue 181453002: Reset trunk to 3.24.35.4 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 months 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
« no previous file with comments | « test/mjsunit/mjsunit.status ('k') | test/mjsunit/regress-3135.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/proto-accessor.js
diff --git a/test/mjsunit/proto-accessor.js b/test/mjsunit/proto-accessor.js
index 5eb48bbd239af1f8a420fd626a108fb64ebba944..aca6ec54283803a2cb07e9425471fa322c7f970f 100644
--- a/test/mjsunit/proto-accessor.js
+++ b/test/mjsunit/proto-accessor.js
@@ -25,118 +25,57 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --harmony-symbols
-
var desc = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__");
-var getProto = desc.get;
-var setProto = desc.set;
-
-function TestNoPoisonPill() {
- assertEquals("function", typeof desc.get);
- assertEquals("function", typeof desc.set);
- assertDoesNotThrow("desc.get.call({})");
- assertDoesNotThrow("desc.set.call({}, {})");
-
- var obj = {};
- var obj2 = {};
- desc.set.call(obj, obj2);
- assertEquals(obj.__proto__, obj2);
- assertEquals(desc.get.call(obj), obj2);
-}
-TestNoPoisonPill();
-
-
-function TestRedefineObjectPrototypeProtoGetter() {
- Object.defineProperty(Object.prototype, "__proto__", {
- get: function() {
- return 42;
- }
- });
- assertEquals({}.__proto__, 42);
- assertEquals(desc.get.call({}), Object.prototype);
-
- var desc2 = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__");
- assertEquals(desc2.get.call({}), 42);
- assertEquals(desc2.set.call({}), undefined);
-
- Object.defineProperty(Object.prototype, "__proto__", {
- set: function(x) {}
- });
- var desc3 = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__");
- assertEquals(desc3.get.call({}), 42);
- assertEquals(desc3.set.call({}), undefined);
-}
-TestRedefineObjectPrototypeProtoGetter();
-
+assertEquals("function", typeof desc.get);
+assertEquals("function", typeof desc.set);
+assertDoesNotThrow("desc.get.call({})");
+assertDoesNotThrow("desc.set.call({}, {})");
-function TestRedefineObjectPrototypeProtoSetter() {
- Object.defineProperty(Object.prototype, "__proto__", { set: undefined });
- assertThrows(function() {
- "use strict";
- var o = {};
- var p = {};
- o.__proto__ = p;
- }, TypeError);
-}
-TestRedefineObjectPrototypeProtoSetter();
+var obj = {};
+var obj2 = {};
+desc.set.call(obj, obj2);
+assertEquals(obj.__proto__, obj2);
+assertEquals(desc.get.call(obj), obj2);
-function TestGetProtoOfValues() {
- assertEquals(getProto.call(1), Number.prototype);
- assertEquals(getProto.call(true), Boolean.prototype);
- assertEquals(getProto.call(false), Boolean.prototype);
- assertEquals(getProto.call('s'), String.prototype);
- assertEquals(getProto.call(Symbol()), Symbol.prototype);
- assertThrows(function() { getProto.call(null); }, TypeError);
- assertThrows(function() { getProto.call(undefined); }, TypeError);
-}
-TestGetProtoOfValues();
-
-
-var values = [1, true, false, 's', Symbol()];
-
-
-function TestSetProtoOfValues() {
- for (var i = 0; i < values.length; i++) {
- assertEquals(setProto.call(values[i], i), undefined);
+// Check that any redefinition of the __proto__ accessor works.
+Object.defineProperty(Object.prototype, "__proto__", {
+ get: function() {
+ return 42;
}
+});
+assertEquals({}.__proto__, 42);
+assertEquals(desc.get.call({}), Object.prototype);
- assertThrows(function() { setProto.call(null, 7); }, TypeError);
- assertThrows(function() { setProto.call(undefined, 8); }, TypeError);
-}
-TestSetProtoOfValues();
+var desc2 = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__");
+assertEquals(desc2.get.call({}), 42);
+assertDoesNotThrow("desc2.set.call({})");
-function TestSetProtoToValue() {
- var object = {};
- var proto = {};
- setProto.call(object, proto);
-
- var valuesWithUndefined = values.concat(undefined);
-
- for (var i = 0; i < valuesWithUndefined.length; i++) {
- assertEquals(setProto.call(object, valuesWithUndefined[i]), undefined);
- assertEquals(getProto.call(object), proto);
- }
- // null is the only valid value that can be used as a [[Prototype]].
- assertEquals(setProto.call(object, null), undefined);
- assertEquals(getProto.call(object), null);
-}
-TestSetProtoToValue();
+Object.defineProperty(Object.prototype, "__proto__", { set:function(x){} });
+var desc3 = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__");
+assertDoesNotThrow("desc3.get.call({})");
+assertDoesNotThrow("desc3.set.call({})");
-function TestDeleteProto() {
- assertTrue(delete Object.prototype.__proto__);
+Object.defineProperty(Object.prototype, "__proto__", { set: undefined });
+assertThrows(function() {
+ "use strict";
var o = {};
var p = {};
o.__proto__ = p;
- assertEquals(Object.getPrototypeOf(o), Object.prototype);
- var desc4 = Object.getOwnPropertyDescriptor(o, "__proto__");
- assertTrue(desc4.configurable);
- assertTrue(desc4.enumerable);
- assertTrue(desc4.writable);
- assertEquals(desc4.value, p);
-}
-TestDeleteProto();
+}, TypeError);
+
+
+assertTrue(delete Object.prototype.__proto__);
+var o = {};
+var p = {};
+o.__proto__ = p;
+assertEquals(Object.getPrototypeOf(o), Object.prototype);
+var desc4 = Object.getOwnPropertyDescriptor(o, "__proto__");
+assertTrue(desc4.configurable);
+assertTrue(desc4.enumerable);
+assertTrue(desc4.writable);
+assertEquals(desc4.value, p);
« no previous file with comments | « test/mjsunit/mjsunit.status ('k') | test/mjsunit/regress-3135.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698