Add test for extending a constructor with null .prototype (#806)

This commit is contained in:
Kevin Gibbons 2016-12-20 22:30:06 -08:00 committed by Leo Balter
parent db3aa4ca4f
commit fcc9e07265
6 changed files with 33 additions and 17 deletions

View File

@ -8,7 +8,7 @@ description: >
info: |
[...]
10. If constructor is empty, then
a. If ClassHeritageopt is present and protoParent is not null, then
a. If ClassHeritageopt is present and superclass is not null, then
i. Let constructor be the result of parsing the source text
constructor(... args){ super (...args);}

View File

@ -16,11 +16,9 @@ info: |
[...]
6. Else,
[...]
e. If superclass is null, then
i. Let protoParent be null.
ii. Let constructorParent be the intrinsic object %FunctionPrototype%.
b. Let superclass be the result of evaluating ClassHeritage.
[...]
15. If ClassHeritageopt is present and protoParent is not null, then set F's
15. If ClassHeritageopt is present and superclass is not null, then set F's
[[ConstructorKind]] internal slot to "derived".
[...]

View File

@ -13,11 +13,9 @@ info: |
[...]
6. Else,
[...]
e. If superclass is null, then
i. Let protoParent be null.
ii. Let constructorParent be the intrinsic object %FunctionPrototype%.
b. Let superclass be the result of evaluating ClassHeritage.
[...]
15. If ClassHeritageopt is present and protoParent is not null, then set F's
15. If ClassHeritageopt is present and superclass is not null, then set F's
[[ConstructorKind]] internal slot to "derived".
[...]

View File

@ -15,11 +15,9 @@ info: |
[...]
6. Else,
[...]
e. If superclass is null, then
i. Let protoParent be null.
ii. Let constructorParent be the intrinsic object %FunctionPrototype%.
b. Let superclass be the result of evaluating ClassHeritage.
[...]
15. If ClassHeritageopt is present and protoParent is not null, then set F's
15. If ClassHeritageopt is present and superclass is not null, then set F's
[[ConstructorKind]] internal slot to "derived".
[...]

View File

@ -16,15 +16,13 @@ info: |
[...]
6. Else,
[...]
e. If superclass is null, then
i. Let protoParent be null.
ii. Let constructorParent be the intrinsic object %FunctionPrototype%.
b. Let superclass be the result of evaluating ClassHeritage.
[...]
7. Let proto be ObjectCreate(protoParent).
8. If ClassBodyopt is not present, let constructor be empty.
9. Else, let constructor be ConstructorMethod of ClassBody.
10. If constructor is empty, then
a. If ClassHeritageopt is present and protoParent is not null, then
a. If ClassHeritageopt is present and superclass is not null, then
[...]
b. Else,
i. Let constructor be the result of parsing the source text

View File

@ -0,0 +1,24 @@
// Copyright (C) 2016 Kevin Gibbons. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-runtime-semantics-classdefinitionevaluation
description: A class which extends a constructor with null .prototype is a derived class.
---*/
var invoked = false;
var instance, savedArg;
function A(arg) {
invoked = true;
savedArg = arg;
this.prop = 0;
}
A.prototype = null;
class C extends A {}
instance = new C(1);
assert.sameValue(invoked, true);
assert.sameValue(savedArg, 1);
assert.sameValue(instance.prop, 0);