summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/class/definition/this-check-ordering.js
diff options
context:
space:
mode:
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);