summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/class/subclass/class-definition-null-proto-contains-return-override.js
blob: 5fc6aa0c2964ac7739cceb3f20adc2c8e79c0d76 (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
// Copyright (C) 2014 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-runtime-semantics-classdefinitionevaluation
es6id: 14.5.14
description: >
    The constructor of a null-extending class can contain an explicit return value.
info: |
  Runtime Semantics: ClassDefinitionEvaluation

  [...]
  15. If ClassHeritageopt is present, then set F's [[ConstructorKind]] internal slot to "derived".
  [...]

  9.2.2 [[Construct]]

  [...]
  13. If result.[[Type]] is return, then
     a. If Type(result.[[Value]]) is Object, return NormalCompletion(result.[[Value]]).
  [...]
---*/
var obj;

class Foo extends null {
  constructor() {
    return obj = {};
  }
}

var f = new Foo();

assert.sameValue(f, obj);
assert.sameValue(Object.getPrototypeOf(f), Object.prototype);

reportCompare(0, 0);