Skip to content

Commit 2bfb9b9

Browse files
committed
Fix ecma_op_array_object_define_own_property
JerryScript-DCO-1.0-Signed-off-by: Kristof Kosztyo [email protected]
1 parent e9a5b34 commit 2bfb9b9

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

jerry-core/ecma/operations/ecma-array-object.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ ecma_op_array_object_define_own_property (ecma_object_t *obj_p, /**< the array o
414414
return ecma_op_general_object_define_own_property (obj_p,
415415
property_name_p,
416416
property_desc_p,
417-
false);
417+
is_throw);
418418
}
419419

420420
// 4.

tests/jerry/object-defineproperty.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright 2015 Samsung Electronics Co., Ltd.
2+
// Copyright 2015 University of Szeged.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
var obj = [];
17+
18+
Object.defineProperty (obj, "prop", {
19+
value: 2010,
20+
writable: true,
21+
enumerable: true,
22+
configurable: false
23+
});
24+
25+
assert (obj.hasOwnProperty ("prop"));
26+
function getFunc() {
27+
return 20;
28+
}
29+
30+
try {
31+
Object.defineProperty (obj, "prop", {
32+
get: getFunc
33+
});
34+
assert (false);
35+
} catch (e) {
36+
assert (e instanceof TypeError);
37+
var desc = Object.getOwnPropertyDescriptor (obj, "prop");
38+
assert (desc.value === 2010);
39+
assert (typeof (desc.get) === 'undefined');
40+
}

0 commit comments

Comments
 (0)