Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/create/15.2.3.5-4-40.js

raw
1 // Copyright (c) 2012 Ecma International. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 es5id: 15.2.3.5-4-40
6 description: >
7 Object.create - ensure that if an exception is thrown it occurs in
8 the correct order relative to prior and subsequent side-effects
9 (15.2.3.7 step 5.a)
10 ---*/
11
12 var newObj = {};
13 var props = {};
14 var i = 0;
15
16 Object.defineProperty(props, "prop1", {
17 get: function() {
18 i++;
19 return {};
20 },
21 enumerable: true
22 });
23
24 Object.defineProperty(props, "prop2", {
25 get: function() {
26 if (1 === i++) {
27 throw new RangeError();
28 } else {
29 return {};
30 }
31 },
32 enumerable: true
33 });
34 assert.throws(RangeError, function() {
35 newObj = Object.create({}, props);
36 });
37 assert.sameValue(newObj.hasOwnProperty("prop1"), false, 'newObj.hasOwnProperty("prop1")');
38 assert.sameValue(i, 2, 'i');