From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../class/static/browser.js | 0 .../class/static/generator-constructor.js | 13 ++++ .../class/static/generator-prototype.js | 15 ++++ .../class/static/getter-constructor.js | 13 ++++ .../class/static/getter-prototype.js | 15 ++++ .../class/static/method-constructor.js | 13 ++++ .../class/static/method-number-order.js | 70 +++++++++++++++++++ .../class/static/method-number.js | 74 ++++++++++++++++++++ .../class/static/method-prototype.js | 16 +++++ .../class/static/method-string-order.js | 70 +++++++++++++++++++ .../class/static/method-string.js | 74 ++++++++++++++++++++ .../class/static/method-symbol-order.js | 81 ++++++++++++++++++++++ .../class/static/method-symbol.js | 81 ++++++++++++++++++++++ .../class/static/setter-constructor.js | 13 ++++ .../class/static/setter-prototype.js | 16 +++++ .../computed-property-names/class/static/shell.js | 0 16 files changed, 564 insertions(+) create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/browser.js create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/generator-constructor.js create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/generator-prototype.js create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/getter-constructor.js create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/getter-prototype.js create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/method-constructor.js create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/method-number-order.js create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/method-number.js create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/method-prototype.js create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/method-string-order.js create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/method-string.js create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/method-symbol-order.js create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/method-symbol.js create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/setter-constructor.js create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/setter-prototype.js create mode 100644 js/src/tests/test262/language/computed-property-names/class/static/shell.js (limited to 'js/src/tests/test262/language/computed-property-names/class/static') diff --git a/js/src/tests/test262/language/computed-property-names/class/static/browser.js b/js/src/tests/test262/language/computed-property-names/class/static/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/language/computed-property-names/class/static/generator-constructor.js b/js/src/tests/test262/language/computed-property-names/class/static/generator-constructor.js new file mode 100644 index 0000000000..ce81441d1a --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/static/generator-constructor.js @@ -0,0 +1,13 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 12.2.5 +description: > + In a class, computed property names for static + generators can be named "constructor" +---*/ +class C { + static *['constructor']() {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/static/generator-prototype.js b/js/src/tests/test262/language/computed-property-names/class/static/generator-prototype.js new file mode 100644 index 0000000000..7c3924caba --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/static/generator-prototype.js @@ -0,0 +1,15 @@ +// 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.14 +description: > + In a class, computed property names for static + generators that are named "prototype" throw a TypeError +---*/ +assert.throws(TypeError, function() { + class C { + static *['prototype']() {} + } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/static/getter-constructor.js b/js/src/tests/test262/language/computed-property-names/class/static/getter-constructor.js new file mode 100644 index 0000000000..7a12e11a55 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/static/getter-constructor.js @@ -0,0 +1,13 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 12.2.5 +description: > + In a class, computed property names for static + getters can be named "constructor" +---*/ +class C { + static get ['constructor']() {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/static/getter-prototype.js b/js/src/tests/test262/language/computed-property-names/class/static/getter-prototype.js new file mode 100644 index 0000000000..6f149b09dc --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/static/getter-prototype.js @@ -0,0 +1,15 @@ +// 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.14 +description: > + In a class, computed property names for static + getters that are named "prototype" throw a TypeError +---*/ +assert.throws(TypeError, function() { + class C { + static get ['prototype']() {} + } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/static/method-constructor.js b/js/src/tests/test262/language/computed-property-names/class/static/method-constructor.js new file mode 100644 index 0000000000..4250ccd8e5 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/static/method-constructor.js @@ -0,0 +1,13 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 12.2.5 +description: > + In a class, computed property names for static + methods can be named "constructor" +---*/ +class C { + static ['constructor']() {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/static/method-number-order.js b/js/src/tests/test262/language/computed-property-names/class/static/method-number-order.js new file mode 100644 index 0000000000..88bf48b833 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/static/method-number-order.js @@ -0,0 +1,70 @@ +// 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'] +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/static/method-number.js b/js/src/tests/test262/language/computed-property-names/class/static/method-number.js new file mode 100644 index 0000000000..22e5fc593f --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/static/method-number.js @@ -0,0 +1,74 @@ +// 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.sameValue(C.a(), 'A', "`C.a()` returns `'A'`. Defined as `static a() { return 'A'; }`"); +assert.sameValue(C[1](), 'B', "`C[1]()` returns `'B'`. Defined as `static [1]() { return 'B'; }`"); +assert.sameValue(C.c(), 'C', "`C.c()` returns `'C'`. Defined as `static c() { return 'C'; }`"); +assert.sameValue(C[2](), 'D', "`C[2]()` returns `'D'`. Defined as `static [2]() { return 'D'; }`"); +assert.compareArray( + Object.keys(C), + [] +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/static/method-prototype.js b/js/src/tests/test262/language/computed-property-names/class/static/method-prototype.js new file mode 100644 index 0000000000..517d81ee4b --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/static/method-prototype.js @@ -0,0 +1,16 @@ +// 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.14 +description: > + In a class, computed property names for static + methods that are named "prototype" throw a TypeError +---*/ + +assert.throws(TypeError, function() { + class C { + static ['prototype']() {} + } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/static/method-string-order.js b/js/src/tests/test262/language/computed-property-names/class/static/method-string-order.js new file mode 100644 index 0000000000..7ac43319ab --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/static/method-string-order.js @@ -0,0 +1,70 @@ +// 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'] +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/static/method-string.js b/js/src/tests/test262/language/computed-property-names/class/static/method-string.js new file mode 100644 index 0000000000..0c0fdf8718 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/static/method-string.js @@ -0,0 +1,74 @@ +// 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.sameValue(C.a(), 'A', "`C.a()` returns `'A'`. Defined as `static a() { return 'A'}`"); +assert.sameValue(C.b(), 'B', "`C.b()` returns `'B'`. Defined as `static ['b']() { return 'B'; }`"); +assert.sameValue(C.c(), 'C', "`C.c()` returns `'C'`. Defined as `static c() { return 'C'; }`"); +assert.sameValue(C.d(), 'D', "`C.d()` returns `'D'`. Defined as `static ['d']() { return 'D'; }`"); +assert.compareArray( + Object.keys(C), + [] +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/static/method-symbol-order.js b/js/src/tests/test262/language/computed-property-names/class/static/method-symbol-order.js new file mode 100644 index 0000000000..639013ed38 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/static/method-symbol-order.js @@ -0,0 +1,81 @@ +// 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] +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/static/method-symbol.js b/js/src/tests/test262/language/computed-property-names/class/static/method-symbol.js new file mode 100644 index 0000000000..5811db0a36 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/static/method-symbol.js @@ -0,0 +1,81 @@ +// 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.sameValue(C.a(), 'A', "`C.a()` returns `'A'`. Defined as `static a() { return 'A'; }`"); +assert.sameValue(C[sym1](), 'B', "`C[sym1]()` returns `'B'`. Defined as `static [sym1]() { return 'B'; }`"); +assert.sameValue(C.c(), 'C', "`C.c()` returns `'C'`. Defined as `static c() { return 'C'; }`"); +assert.sameValue(C[sym2](), 'D', "`C[sym2]()` returns `'D'`. Defined as `static [sym2]() { return 'D'; }`"); +assert.compareArray( + Object.keys(C), + [] +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/static/setter-constructor.js b/js/src/tests/test262/language/computed-property-names/class/static/setter-constructor.js new file mode 100644 index 0000000000..fbbb825b14 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/static/setter-constructor.js @@ -0,0 +1,13 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 12.2.5 +description: > + In a class, computed property names for static + setters can be named "constructor" +---*/ +class C { + static set ['constructor'](x) {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/static/setter-prototype.js b/js/src/tests/test262/language/computed-property-names/class/static/setter-prototype.js new file mode 100644 index 0000000000..c18bd5a253 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/static/setter-prototype.js @@ -0,0 +1,16 @@ +// 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.14 +description: > + In a class, computed property names for static + setters that are named "prototype" throw a TypeError +---*/ + +assert.throws(TypeError, function() { + class C { + static set ['prototype'](x) {} + } +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/static/shell.js b/js/src/tests/test262/language/computed-property-names/class/static/shell.js new file mode 100644 index 0000000000..e69de29bb2 -- cgit v1.2.3