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
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-additional-properties-of-the-object.prototype-object
description: Behavior when getter is not callable
info: |
[...]
2. If IsCallable(getter) is false, throw a TypeError exception.
features: [Symbol, __getter__]
---*/
var subject = {};
var symbol = Symbol('');
var toStringCount = 0;
var key = {
toString: function() {
toStringCount += 1;
}
};
assert.sameValue(typeof Object.prototype.__defineGetter__, 'function');
assert.throws(TypeError, function() {
subject.__defineGetter__(key, '');
}, 'string');
assert.throws(TypeError, function() {
subject.__defineGetter__(key, 23);
}, 'number');
assert.throws(TypeError, function() {
subject.__defineGetter__(key, true);
}, 'boolean');
assert.throws(TypeError, function() {
subject.__defineGetter__(key, symbol);
}, 'symbol');
assert.throws(TypeError, function() {
subject.__defineGetter__(key, {});
}, 'object');
assert.sameValue(toStringCount, 0);
reportCompare(0, 0);
|