summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/class/definition/prototype-getter.js
blob: cbfe6ac1b7a358e7760b2fc69cae3d1440aafc98 (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
// Copyright (C) 2014 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 14.5
description: >
    class prototype getter
---*/
var calls = 0;
var Base = function() {}.bind();
Object.defineProperty(Base, 'prototype', {
  get: function() {
    calls++;
    return null;
  },
  configurable: true
});
class C extends Base {}
assert.sameValue(calls, 1, "The value of `calls` is `1`");

calls = 0;
Object.defineProperty(Base, 'prototype', {
  get: function() {
    calls++;
    return 42;
  },
  configurable: true
});
assert.throws(TypeError, function() {
  class C extends Base {}
});
assert.sameValue(calls, 1, "The value of `calls` is `1`");

reportCompare(0, 0);