mirror of
https://github.com/tc39/test262.git
synced 2025-07-26 23:44:27 +02:00
Add more tests for Object.prototype.[[SetPrototypeOf]]
(#4446)
This commit is contained in:
parent
8da5438d7a
commit
5b7101ae71
33
test/built-ins/Object/prototype/setPrototypeOf-with-non-circular-values-__proto__.js
vendored
Normal file
33
test/built-ins/Object/prototype/setPrototypeOf-with-non-circular-values-__proto__.js
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2025 ExE Boss. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-immutable-prototype-exotic-objects-setprototypeof-v
|
||||
description: >
|
||||
Object.prototype's [[SetPrototypeOf]] returns false even in cases where
|
||||
OrdinarySetPrototypeOf(O, V) would return true
|
||||
info: |
|
||||
9.4.7.1 [[SetPrototypeOf]] (V)
|
||||
|
||||
...
|
||||
2. Let current be the value of the [[Prototype]] internal slot of O.
|
||||
3. If SameValue(V, current), return true.
|
||||
4. Return false.
|
||||
|
||||
19.1.3 Properties of the Object Prototype Object
|
||||
|
||||
The value of the [[Prototype]] internal slot of the Object prototype object is
|
||||
null and the initial value of the [[Extensible]] internal slot is true.
|
||||
features: [Reflect.setPrototypeOf]
|
||||
---*/
|
||||
|
||||
var ObjProto = Object.prototype;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Object.setPrototypeOf(ObjProto, { __proto__: null });
|
||||
}, "Object.setPrototypeOf(ObjProto, { __proto__: null }) throws a TypeError");
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.setPrototypeOf(ObjProto, { __proto__: null }),
|
||||
false,
|
||||
"Reflect.setPrototypeOf(ObjProto, { __proto__: null }) returns false"
|
||||
);
|
33
test/built-ins/Object/prototype/setPrototypeOf-with-non-circular-values.js
vendored
Normal file
33
test/built-ins/Object/prototype/setPrototypeOf-with-non-circular-values.js
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2025 ExE Boss. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-immutable-prototype-exotic-objects-setprototypeof-v
|
||||
description: >
|
||||
Object.prototype's [[SetPrototypeOf]] returns false even in cases where
|
||||
OrdinarySetPrototypeOf(O, V) would return true
|
||||
info: |
|
||||
9.4.7.1 [[SetPrototypeOf]] (V)
|
||||
|
||||
...
|
||||
2. Let current be the value of the [[Prototype]] internal slot of O.
|
||||
3. If SameValue(V, current), return true.
|
||||
4. Return false.
|
||||
|
||||
19.1.3 Properties of the Object Prototype Object
|
||||
|
||||
The value of the [[Prototype]] internal slot of the Object prototype object is
|
||||
null and the initial value of the [[Extensible]] internal slot is true.
|
||||
features: [Reflect.setPrototypeOf]
|
||||
---*/
|
||||
|
||||
var ObjProto = Object.prototype;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Object.setPrototypeOf(ObjProto, Object.create(null));
|
||||
}, "Object.setPrototypeOf(ObjProto, Object.create(null)) throws a TypeError");
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.setPrototypeOf(ObjProto, Object.create(null)),
|
||||
false,
|
||||
"Reflect.setPrototypeOf(ObjProto, Object.create(null)) returns false"
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user