Index: test/mjsunit/harmony/reflect-set-prototype-of.js |
diff --git a/test/mjsunit/harmony/set-prototype-of.js b/test/mjsunit/harmony/reflect-set-prototype-of.js |
similarity index 87% |
copy from test/mjsunit/harmony/set-prototype-of.js |
copy to test/mjsunit/harmony/reflect-set-prototype-of.js |
index e92a0c37bc3de9eb3b4750b0474581319061304e..95b05aacd9054080a183e6d4f3aed98592a77313 100644 |
--- a/test/mjsunit/harmony/set-prototype-of.js |
+++ b/test/mjsunit/harmony/reflect-set-prototype-of.js |
@@ -1,4 +1,4 @@ |
-// Copyright 2014 the V8 project authors. All rights reserved. |
+// Copyright 2014-2015 the V8 project authors. All rights reserved. |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
// met: |
@@ -25,6 +25,11 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+// This is adapted from mjsunit/harmony/set-prototype-of.js. |
+ |
+// Flags: --harmony-reflect |
+ |
+ |
function getObjects() { |
function func() {} |
@@ -65,7 +70,7 @@ function TestSetPrototypeOfCoercibleValues() { |
for (var i = 0; i < coercibleValues.length; i++) { |
var value = coercibleValues[i]; |
var proto = Object.getPrototypeOf(value); |
- assertEquals(Object.setPrototypeOf(value, {}), value); |
+ assertThrows(function() { Reflect.setPrototypeOf(value, {}) }, TypeError); |
assertSame(proto, Object.getPrototypeOf(value)); |
} |
} |
@@ -76,7 +81,7 @@ function TestSetPrototypeOfNonCoercibleValues() { |
for (var i = 0; i < nonCoercibleValues.length; i++) { |
var value = nonCoercibleValues[i]; |
assertThrows(function() { |
- Object.setPrototypeOf(value, {}); |
+ Reflect.setPrototypeOf(value, {}); |
}, TypeError); |
} |
} |
@@ -90,7 +95,7 @@ function TestSetPrototypeToNonObject(proto) { |
for (var j = 0; j < valuesWithoutNull.length; j++) { |
var proto = valuesWithoutNull[j]; |
assertThrows(function() { |
- Object.setPrototypeOf(object, proto); |
+ Reflect.setPrototypeOf(object, proto); |
}, TypeError); |
} |
} |
@@ -99,7 +104,7 @@ TestSetPrototypeToNonObject(); |
function TestSetPrototypeOf(object, proto) { |
- assertEquals(Object.setPrototypeOf(object, proto), object); |
+ assertTrue(Reflect.setPrototypeOf(object, proto)); |
assertEquals(Object.getPrototypeOf(object), proto); |
} |
@@ -131,9 +136,7 @@ function TestSetPrototypeOfNonExtensibleObject() { |
for (var i = 0; i < objects.length; i++) { |
var object = objects[i]; |
Object.preventExtensions(object); |
- assertThrows(function() { |
- Object.setPrototypeOf(object, proto); |
- }, TypeError); |
+ assertFalse(Reflect.setPrototypeOf(object, proto)); |
} |
} |
TestSetPrototypeOfNonExtensibleObject(); |
@@ -149,9 +152,7 @@ function TestSetPrototypeCyclic() { |
for (var i = 0; i < objects.length; i += 2) { |
var object = objects[i]; |
var value = objects[i + 1]; |
- assertThrows(function() { |
- Object.setPrototypeOf(object, value); |
- }, TypeError); |
+ assertFalse(Reflect.setPrototypeOf(object, value)); |
} |
} |
TestSetPrototypeCyclic(); |
@@ -166,14 +167,14 @@ function TestLookup() { |
x: 'old x', |
y: 'old y' |
}; |
- Object.setPrototypeOf(object, oldProto); |
+ assertTrue(Reflect.setPrototypeOf(object, oldProto)); |
assertEquals(object.x, 'old x'); |
assertEquals(object.y, 'old y'); |
var newProto = { |
x: 'new x' |
}; |
- Object.setPrototypeOf(object, newProto); |
+ assertTrue(Reflect.setPrototypeOf(object, newProto)); |
assertEquals(object.x, 'new x'); |
assertFalse('y' in object); |
} |