diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/language/computed-property-names/class/method | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/computed-property-names/class/method')
13 files changed, 218 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/computed-property-names/class/method/browser.js b/js/src/tests/test262/language/computed-property-names/class/method/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/method/browser.js diff --git a/js/src/tests/test262/language/computed-property-names/class/method/constructor-can-be-generator.js b/js/src/tests/test262/language/computed-property-names/class/method/constructor-can-be-generator.js new file mode 100644 index 0000000000..61e2a36607 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/method/constructor-can-be-generator.js @@ -0,0 +1,12 @@ +// 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.3 +description: > + computed property generator method names can be called "constructor" +---*/ +class C4 { + *['constructor']() {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/method/constructor-can-be-getter.js b/js/src/tests/test262/language/computed-property-names/class/method/constructor-can-be-getter.js new file mode 100644 index 0000000000..aab8a295a8 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/method/constructor-can-be-getter.js @@ -0,0 +1,12 @@ +// 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.3 +description: > + computed property getter names can be called "constructor" +---*/ +class C4 { + get ['constructor']() {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/method/constructor-can-be-setter.js b/js/src/tests/test262/language/computed-property-names/class/method/constructor-can-be-setter.js new file mode 100644 index 0000000000..a44fd56306 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/method/constructor-can-be-setter.js @@ -0,0 +1,12 @@ +// 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.3 +description: > + computed property setter names can be called "constructor" +---*/ +class C4 { + set ['constructor'](_) {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/method/constructor-duplicate-1.js b/js/src/tests/test262/language/computed-property-names/class/method/constructor-duplicate-1.js new file mode 100644 index 0000000000..7e35a35658 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/method/constructor-duplicate-1.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: > + computed property names can be "constructor" +---*/ +class C { + constructor() {} + ['constructor']() {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/method/constructor-duplicate-2.js b/js/src/tests/test262/language/computed-property-names/class/method/constructor-duplicate-2.js new file mode 100644 index 0000000000..9974c81deb --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/method/constructor-duplicate-2.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: > + computed property names can be "constructor" +---*/ +class C { + ['constructor']() {} + constructor() {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/method/constructor-duplicate-3.js b/js/src/tests/test262/language/computed-property-names/class/method/constructor-duplicate-3.js new file mode 100644 index 0000000000..48db7a2bdc --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/method/constructor-duplicate-3.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: > + computed property names can be "constructor" +---*/ +class C { + ['constructor']() {} + ['constructor']() {} +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/method/constructor.js b/js/src/tests/test262/language/computed-property-names/class/method/constructor.js new file mode 100644 index 0000000000..7b45364ff3 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/method/constructor.js @@ -0,0 +1,19 @@ +// 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: > + computed property names can be "constructor" +---*/ +class C { + ['constructor']() { + return 1; + } +} +assert( + C !== C.prototype.constructor, + "The result of `C !== C.prototype.constructor` is `true`" +); +assert.sameValue(new C().constructor(), 1, "`new C().constructor()` returns `1`"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/method/generator.js b/js/src/tests/test262/language/computed-property-names/class/method/generator.js new file mode 100644 index 0000000000..cfd471bc8c --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/method/generator.js @@ -0,0 +1,25 @@ +// 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: > + computed property names can be used as the name of a generator method in a class +includes: [compareArray.js] +---*/ +class C { + *['a']() { + yield 1; + yield 2; + } +} +assert.sameValue( + Object.keys(C.prototype).length, + 0, + "The value of `Object.keys(C.prototype).length` is `0`" +); +assert.compareArray( + Object.getOwnPropertyNames(C.prototype), + ['constructor', 'a'] +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/method/number.js b/js/src/tests/test262/language/computed-property-names/class/method/number.js new file mode 100644 index 0000000000..e9ee5e12bc --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/method/number.js @@ -0,0 +1,32 @@ +// 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: > + computed property class method names can be a number +includes: [compareArray.js] +---*/ + +function ID(x) { + return x; +} + +class C { + a() { return 'A'; } + [1]() { return 'B'; } + c() { return 'C'; } + [ID(2)]() { return 'D'; } +} +assert.sameValue(new C().a(), 'A', "`new C().a()` returns `'A'`, from `a() { return 'A'; }`"); +assert.sameValue(new C()[1](), 'B', "`new C()[1]()` returns `'B'`, from `[1]() { return 'B'; }`"); +assert.sameValue(new C().c(), 'C', "`new C().c()` returns `'C'`, from `c() { return 'C'; }`"); +assert.sameValue(new C()[2](), 'D', "`new C()[2]()` returns `'D'`, from `[ID(2)]() { return 'D'; }`"); + +assert.sameValue(Object.keys(C.prototype).length, 0, "No enum keys from C.prototype"); + +assert.compareArray( + Object.getOwnPropertyNames(C.prototype), + ['1', '2', 'constructor', 'a', 'c'] +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/method/shell.js b/js/src/tests/test262/language/computed-property-names/class/method/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/method/shell.js diff --git a/js/src/tests/test262/language/computed-property-names/class/method/string.js b/js/src/tests/test262/language/computed-property-names/class/method/string.js new file mode 100644 index 0000000000..c152bc6c03 --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/method/string.js @@ -0,0 +1,30 @@ +// 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: > + computed property class method names can be a string +includes: [compareArray.js] +---*/ + +function ID(x) { + return x; +} + +class C { + a() { return 'A'} + ['b']() { return 'B'; } + c() { return 'C'; } + [ID('d')]() { return 'D'; } +} +assert.sameValue(new C().a(), 'A', "`new C().a()` returns `'A'`. Defined as `a() { return 'A'}`"); +assert.sameValue(new C().b(), 'B', "`new C().b()` returns `'B'`. Defined as `['b']() { return 'B'; }`"); +assert.sameValue(new C().c(), 'C', "`new C().c()` returns `'C'`. Defined as `c() { return 'C'; }`"); +assert.sameValue(new C().d(), 'D', "`new C().d()` returns `'D'`. Defined as `[ID('d')]() { return 'D'; }`"); +assert.sameValue(Object.keys(C.prototype).length, 0, "No enum keys from C.prototype"); +assert.compareArray( + Object.getOwnPropertyNames(C.prototype), + ['constructor', 'a', 'b', 'c', 'd'] +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/computed-property-names/class/method/symbol.js b/js/src/tests/test262/language/computed-property-names/class/method/symbol.js new file mode 100644 index 0000000000..07bac0c9cd --- /dev/null +++ b/js/src/tests/test262/language/computed-property-names/class/method/symbol.js @@ -0,0 +1,37 @@ +// 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: > + computed property class method names can be a symbol +includes: [compareArray.js] +features: [Symbol] +---*/ + +function ID(x) { + return x; +} + +var sym1 = Symbol(); +var sym2 = Symbol(); +class C { + a() { return 'A'; } + [sym1]() { return 'B'; } + c() { return 'C'; } + [ID(sym2)]() { return 'D'; } +} +assert.sameValue(new C().a(), 'A', "`new C().a()` returns `'A'`. Defined as `a() { return 'A'; }`"); +assert.sameValue(new C()[sym1](), 'B', "`new C()[sym1]()` returns `'B'`. Defined as `[sym1]() { return 'B'; }`"); +assert.sameValue(new C().c(), 'C', "`new C().c()` returns `'C'`. Defined as `c() { return 'C'; }`"); +assert.sameValue(new C()[sym2](), 'D', "`new C()[sym2]()` returns `'D'`. Defined as `[ID(sym2)]() { return 'D'; }`"); +assert.sameValue(Object.keys(C.prototype).length, 0, "No enum keys from C.prototype"); +assert.compareArray( + Object.getOwnPropertyNames(C.prototype), + ['constructor', 'a', 'c'] +); +assert.compareArray( + Object.getOwnPropertySymbols(C.prototype), + [sym1, sym2] +); + +reportCompare(0, 0); |