Split files which test for the property order of functions

So SpiderMonkey can run the other parts of these tests.
This commit is contained in:
André Bargull 2021-08-03 10:17:40 -07:00 committed by Rick Waldron
parent d00039593d
commit 47be34cef7
14 changed files with 431 additions and 41 deletions

View File

@ -0,0 +1,38 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object.entries
description: >
Property names are returned in ascending chronological order of creation
that is unaffected by [[DefineOwnProperty]].
info: |
Object.entries ( O )
[...]
2. Let nameList be ? EnumerableOwnPropertyNames(obj, key+value).
3. Return CreateArrayFromList(nameList).
EnumerableOwnPropertyNames ( O, kind )
[...]
2. Let ownKeys be ? O.[[OwnPropertyKeys]]().
[...]
OrdinaryOwnPropertyKeys ( O )
[...]
3. For each own property key P of O that is a String but is not an array index,
in ascending chronological order of property creation, do
a. Add P as the last element of keys.
[...]
5. Return keys.
features: [arrow-function]
includes: [compareArray.js]
---*/
var fn = () => {};
fn.a = 1;
Object.defineProperty(fn, "name", {enumerable: true});
var fnKeys = Object.entries(fn).map(e => e[0]);
assert.compareArray(fnKeys, ["name", "a"]);

View File

@ -27,7 +27,6 @@ info: |
a. Add P as the last element of keys.
[...]
5. Return keys.
features: [arrow-function]
includes: [compareArray.js]
---*/
@ -37,9 +36,3 @@ obj.b = 2;
Object.defineProperty(obj, "a", {writable: false});
var objKeys = Object.entries(obj).map(e => e[0]);
assert.compareArray(objKeys, ["a", "b"]);
var fn = () => {};
fn.a = 1;
Object.defineProperty(fn, "name", {enumerable: true});
var fnKeys = Object.entries(fn).map(e => e[0]);
assert.compareArray(fnKeys, ["name", "a"]);

View File

@ -0,0 +1,37 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object.keys
description: >
Property names are returned in ascending chronological order of creation
that is unaffected by [[DefineOwnProperty]].
info: |
Object.keys ( O )
[...]
2. Let nameList be ? EnumerableOwnPropertyNames(obj, key).
3. Return CreateArrayFromList(nameList).
EnumerableOwnPropertyNames ( O, kind )
[...]
2. Let ownKeys be ? O.[[OwnPropertyKeys]]().
[...]
OrdinaryOwnPropertyKeys ( O )
[...]
3. For each own property key P of O that is a String but is not an array index,
in ascending chronological order of property creation, do
a. Add P as the last element of keys.
[...]
5. Return keys.
features: [arrow-function]
includes: [compareArray.js]
---*/
var fn = () => {};
fn.a = 1;
Object.defineProperty(fn, "length", {enumerable: true});
assert.compareArray(Object.keys(fn), ["length", "a"]);

View File

@ -27,7 +27,6 @@ info: |
a. Add P as the last element of keys.
[...]
5. Return keys.
features: [Proxy]
includes: [compareArray.js]
---*/
@ -41,8 +40,3 @@ Object.defineProperty(obj, "a", {
obj.b = 2;
Object.defineProperty(obj, "a", {value: 1});
assert.compareArray(Object.keys(obj), ["a", "b"]);
var fn = () => {};
fn.a = 1;
Object.defineProperty(fn, "length", {enumerable: true});
assert.compareArray(Object.keys(fn), ["length", "a"]);

View File

@ -0,0 +1,68 @@
// 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
description: >
In a class, static computed property method names can be a number
info: |
Set order: "length", "name", "prototype", static methods
Runtime Semantics: ClassDefinitionEvaluation
...
11. Let constructorInfo be ! DefineMethod of constructor with arguments proto and constructorParent.
12. Let F be constructorInfo.[[Closure]].
13. Perform SetFunctionName(F, className).
14. Perform MakeConstructor(F, false, proto).
...
19. Else, let methods be NonConstructorMethodDefinitions of ClassBody.
20. For each ClassElement m in order from methods, do
a. If IsStatic of m is false, then
...
b. Else,
i. Let status be PropertyDefinitionEvaluation of m with arguments F and false.
...
---
Object.getOwnPropertyNames ( O )
1. Return ? GetOwnPropertyKeys(O, string).
Runtime Semantics: GetOwnPropertyKeys ( O, type )
1. Let obj be ? ToObject(O).
2. Let keys be ? obj.[[OwnPropertyKeys]]().
3. Let nameList be a new empty List.
4. For each element nextKey of keys in List order, do
a. If Type(nextKey) is Symbol and type is symbol or Type(nextKey) is String and type is string, then
i. Append nextKey as the last element of nameList.
5. Return CreateArrayFromList(nameList).
[[OwnPropertyKeys]] ( )
1. Return ! OrdinaryOwnPropertyKeys(O).
OrdinaryOwnPropertyKeys ( O )
1. Let keys be a new empty List.
2. For each own property key P of O such that P is an array index, in ascending numeric index order, do
a. Add P as the last element of keys.
3. For each own property key P of O such that Type(P) is String and P is not an array index, in ascending chronological order of property creation, do
a. Add P as the last element of keys.
4. For each own property key P of O such that Type(P) is Symbol, in ascending chronological order of property creation, do
a. Add P as the last element of keys.
5. Return keys.
includes: [compareArray.js]
---*/
class C {
static a() { return 'A'; }
static [1]() { return 'B'; }
static c() { return 'C'; }
static [2]() { return 'D'; }
}
assert.compareArray(
Object.getOwnPropertyNames(C),
['1', '2', 'length', 'name', 'prototype', 'a', 'c']
);

View File

@ -70,7 +70,3 @@ assert.compareArray(
Object.keys(C),
[]
);
assert.compareArray(
Object.getOwnPropertyNames(C),
['1', '2', 'length', 'name', 'prototype', 'a', 'c']
);

View File

@ -0,0 +1,68 @@
// 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
description: >
In a class, static computed property method names can be a string
info: |
Set order: "length", "name", "prototype", static methods
Runtime Semantics: ClassDefinitionEvaluation
...
11. Let constructorInfo be ! DefineMethod of constructor with arguments proto and constructorParent.
12. Let F be constructorInfo.[[Closure]].
13. Perform SetFunctionName(F, className).
14. Perform MakeConstructor(F, false, proto).
...
19. Else, let methods be NonConstructorMethodDefinitions of ClassBody.
20. For each ClassElement m in order from methods, do
a. If IsStatic of m is false, then
...
b. Else,
i. Let status be PropertyDefinitionEvaluation of m with arguments F and false.
...
---
Object.getOwnPropertyNames ( O )
1. Return ? GetOwnPropertyKeys(O, string).
Runtime Semantics: GetOwnPropertyKeys ( O, type )
1. Let obj be ? ToObject(O).
2. Let keys be ? obj.[[OwnPropertyKeys]]().
3. Let nameList be a new empty List.
4. For each element nextKey of keys in List order, do
a. If Type(nextKey) is Symbol and type is symbol or Type(nextKey) is String and type is string, then
i. Append nextKey as the last element of nameList.
5. Return CreateArrayFromList(nameList).
[[OwnPropertyKeys]] ( )
1. Return ! OrdinaryOwnPropertyKeys(O).
OrdinaryOwnPropertyKeys ( O )
1. Let keys be a new empty List.
2. For each own property key P of O such that P is an array index, in ascending numeric index order, do
a. Add P as the last element of keys.
3. For each own property key P of O such that Type(P) is String and P is not an array index, in ascending chronological order of property creation, do
a. Add P as the last element of keys.
4. For each own property key P of O such that Type(P) is Symbol, in ascending chronological order of property creation, do
a. Add P as the last element of keys.
5. Return keys.
includes: [compareArray.js]
---*/
class C {
static a() { return 'A'}
static ['b']() { return 'B'; }
static c() { return 'C'; }
static ['d']() { return 'D'; }
}
assert.compareArray(
Object.getOwnPropertyNames(C),
['length', 'name', 'prototype', 'a', 'b', 'c', 'd']
);

View File

@ -70,7 +70,3 @@ assert.compareArray(
Object.keys(C),
[]
);
assert.compareArray(
Object.getOwnPropertyNames(C),
['length', 'name', 'prototype', 'a', 'b', 'c', 'd']
);

View File

@ -0,0 +1,79 @@
// 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
description: >
In a class, static computed property method names can be a symbol
info: |
Set order: "length", "name", "prototype", static methods
Runtime Semantics: ClassDefinitionEvaluation
...
11. Let constructorInfo be ! DefineMethod of constructor with arguments proto and constructorParent.
12. Let F be constructorInfo.[[Closure]].
13. Perform SetFunctionName(F, className).
14. Perform MakeConstructor(F, false, proto).
...
19. Else, let methods be NonConstructorMethodDefinitions of ClassBody.
20. For each ClassElement m in order from methods, do
a. If IsStatic of m is false, then
...
b. Else,
i. Let status be PropertyDefinitionEvaluation of m with arguments F and false.
...
---
Object.getOwnPropertyNames ( O )
1. Return ? GetOwnPropertyKeys(O, string).
Object.getOwnPropertySymbols ( O )
1. Return ? GetOwnPropertyKeys(O, symbol).
Runtime Semantics: GetOwnPropertyKeys ( O, type )
1. Let obj be ? ToObject(O).
2. Let keys be ? obj.[[OwnPropertyKeys]]().
3. Let nameList be a new empty List.
4. For each element nextKey of keys in List order, do
a. If Type(nextKey) is Symbol and type is symbol or Type(nextKey) is String and type is string, then
i. Append nextKey as the last element of nameList.
5. Return CreateArrayFromList(nameList).
[[OwnPropertyKeys]] ( )
1. Return ! OrdinaryOwnPropertyKeys(O).
OrdinaryOwnPropertyKeys ( O )
1. Let keys be a new empty List.
2. For each own property key P of O such that P is an array index, in ascending numeric index order, do
a. Add P as the last element of keys.
3. For each own property key P of O such that Type(P) is String and P is not an array index, in ascending chronological order of property creation, do
a. Add P as the last element of keys.
4. For each own property key P of O such that Type(P) is Symbol, in ascending chronological order of property creation, do
a. Add P as the last element of keys.
5. Return keys.
includes: [compareArray.js]
features: [Symbol]
---*/
var sym1 = Symbol();
var sym2 = Symbol();
class C {
static a() { return 'A'; }
static [sym1]() { return 'B'; }
static c() { return 'C'; }
static [sym2]() { return 'D'; }
}
assert.compareArray(
Object.getOwnPropertyNames(C),
['length', 'name', 'prototype', 'a', 'c']
);
assert.compareArray(
Object.getOwnPropertySymbols(C),
[sym1, sym2]
);

View File

@ -77,11 +77,3 @@ assert.compareArray(
Object.keys(C),
[]
);
assert.compareArray(
Object.getOwnPropertyNames(C),
['length', 'name', 'prototype', 'a', 'c']
);
assert.compareArray(
Object.getOwnPropertySymbols(C),
[sym1, sym2]
);

View File

@ -0,0 +1,72 @@
// Copyright (C) 2015 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
description: >
Function `length` attribute not inferred in presence of static `length` method
info: |
ClassTail : ClassHeritage_opt { ClassBody_opt }
14. If constructor is empty, then [...]
b. Let F be ! CreateBuiltinFunction(steps, 0, className, « [[ConstructorKind]], [[SourceText]] », empty, constructorParent).
15. Else,
a. Let constructorInfo be ! DefineMethod of constructor with arguments proto and constructorParent.
[ This sets the length property on constructorInfo.[[Closure]]. ]
b. Let F be constructorInfo.[[Closure]].
[...]
25. For each ClassElement e of elements, do
a. If IsStatic of e is false, then [...]
b. Else,
i. Let field be ClassElementEvaluation of e with arguments F and false.
[ This overwrites the length property on F. ]
includes: [compareArray.js]
features: [generators]
---*/
class A {
static method() {
throw new Test262Error('Static method should not be executed during definition');
}
static length() {
throw new Test262Error('Static method should not be executed during definition');
}
}
assert(compareArray(Object.getOwnPropertyNames(A), ['length', 'name', 'prototype', 'method']))
var attr = 'length';
class B {
static [attr]() {
throw new Test262Error(
'Static method defined via computed property should not be executed ' +
'during definition'
);
}
}
assert(compareArray(Object.getOwnPropertyNames(B), ['length', 'name', 'prototype']))
class C {
static get length() {
throw new Test262Error('Static `get` accessor should not be executed during definition');
}
}
assert(compareArray(Object.getOwnPropertyNames(C), ['length', 'name', 'prototype']))
class D {
static set length(_) {
throw new Test262Error('Static `set` accessor should not be executed during definition');
}
}
assert(compareArray(Object.getOwnPropertyNames(D), ['length', 'name', 'prototype']))
class E {
static *length() {
throw new Test262Error('Static GeneratorMethod should not be executed during definition');
}
}
assert(compareArray(Object.getOwnPropertyNames(E), ['length', 'name', 'prototype']))

View File

@ -20,7 +20,6 @@ info: |
b. Else,
i. Let field be ClassElementEvaluation of e with arguments F and false.
[ This overwrites the length property on F. ]
includes: [compareArray.js]
features: [generators]
---*/
@ -34,7 +33,6 @@ class A {
}
assert.sameValue(typeof A.length, 'function');
assert(compareArray(Object.getOwnPropertyNames(A), ['length', 'name', 'prototype', 'method']))
var attr = 'length';
class B {
@ -47,7 +45,6 @@ class B {
}
assert.sameValue(typeof B.length, 'function');
assert(compareArray(Object.getOwnPropertyNames(B), ['length', 'name', 'prototype']))
var isDefined = false;
class C {
@ -61,7 +58,6 @@ class C {
isDefined = true;
assert.sameValue(C.length, 'pass');
assert(compareArray(Object.getOwnPropertyNames(C), ['length', 'name', 'prototype']))
class D {
static set length(_) {
@ -70,7 +66,6 @@ class D {
}
assert.sameValue(D.length, undefined);
assert(compareArray(Object.getOwnPropertyNames(D), ['length', 'name', 'prototype']))
class E {
static *length() {
@ -79,4 +74,3 @@ class E {
}
assert.sameValue(typeof E.length, 'function');
assert(compareArray(Object.getOwnPropertyNames(E), ['length', 'name', 'prototype']))

View File

@ -0,0 +1,69 @@
// Copyright (C) 2015 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
description: >
Function `name` attribute not inferred in presence of static `name` method
info: |
ClassTail : ClassHeritage_opt { ClassBody_opt }
14. If constructor is empty, then [...]
b. Let F be ! CreateBuiltinFunction(steps, 0, className, « [[ConstructorKind]], [[SourceText]] », empty, constructorParent).
15. Else, [...]
d. Perform ! SetFunctionName(F, className).
25. For each ClassElement e of elements, do
a. If IsStatic of e is false, then [...]
b. Else,
i. Let field be ClassElementEvaluation of e with arguments F and false.
[ This overwrites the name property on F. ]
includes: [compareArray.js]
features: [generators]
---*/
class A {
static method() {
throw new Test262Error('Static method should not be executed during definition');
}
static name() {
throw new Test262Error('Static method should not be executed during definition');
}
}
assert(compareArray(Object.getOwnPropertyNames(A), ['length', 'name', 'prototype', 'method']))
var attr = 'name';
class B {
static [attr]() {
throw new Test262Error(
'Static method defined via computed property should not be executed ' +
'during definition'
);
}
}
assert(compareArray(Object.getOwnPropertyNames(B), ['length', 'name', 'prototype']))
class C {
static get name() {
throw new Test262Error('Static `get` accessor should not be executed during definition');
}
}
assert(compareArray(Object.getOwnPropertyNames(C), ['length', 'name', 'prototype']))
class D {
static set name(_) {
throw new Test262Error('Static `set` accessor should not be executed during definition');
}
}
assert(compareArray(Object.getOwnPropertyNames(D), ['length', 'name', 'prototype']))
class E {
static *name() {
throw new Test262Error('Static GeneratorMethod should not be executed during definition');
}
}
assert(compareArray(Object.getOwnPropertyNames(E), ['length', 'name', 'prototype']))

View File

@ -17,7 +17,6 @@ info: |
b. Else,
i. Let field be ClassElementEvaluation of e with arguments F and false.
[ This overwrites the name property on F. ]
includes: [compareArray.js]
features: [generators]
---*/
@ -31,7 +30,6 @@ class A {
}
assert.sameValue(typeof A.name, 'function');
assert(compareArray(Object.getOwnPropertyNames(A), ['length', 'name', 'prototype', 'method']))
var attr = 'name';
class B {
@ -44,7 +42,6 @@ class B {
}
assert.sameValue(typeof B.name, 'function');
assert(compareArray(Object.getOwnPropertyNames(B), ['length', 'name', 'prototype']))
var isDefined = false;
class C {
@ -58,7 +55,6 @@ class C {
isDefined = true;
assert.sameValue(C.name, 'pass');
assert(compareArray(Object.getOwnPropertyNames(C), ['length', 'name', 'prototype']))
class D {
static set name(_) {
@ -67,7 +63,6 @@ class D {
}
assert.sameValue(D.name, undefined);
assert(compareArray(Object.getOwnPropertyNames(D), ['length', 'name', 'prototype']))
class E {
static *name() {
@ -76,4 +71,3 @@ class E {
}
assert.sameValue(typeof E.name, 'function');
assert(compareArray(Object.getOwnPropertyNames(E), ['length', 'name', 'prototype']))