node/deps/v8/test/mjsunit/es6/classes-test-super.js
Michaël Zasso e31f0a7d25
deps: update V8 to 7.7.299.4
PR-URL: https://github.com/nodejs/node/pull/28918
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-08-19 09:25:23 +02:00

121 lines
1.9 KiB
JavaScript

// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
(function TestSuperInMethods() {
class B {
method() {
return 1;
}
get x() {
return 2;
}
}
class C extends B {
method() {
assertEquals(2, super.x);
return super.method();
}
}
assertEquals(1, new C().method());
})();
(function TestSuperInGetter() {
class B {
method() {
return 1;
}
get x() {
return 2;
}
}
class C extends B {
get y() {
assertEquals(2, super.x);
return super.method();
}
}
assertEquals(1, new C().y);
})();
(function TestSuperInSetter() {
class B {
method() {
return 1;
}
get x() {
return 2;
}
}
class C extends B {
set y(v) {
assertEquals(3, v);
assertEquals(2, super.x);
assertEquals(1, super.method());
}
}
assertEquals(3, new C().y = 3);
})();
(function TestSuperInStaticMethods() {
class B {
static method() {
return 1;
}
static get x() {
return 2;
}
}
class C extends B {
static method() {
assertEquals(2, super.x);
return super.method();
}
}
assertEquals(1, C.method());
})();
(function TestSuperInStaticGetter() {
class B {
static method() {
return 1;
}
static get x() {
return 2;
}
}
class C extends B {
static get x() {
assertEquals(2, super.x);
return super.method();
}
}
assertEquals(1, C.x);
})();
(function TestSuperInStaticSetter() {
class B {
static method() {
return 1;
}
static get x() {
return 2;
}
}
class C extends B {
static set x(v) {
assertEquals(3, v);
assertEquals(2, super.x);
assertEquals(1, super.method());
}
}
assertEquals(3, C.x = 3);
})();