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/non262/class/newTargetMethods.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.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/non262/class/newTargetMethods.js')
-rw-r--r-- | js/src/tests/non262/class/newTargetMethods.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/js/src/tests/non262/class/newTargetMethods.js b/js/src/tests/non262/class/newTargetMethods.js new file mode 100644 index 0000000000..2383dc8bd8 --- /dev/null +++ b/js/src/tests/non262/class/newTargetMethods.js @@ -0,0 +1,51 @@ +// Just like newTargetDirectInvoke, except to prove it works in functions +// defined with method syntax as well. Note that methods, getters, and setters +// are not constructible. + +let ol = { + olTest(arg) { assertEq(arg, 4); assertEq(new.target, undefined); }, + get ol() { assertEq(new.target, undefined); }, + set ol(arg) { assertEq(arg, 4); assertEq(new.target, undefined); } +} + +class cl { + constructor() { assertEq(new.target, cl); } + clTest(arg) { assertEq(arg, 4); assertEq(new.target, undefined); } + get cl() { assertEq(new.target, undefined); } + set cl(arg) { assertEq(arg, 4); assertEq(new.target, undefined); } + + static staticclTest(arg) { assertEq(arg, 4); assertEq(new.target, undefined); } + static get staticcl() { assertEq(new.target, undefined); } + static set staticcl(arg) { assertEq(arg, 4); assertEq(new.target, undefined); } +} + +const TEST_ITERATIONS = 150; + +for (let i = 0; i < TEST_ITERATIONS; i++) + ol.olTest(4); +for (let i = 0; i < TEST_ITERATIONS; i++) + ol.ol; +for (let i = 0; i < TEST_ITERATIONS; i++) + ol.ol = 4; + +for (let i = 0; i < TEST_ITERATIONS; i++) + cl.staticclTest(4); +for (let i = 0; i < TEST_ITERATIONS; i++) + cl.staticcl; +for (let i = 0; i < TEST_ITERATIONS; i++) + cl.staticcl = 4; + +for (let i = 0; i < TEST_ITERATIONS; i++) + new cl(); + +let clInst = new cl(); + +for (let i = 0; i < TEST_ITERATIONS; i++) + clInst.clTest(4); +for (let i = 0; i < TEST_ITERATIONS; i++) + clInst.cl; +for (let i = 0; i < TEST_ITERATIONS; i++) + clInst.cl = 4; + +if (typeof reportCompare === "function") + reportCompare(0,0,"OK"); |