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/statements/class/subclass/default-constructor-2.js | |
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/statements/class/subclass/default-constructor-2.js')
-rw-r--r-- | js/src/tests/test262/language/statements/class/subclass/default-constructor-2.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/class/subclass/default-constructor-2.js b/js/src/tests/test262/language/statements/class/subclass/default-constructor-2.js new file mode 100644 index 0000000000..e5a984401d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/subclass/default-constructor-2.js @@ -0,0 +1,65 @@ +// 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 +description: > + class default constructor 2 +---*/ +class Base1 { } +assert.throws(TypeError, function() { Base1(); }); + +class Subclass1 extends Base1 { } + +assert.throws(TypeError, function() { Subclass1(); }); + +var s1 = new Subclass1(); +assert.sameValue( + Subclass1.prototype, + Object.getPrototypeOf(s1), + "The value of `Subclass1.prototype` is `Object.getPrototypeOf(s1)`, after executing `var s1 = new Subclass1();`" +); + +class Base2 { + constructor(x, y) { + this.x = x; + this.y = y; + } +} + +class Subclass2 extends Base2 {}; + +var s2 = new Subclass2(1, 2); + +assert.sameValue( + Subclass2.prototype, + Object.getPrototypeOf(s2), + "The value of `Subclass2.prototype` is `Object.getPrototypeOf(s2)`, after executing `var s2 = new Subclass2(1, 2);`" +); +assert.sameValue(s2.x, 1, "The value of `s2.x` is `1`"); +assert.sameValue(s2.y, 2, "The value of `s2.y` is `2`"); + +var f = Subclass2.bind({}, 3, 4); +var s2prime = new f(); +assert.sameValue( + Subclass2.prototype, + Object.getPrototypeOf(s2prime), + "The value of `Subclass2.prototype` is `Object.getPrototypeOf(s2prime)`" +); +assert.sameValue(s2prime.x, 3, "The value of `s2prime.x` is `3`"); +assert.sameValue(s2prime.y, 4, "The value of `s2prime.y` is `4`"); + + +var obj = {}; +class Base3 { + constructor() { + return obj; + } +} + +class Subclass3 extends Base3 {}; + +var s3 = new Subclass3(); +assert.sameValue(s3, obj, "The value of `s3` is `obj`"); + + +reportCompare(0, 0); |