summaryrefslogtreecommitdiff
path: root/test/built-ins/Object/defineProperties/15.2.3.7-6-a-91.js
blob: 3698daffbb0cab143af2d440a1d4ba337302beee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2012 Ecma International.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
es5id: 15.2.3.7-6-a-91
description: >
    Object.defineProperties throws TypeError when P.configurable is
    false, both properties.[[Get]] and P.[[Get]] are two objects which
    refer to different objects (8.12.9 step 11.a.ii)
includes: [propertyHelper.js]
---*/


var obj = {};

function set_func(value) {
    obj.setVerifyHelpProp = value;
}
function get_func1() {
    return 10;
}

Object.defineProperty(obj, "foo", {
    get: get_func1,
    set: set_func,
    enumerable: false,
    configurable: false
});

function get_func2() {
    return 20;
}

try {
    Object.defineProperties(obj, {
        foo: {
            get: get_func2
        }
    });
    $ERROR("Expected an exception");
} catch (e) {
    verifyEqualTo(obj, "foo", get_func1());

    verifyWritable(obj, "foo", "setVerifyHelpProp");

    verifyNotEnumerable(obj, "foo");

    verifyNotConfigurable(obj, "foo");

    if (!(e instanceof TypeError)) {
        $ERROR("Expected TypeError, got " + e);
    }

}