summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/class/definition/this-check-ordering.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/language/statements/class/definition/this-check-ordering.js
parentInitial commit. (diff)
downloadfirefox-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/definition/this-check-ordering.js')
-rw-r--r--js/src/tests/test262/language/statements/class/definition/this-check-ordering.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/class/definition/this-check-ordering.js b/js/src/tests/test262/language/statements/class/definition/this-check-ordering.js
new file mode 100644
index 0000000000..c7f867db9b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/class/definition/this-check-ordering.js
@@ -0,0 +1,72 @@
+// 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 this check ordering
+---*/
+var baseCalled = 0;
+class Base {
+ constructor() { baseCalled++ }
+}
+
+var fCalled = 0;
+function f() { fCalled++; return 3; }
+
+class Subclass1 extends Base {
+ constructor() {
+ baseCalled = 0;
+ super();
+ assert.sameValue(baseCalled, 1, "The value of `baseCalled` is `1`");
+ var obj = this;
+
+ var exn = null;
+ baseCalled = 0;
+ fCalled = 0;
+ try {
+ super(f());
+ } catch (e) { exn = e; }
+ assert.sameValue(
+ exn instanceof ReferenceError,
+ true,
+ "The result of `exn instanceof ReferenceError` is `true`"
+ );
+ assert.sameValue(fCalled, 1, "The value of `fCalled` is `1`");
+ assert.sameValue(baseCalled, 1, "The value of `baseCalled` is `1`");
+ assert.sameValue(this, obj, "`this` is `obj`");
+
+ exn = null;
+ baseCalled = 0;
+ fCalled = 0;
+ try {
+ super(super(), f());
+ } catch (e) { exn = e; }
+ assert.sameValue(
+ exn instanceof ReferenceError,
+ true,
+ "The result of `exn instanceof ReferenceError` is `true`"
+ );
+ assert.sameValue(fCalled, 0, "The value of `fCalled` is `0`");
+ assert.sameValue(baseCalled, 1, "The value of `baseCalled` is `1`");
+ assert.sameValue(this, obj, "`this` is `obj`");
+
+ exn = null;
+ baseCalled = 0;
+ fCalled = 0;
+ try {
+ super(f(), super());
+ } catch (e) { exn = e; }
+ assert.sameValue(
+ exn instanceof ReferenceError,
+ true,
+ "The result of `exn instanceof ReferenceError` is `true`"
+ );
+ assert.sameValue(fCalled, 1, "The value of `fCalled` is `1`");
+ assert.sameValue(baseCalled, 1, "The value of `baseCalled` is `1`");
+ assert.sameValue(this, obj, "`this` is `obj`");
+ }
+}
+
+new Subclass1();
+
+reportCompare(0, 0);