mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Fix the Object.getPrototypeOf function.
Related issue: #208 JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
This commit is contained in:
parent
d7ecd4a467
commit
1c19e5c8ab
@ -128,11 +128,17 @@ ecma_builtin_object_object_get_prototype_of (ecma_value_t this_arg __attr_unused
|
|||||||
{
|
{
|
||||||
/* 2. */
|
/* 2. */
|
||||||
ecma_object_t *obj_p = ecma_get_object_from_value (arg);
|
ecma_object_t *obj_p = ecma_get_object_from_value (arg);
|
||||||
|
|
||||||
ecma_object_t *prototype_p = ecma_get_object_prototype (obj_p);
|
ecma_object_t *prototype_p = ecma_get_object_prototype (obj_p);
|
||||||
ecma_ref_object (prototype_p);
|
|
||||||
|
|
||||||
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (prototype_p));
|
if (prototype_p)
|
||||||
|
{
|
||||||
|
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (prototype_p));
|
||||||
|
ecma_ref_object (prototype_p);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret_value;
|
return ret_value;
|
||||||
|
|||||||
@ -128,8 +128,7 @@ try {
|
|||||||
// Create an object with null as prototype
|
// Create an object with null as prototype
|
||||||
var obj = Object.create(null)
|
var obj = Object.create(null)
|
||||||
assert (typeof (obj) === "object");
|
assert (typeof (obj) === "object");
|
||||||
// FIXME: enable this assertion after the #208 is fixed.
|
assert (Object.getPrototypeOf (obj) === null);
|
||||||
// assert (Object.getPrototypeOf (obj) === null);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Object.create()
|
Object.create()
|
||||||
|
|||||||
@ -35,11 +35,21 @@ try {
|
|||||||
assert (e instanceof TypeError);
|
assert (e instanceof TypeError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
var y = Object.getPrototypeOf(null);
|
||||||
|
assert (false);
|
||||||
|
} catch (e) {
|
||||||
|
assert (e instanceof TypeError);
|
||||||
|
}
|
||||||
|
|
||||||
var obj = { x : "foo" };
|
var obj = { x : "foo" };
|
||||||
assert (Object.getPrototypeOf(obj) === Object.prototype)
|
assert (Object.getPrototypeOf(obj) === Object.prototype);
|
||||||
|
|
||||||
var constructor = function () {};
|
var constructor = function () {};
|
||||||
constructor.prototype = obj;
|
constructor.prototype = obj;
|
||||||
|
|
||||||
var d_obj = new constructor();
|
var d_obj = new constructor();
|
||||||
assert (Object.getPrototypeOf(d_obj) === obj);
|
assert (Object.getPrototypeOf(d_obj) === obj);
|
||||||
|
|
||||||
|
obj = Object.create(null);
|
||||||
|
assert (Object.getPrototypeOf(obj) === null);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user