2021-08-30 07:08:24 +03:00
|
|
|
use std::{fs::read_to_string, path::PathBuf};
|
|
|
|
|
2021-08-13 13:03:04 +03:00
|
|
|
use swc_common::{chain, Mark};
|
2021-01-05 08:29:52 +03:00
|
|
|
use swc_ecma_parser::Syntax;
|
|
|
|
use swc_ecma_transforms_base::resolver::resolver;
|
2021-08-13 13:03:04 +03:00
|
|
|
use swc_ecma_transforms_compat::{
|
|
|
|
es2015,
|
|
|
|
es2015::{arrow, block_scoping, classes, spread},
|
|
|
|
es2016, es2017, es2018, es2020,
|
|
|
|
es2020::class_properties,
|
|
|
|
};
|
2021-08-30 07:08:24 +03:00
|
|
|
use swc_ecma_transforms_testing::{compare_stdout, test, test_exec, Tester};
|
2020-07-23 20:18:22 +03:00
|
|
|
use swc_ecma_visit::Fold;
|
2019-12-24 16:53:48 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
fn syntax() -> Syntax {
|
2019-01-30 07:05:45 +03:00
|
|
|
Syntax::default()
|
2019-01-24 10:07:09 +03:00
|
|
|
}
|
|
|
|
|
2021-05-08 09:47:20 +03:00
|
|
|
fn tr(tester: &Tester) -> impl Fold {
|
|
|
|
classes(Some(tester.comments.clone()))
|
2019-01-10 12:33:32 +03:00
|
|
|
}
|
|
|
|
|
2021-05-08 09:47:20 +03:00
|
|
|
fn spec_tr(tester: &Tester) -> impl Fold {
|
2019-12-09 15:02:51 +03:00
|
|
|
chain!(
|
|
|
|
resolver(),
|
2021-05-08 09:47:20 +03:00
|
|
|
classes(Some(tester.comments.clone())),
|
2019-12-09 15:02:51 +03:00
|
|
|
spread(spread::Config {
|
|
|
|
..Default::default()
|
|
|
|
}),
|
|
|
|
block_scoping(),
|
|
|
|
)
|
2019-01-24 10:07:09 +03:00
|
|
|
}
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-02-13 10:03:38 +03:00
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-02-13 10:03:38 +03:00
|
|
|
issue_189,
|
|
|
|
r#"
|
|
|
|
class HomePage extends React.Component {}
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
let HomePage = function(_Component) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-02-13 10:03:38 +03:00
|
|
|
_inherits(HomePage, _Component);
|
|
|
|
function HomePage() {
|
|
|
|
_classCallCheck(this, HomePage);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(HomePage).apply(this, arguments));
|
|
|
|
}
|
|
|
|
return HomePage;
|
|
|
|
}(React.Component);
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
2019-01-29 17:56:16 +03:00
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
custom_singleton,
|
|
|
|
r#"
|
2019-01-29 17:56:16 +03:00
|
|
|
let singleton;
|
|
|
|
class Sub extends Foo {
|
|
|
|
constructor() {
|
|
|
|
if (singleton) {
|
|
|
|
return singleton;
|
|
|
|
}
|
|
|
|
singleton = super();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-29 17:56:16 +03:00
|
|
|
let singleton;
|
2019-12-09 15:02:51 +03:00
|
|
|
let Sub = function(Foo) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(Sub, Foo);
|
2019-01-29 17:56:16 +03:00
|
|
|
function Sub() {
|
|
|
|
_classCallCheck(this, Sub);
|
2019-12-09 15:02:51 +03:00
|
|
|
var _this;
|
2019-01-29 17:56:16 +03:00
|
|
|
if (singleton) {
|
|
|
|
return _possibleConstructorReturn(_this, singleton);
|
|
|
|
}
|
|
|
|
singleton = _this = _possibleConstructorReturn(this, _getPrototypeOf(Sub).call(this));
|
|
|
|
return _possibleConstructorReturn(_this);
|
|
|
|
}
|
|
|
|
return Sub;
|
|
|
|
}(Foo);
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
2019-01-30 05:30:09 +03:00
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
custom_native,
|
|
|
|
r#"
|
2019-01-30 05:30:09 +03:00
|
|
|
class List extends Array {}
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2021-09-01 16:11:55 +03:00
|
|
|
let List = function(Array) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(List, Array);
|
2019-01-30 05:30:09 +03:00
|
|
|
function List() {
|
|
|
|
_classCallCheck(this, List);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(List).apply(this, arguments));
|
|
|
|
}
|
|
|
|
return List;
|
|
|
|
}(_wrapNativeSuper(Array));
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
2019-01-29 17:56:16 +03:00
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
custom_nested,
|
|
|
|
r#"
|
2019-01-29 17:56:16 +03:00
|
|
|
class Hello{
|
|
|
|
constructor(){
|
|
|
|
return {
|
|
|
|
toString () {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class Outer extends Hello{
|
|
|
|
constructor(){
|
|
|
|
var _ref = super();
|
|
|
|
class Inner{
|
|
|
|
constructor(){
|
|
|
|
this[_ref] = 'hello';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new Inner();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
expect(new Outer().hello).toBe('hello');
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// spec_constructor_only
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_constructor_only,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Foo {
|
|
|
|
constructor() {
|
2018-11-14 13:40:46 +03:00
|
|
|
|
|
|
|
}
|
2019-01-24 10:07:09 +03:00
|
|
|
}
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Foo = function Foo() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
|
|
|
_classCallCheck(this, Foo);
|
2019-01-24 10:07:09 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
"#
|
2018-11-14 13:40:46 +03:00
|
|
|
);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// extend_builtins_wrap_native_super
|
|
|
|
|
|
|
|
// spec_name_method_collision
|
|
|
|
|
|
|
|
// exec_super
|
|
|
|
|
|
|
|
// regression_5769_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
regression_5769_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Point {
|
|
|
|
getX() {
|
|
|
|
expect(this.x).toBe(3); // C
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
2019-01-24 10:07:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
class ColorPoint extends Point {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.x = 2;
|
|
|
|
super.x = 3;
|
|
|
|
expect(this.x).toBe(3); // A
|
|
|
|
expect(super.x).toBeUndefined(); // B
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
m() {
|
|
|
|
this.getX()
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
2019-01-24 10:07:09 +03:00
|
|
|
}
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
const cp = new ColorPoint();
|
|
|
|
cp.m();
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#
|
2018-11-14 13:40:46 +03:00
|
|
|
);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// spec_this_not_allowed_before_super_in_derived_classes_5_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_this_not_allowed_before_super_in_derived_classes_5_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Bar {}
|
|
|
|
|
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
Foo[this];
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
2019-01-24 10:07:09 +03:00
|
|
|
}
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#
|
2018-11-14 13:40:46 +03:00
|
|
|
);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// spec_statement
|
2018-11-14 13:40:46 +03:00
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
// We don't use function-name pass
|
|
|
|
ignore,
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_statement,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var BaseView = class BaseView {
|
|
|
|
constructor() {
|
|
|
|
this.autoRender = true;
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
2019-01-24 10:07:09 +03:00
|
|
|
}
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
var BaseView = class {
|
|
|
|
constructor() {
|
|
|
|
this.autoRender = true;
|
|
|
|
}
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
var BaseView = class {
|
|
|
|
foo() {
|
|
|
|
this.autoRender = true;
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
2019-01-24 10:07:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var BaseView = function BaseView() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
|
|
|
_classCallCheck(this, BaseView);
|
2019-01-24 10:07:09 +03:00
|
|
|
this.autoRender = true;
|
|
|
|
};
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
var BaseView = function BaseView() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
|
|
|
_classCallCheck(this, BaseView);
|
2019-01-24 10:07:09 +03:00
|
|
|
this.autoRender = true;
|
|
|
|
};
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
var BaseView =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
|
|
|
function BaseView() {
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, BaseView);
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
_createClass(BaseView, [{
|
2018-11-14 13:40:46 +03:00
|
|
|
key: "foo",
|
2019-01-24 10:07:09 +03:00
|
|
|
value: function foo() {
|
|
|
|
this.autoRender = true;
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
|
|
|
}]);
|
2019-01-24 10:07:09 +03:00
|
|
|
return BaseView;
|
|
|
|
}();
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#
|
2018-11-14 13:40:46 +03:00
|
|
|
);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// get_set_set_semantics_getter_defined_on_parent
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_set_semantics_getter_defined_on_parent,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Base {
|
|
|
|
get test() {
|
|
|
|
return 1;
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
2019-01-24 10:07:09 +03:00
|
|
|
};
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
class Obj extends Base {
|
|
|
|
set() {
|
|
|
|
return super.test = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
const obj = new Obj();
|
|
|
|
expect(() => {
|
|
|
|
// this requires helpers to be in file (not external), so they
|
|
|
|
// are in "strict" mode code.
|
|
|
|
obj.set();
|
|
|
|
}).toThrow();
|
|
|
|
expect(Base.prototype.test).toBe(1);
|
|
|
|
expect(Obj.prototype.test).toBe(2);
|
|
|
|
expect(obj.test).toBe(2);
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2018-11-14 13:40:46 +03:00
|
|
|
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
let Base =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
function Base() {
|
|
|
|
_classCallCheck(this, Base);
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
_createClass(Base, [{
|
|
|
|
key: "test",
|
|
|
|
get: function () {
|
|
|
|
return 1;
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
return Base;
|
|
|
|
}();
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
;
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "set",
|
|
|
|
value: function set() {
|
|
|
|
return _set(_getPrototypeOf(Obj.prototype), "test", 3, this, true);
|
|
|
|
}
|
2018-11-14 13:40:46 +03:00
|
|
|
}]);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
return Obj;
|
|
|
|
}(Base);
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(() => {
|
|
|
|
// this requires helpers to be in file (not external), so they
|
|
|
|
// are in "strict" mode code.
|
|
|
|
obj.set();
|
|
|
|
}).toThrow();
|
|
|
|
expect(Base.prototype.test).toBe(1);
|
|
|
|
expect(Obj.prototype.test).toBe(2);
|
|
|
|
expect(obj.test).toBe(2);
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#
|
|
|
|
);
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// spec_derived_constructor_must_call_super
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_derived_constructor_must_call_super,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
2018-11-14 13:40:46 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Foo =
|
|
|
|
/*#__PURE__*/
|
2019-12-09 15:02:51 +03:00
|
|
|
function (Bar) {
|
|
|
|
'use strict';
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
_inherits(Foo, Bar);
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
function Foo() {
|
2019-12-09 15:02:51 +03:00
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
var _this;
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
return _possibleConstructorReturn(_this);
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
return Foo;
|
|
|
|
}(Bar);
|
|
|
|
|
|
|
|
"#
|
2018-11-14 13:40:46 +03:00
|
|
|
);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// get_set_get_semantics_data_defined_on_parent
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_get_semantics_data_defined_on_parent,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Base {
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
2019-01-24 10:07:09 +03:00
|
|
|
Base.prototype.test = 1;
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
get() {
|
|
|
|
return super.test;
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
2019-01-24 10:07:09 +03:00
|
|
|
}
|
|
|
|
Obj.prototype.test = 2;
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.test).toBe(2);
|
|
|
|
expect(obj.get()).toBe(1);
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2018-11-14 13:40:46 +03:00
|
|
|
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
let Base = function Base() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Base);
|
|
|
|
};
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
Base.prototype.test = 1;
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2018-11-14 13:40:46 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
2018-11-14 13:40:46 +03:00
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "get",
|
|
|
|
value: function get() {
|
|
|
|
return _get(_getPrototypeOf(Obj.prototype), "test", this);
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
|
|
|
Obj.prototype.test = 2;
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.test).toBe(2);
|
|
|
|
expect(obj.get()).toBe(1);
|
|
|
|
|
|
|
|
"#
|
2018-11-14 13:40:46 +03:00
|
|
|
);
|
2018-12-22 06:15:04 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// extend_builtins_spec
|
|
|
|
|
|
|
|
// spec_super_reference_before_in_lambda_2
|
|
|
|
|
|
|
|
// regression_8499
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
regression_8499,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
// Pretend that `Reflect.construct` isn't supported.
|
|
|
|
this.Reflect = undefined;
|
|
|
|
|
|
|
|
this.HTMLElement = function() {
|
|
|
|
// Here, `this.HTMLElement` is this function, not the original HTMLElement
|
|
|
|
// constructor. `this.constructor` should be this function too, but isn't.
|
|
|
|
constructor = this.constructor;
|
|
|
|
};
|
|
|
|
|
|
|
|
var constructor;
|
|
|
|
|
|
|
|
class CustomElement extends HTMLElement {};
|
|
|
|
new CustomElement();
|
|
|
|
|
|
|
|
expect(constructor).toBe(CustomElement);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
this.Reflect = undefined;
|
2019-12-09 15:02:51 +03:00
|
|
|
this.HTMLElement = function() {
|
|
|
|
constructor = this.constructor;
|
2019-01-24 10:07:09 +03:00
|
|
|
};
|
|
|
|
var constructor;
|
2021-09-01 16:11:55 +03:00
|
|
|
let CustomElement = function(HTMLElement) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(CustomElement, HTMLElement);
|
2019-12-09 15:02:51 +03:00
|
|
|
function CustomElement() {
|
|
|
|
_classCallCheck(this, CustomElement);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(CustomElement).apply(this, arguments));
|
|
|
|
}
|
|
|
|
return CustomElement;
|
2019-01-24 10:07:09 +03:00
|
|
|
}(_wrapNativeSuper(HTMLElement));
|
|
|
|
;
|
|
|
|
new CustomElement();
|
|
|
|
expect(constructor).toBe(CustomElement);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// regression_5817
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| chain!(tr(t), arrow()),
|
2019-01-30 07:05:45 +03:00
|
|
|
regression_5817,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class A extends B {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.arrow1 = (x) => { return x; };
|
|
|
|
this.arrow2 = (x) => x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-12-09 15:02:51 +03:00
|
|
|
let A = function(B) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(A, B);
|
|
|
|
function A() {
|
|
|
|
_classCallCheck(this, A);
|
|
|
|
var _this;
|
|
|
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(A).call(this));
|
|
|
|
_this.arrow1 = function(x) {
|
|
|
|
return x;
|
|
|
|
};
|
|
|
|
_this.arrow2 = function(x) {
|
|
|
|
return x;
|
|
|
|
};
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
return A;
|
2019-01-24 10:07:09 +03:00
|
|
|
}(B);
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_super_reference_before_in_lambda_3
|
|
|
|
|
|
|
|
// get_set_set_semantics_not_defined_on_parent_setter_on_obj
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_set_semantics_not_defined_on_parent_setter_on_obj,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Base {
|
|
|
|
}
|
|
|
|
|
|
|
|
let value = 2;
|
|
|
|
class Obj extends Base {
|
|
|
|
set test(v) {
|
|
|
|
expect(this).toBe(obj);
|
|
|
|
value = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
set() {
|
|
|
|
return super.test = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBeUndefined();
|
|
|
|
expect(Obj.prototype.test).toBeUndefined();
|
|
|
|
expect(value).toBe(2);
|
|
|
|
expect(obj.test).toBe(3);
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
let Base = function Base() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Base);
|
|
|
|
};
|
|
|
|
|
|
|
|
let value = 2;
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "test",
|
|
|
|
set: function (v) {
|
|
|
|
expect(this).toBe(obj);
|
|
|
|
value = v;
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
key: "set",
|
|
|
|
value: function set() {
|
|
|
|
return _set(_getPrototypeOf(Obj.prototype), "test", 3, this, true);
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBeUndefined();
|
|
|
|
expect(Obj.prototype.test).toBeUndefined();
|
|
|
|
expect(value).toBe(2);
|
|
|
|
expect(obj.test).toBe(3);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_get_semantics_setter_defined_on_parent
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_get_semantics_setter_defined_on_parent,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
2018-12-22 06:15:04 +03:00
|
|
|
class Base {
|
|
|
|
set test(v) {
|
|
|
|
throw new Error("called");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
get() {
|
|
|
|
return super.test;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.test).toBe(2);
|
|
|
|
expect(obj.get()).toBeUndefined();
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
let Base =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
function Base() {
|
|
|
|
_classCallCheck(this, Base);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Base, [{
|
|
|
|
key: "test",
|
|
|
|
set: function (v) {
|
|
|
|
throw new Error("called");
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Base;
|
|
|
|
}();
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "get",
|
|
|
|
value: function get() {
|
|
|
|
return _get(_getPrototypeOf(Obj.prototype), "test", this);
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.test).toBe(2);
|
|
|
|
expect(obj.get()).toBeUndefined();
|
|
|
|
|
2018-12-22 06:15:04 +03:00
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// spec_this_not_allowed_before_super_in_derived_classes_4
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_this_not_allowed_before_super_in_derived_classes_4,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
const fn = () => this;
|
|
|
|
super();
|
|
|
|
fn();
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-12-09 15:02:51 +03:00
|
|
|
var Foo = function(Bar) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(Foo, Bar);
|
|
|
|
function Foo() {
|
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
var _this;
|
|
|
|
var fn = ()=>_assertThisInitialized(_this)
|
|
|
|
;
|
|
|
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this));
|
|
|
|
fn();
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
return Foo;
|
2019-01-24 10:07:09 +03:00
|
|
|
}(Bar);
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_calling_super_properties
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_calling_super_properties,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Test extends Foo {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
super.test.whatever();
|
|
|
|
super.test();
|
|
|
|
}
|
|
|
|
|
|
|
|
static test() {
|
|
|
|
return super.wow();
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Test =
|
|
|
|
/*#__PURE__*/
|
2019-12-09 15:02:51 +03:00
|
|
|
function (Foo) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(Test, Foo);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Test() {
|
|
|
|
_classCallCheck(this, Test);
|
|
|
|
var _this = _possibleConstructorReturn(this, _getPrototypeOf(Test).call(this));
|
|
|
|
_get(_getPrototypeOf(Test.prototype), "test", _assertThisInitialized(_this)).whatever();
|
|
|
|
_get(_getPrototypeOf(Test.prototype), "test", _assertThisInitialized(_this)).call(_this);
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Test, null, [{
|
|
|
|
key: "test",
|
|
|
|
value: function test() {
|
|
|
|
return _get(_getPrototypeOf(Test), "wow", this).call(this);
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
return Test;
|
|
|
|
}(Foo);
|
|
|
|
|
|
|
|
"#
|
2018-12-22 06:15:04 +03:00
|
|
|
);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// spec_super_reference_before_bare_super
|
|
|
|
|
|
|
|
// spec_super_reference_before_bare_super_inline
|
|
|
|
|
|
|
|
// spec_instance_getter_and_setter
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_instance_getter_and_setter,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Test {
|
2018-12-22 06:15:04 +03:00
|
|
|
get test() {
|
2019-01-24 10:07:09 +03:00
|
|
|
return 5 + 5;
|
|
|
|
}
|
|
|
|
set test(val) {
|
|
|
|
this._test = val;
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Test =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Test() {
|
|
|
|
_classCallCheck(this, Test);
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
_createClass(Test, [{
|
|
|
|
key: "test",
|
|
|
|
get: function () {
|
|
|
|
return 5 + 5;
|
|
|
|
},
|
|
|
|
set: function (val) {
|
|
|
|
this._test = val;
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
return Test;
|
|
|
|
}();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// regression_2941
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
// Module
|
|
|
|
ignore,
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
regression_2941,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
export default class {}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
value: true
|
|
|
|
});
|
|
|
|
exports.default = void 0;
|
|
|
|
|
|
|
|
var _default = function _default() {
|
|
|
|
_classCallCheck(this, _default);
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.default = _default;
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
// regression_t2494
|
2019-01-24 10:07:09 +03:00
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
regression_t2494,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var x = {
|
|
|
|
Foo: class extends Foo {}
|
|
|
|
};
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var x = {
|
|
|
|
Foo:
|
|
|
|
/*#__PURE__*/
|
2019-12-09 15:02:51 +03:00
|
|
|
function (Foo) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(_class, Foo);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function _class() {
|
|
|
|
_classCallCheck(this, _class);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(_class).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
return _class;
|
|
|
|
}(Foo)
|
|
|
|
};
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_inferred_expression_name
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_inferred_expression_name,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var o = { foo: class foo {} };
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var o = {
|
|
|
|
foo: function foo() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_classCallCheck(this, foo);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// regression_8499_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
// Wrong test (babel + jest fails)
|
|
|
|
ignore,
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
regression_8499_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
// Pretend that `Reflect.construct` isn't supported.
|
|
|
|
this.Reflect = undefined;
|
|
|
|
|
|
|
|
this.HTMLElement = function() {
|
|
|
|
// Here, `this.HTMLElement` is this function, not the original HTMLElement
|
|
|
|
// constructor. `this.constructor` should be this function too, but isn't.
|
|
|
|
constructor = this.constructor;
|
|
|
|
};
|
|
|
|
|
|
|
|
var constructor;
|
|
|
|
|
|
|
|
class CustomElement extends HTMLElement {};
|
|
|
|
new CustomElement();
|
|
|
|
|
|
|
|
expect(constructor).toBe(CustomElement);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_default_super
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_default_super,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Test {
|
|
|
|
constructor() {
|
|
|
|
return super.constructor;
|
|
|
|
}
|
|
|
|
|
|
|
|
static test() {
|
|
|
|
return super.constructor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Instances
|
|
|
|
expect(Object.getPrototypeOf(Test.prototype)).toBe(Object.prototype);
|
|
|
|
expect(new Test()).toBe(Object);
|
|
|
|
|
|
|
|
// Static
|
|
|
|
expect(Object.getPrototypeOf(Test)).toBe(Function.prototype);
|
|
|
|
expect(Test.test()).toBe(Function);
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Test =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Test() {
|
|
|
|
_classCallCheck(this, Test);
|
|
|
|
return _get(_getPrototypeOf(Test.prototype), "constructor", this);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Test, null, [{
|
|
|
|
key: "test",
|
|
|
|
value: function test() {
|
|
|
|
return _get(_getPrototypeOf(Test), "constructor", this);
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
return Test;
|
|
|
|
}(); // Instances
|
|
|
|
|
|
|
|
|
|
|
|
expect(Object.getPrototypeOf(Test.prototype)).toBe(Object.prototype);
|
|
|
|
expect(new Test()).toBe(Object); // Static
|
|
|
|
|
|
|
|
expect(Object.getPrototypeOf(Test)).toBe(Function.prototype);
|
|
|
|
expect(Test.test()).toBe(Function);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_default_super
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_default_super_constructor,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Test {
|
|
|
|
constructor() {
|
|
|
|
return super.constructor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Test = function Test() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Test);
|
|
|
|
return _get(_getPrototypeOf(Test.prototype), "constructor", this);
|
|
|
|
}
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_get_semantics_getter_defined_on_parent
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_get_semantics_getter_defined_on_parent,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Base {
|
|
|
|
get test() {
|
|
|
|
expect(this).toBe(obj);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
get() {
|
|
|
|
return super.test;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.test).toBe(2);
|
|
|
|
expect(obj.get()).toBe(1);
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
let Base =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
function Base() {
|
|
|
|
_classCallCheck(this, Base);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Base, [{
|
|
|
|
key: "test",
|
|
|
|
get: function () {
|
|
|
|
expect(this).toBe(obj);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Base;
|
|
|
|
}();
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "get",
|
|
|
|
value: function get() {
|
|
|
|
return _get(_getPrototypeOf(Obj.prototype), "test", this);
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.test).toBe(2);
|
|
|
|
expect(obj.get()).toBe(1);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec
|
|
|
|
|
|
|
|
// spec_this_not_allowed_before_super_in_derived_classes
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_this_not_allowed_before_super_in_derived_classes,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
this.foo = "bar";
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-12-09 15:02:51 +03:00
|
|
|
var Foo = function(Bar) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(Foo, Bar);
|
|
|
|
function Foo() {
|
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
var _this;
|
|
|
|
_this.foo = 'bar';
|
|
|
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this));
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
return Foo;
|
2019-01-24 10:07:09 +03:00
|
|
|
}(Bar);
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_call_semantics_getter_defined_on_parent
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_call_semantics_getter_defined_on_parent,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Base {
|
|
|
|
get test() {
|
|
|
|
expect(this).toBe(obj);
|
|
|
|
return function(...args) {
|
|
|
|
expect(this).toBe(obj);
|
|
|
|
expect(args).toEqual([1, 2, 3]);
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
call() {
|
|
|
|
super.test(1, 2, 3);
|
|
|
|
super.test(1, ...[2, 3]);
|
|
|
|
super.test(...[1, 2, 3]);
|
|
|
|
return super.test(...arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
test() {
|
|
|
|
throw new Error("called");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.call(1, 2, 3)).toBe(1);
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
let Base =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
function Base() {
|
|
|
|
_classCallCheck(this, Base);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Base, [{
|
|
|
|
key: "test",
|
|
|
|
get: function () {
|
|
|
|
expect(this).toBe(obj);
|
|
|
|
return function (...args) {
|
|
|
|
expect(this).toBe(obj);
|
|
|
|
expect(args).toEqual([1, 2, 3]);
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Base;
|
|
|
|
}();
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "call",
|
|
|
|
value: function call() {
|
|
|
|
_get(_getPrototypeOf(Obj.prototype), "test", this).call(this, 1, 2, 3);
|
|
|
|
|
|
|
|
_get(_getPrototypeOf(Obj.prototype), "test", this).call(this, 1, ...[2, 3]);
|
|
|
|
|
|
|
|
_get(_getPrototypeOf(Obj.prototype), "test", this).call(this, ...[1, 2, 3]);
|
|
|
|
|
|
|
|
return _get(_getPrototypeOf(Obj.prototype), "test", this).apply(this, arguments);
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
key: "test",
|
|
|
|
value: function test() {
|
|
|
|
throw new Error("called");
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.call(1, 2, 3)).toBe(1);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_derived_constructor_must_call_super_4_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_derived_constructor_must_call_super_4_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Bar {}
|
|
|
|
|
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
const fn = () => super();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// exec_retain_no_call_on
|
|
|
|
|
|
|
|
// spec_export_default
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_export_default,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
export default class Foo {}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Foo = function Foo() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
};
|
|
|
|
|
|
|
|
export { Foo as default };
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_call_semantics_data_defined_on_parent
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_call_semantics_data_defined_on_parent,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Base {
|
|
|
|
test(...args) {
|
|
|
|
expect(this).toBe(obj);
|
|
|
|
expect(args).toEqual([1, 2, 3]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
call() {
|
|
|
|
super.test(1, 2, 3);
|
|
|
|
super.test(1, ...[2, 3]);
|
|
|
|
super.test(...[1, 2, 3]);
|
|
|
|
return super.test(...arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
test() {
|
|
|
|
throw new Error("called");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.call(1, 2, 3)).toBe(1);
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
let Base =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
function Base() {
|
|
|
|
_classCallCheck(this, Base);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Base, [{
|
|
|
|
key: "test",
|
|
|
|
value: function test(...args) {
|
|
|
|
expect(this).toBe(obj);
|
|
|
|
expect(args).toEqual([1, 2, 3]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Base;
|
|
|
|
}();
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "call",
|
|
|
|
value: function call() {
|
|
|
|
_get(_getPrototypeOf(Obj.prototype), "test", this).call(this, 1, 2, 3);
|
|
|
|
|
|
|
|
_get(_getPrototypeOf(Obj.prototype), "test", this).call(this, 1, ...[2, 3]);
|
|
|
|
|
|
|
|
_get(_getPrototypeOf(Obj.prototype), "test", this).call(this, ...[1, 2, 3]);
|
|
|
|
|
|
|
|
return _get(_getPrototypeOf(Obj.prototype), "test", this).apply(this, arguments);
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
key: "test",
|
|
|
|
value: function test() {
|
|
|
|
throw new Error("called");
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.call(1, 2, 3)).toBe(1);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_static
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_static,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class A {
|
|
|
|
static a() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static get b(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static set b(b){
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var A =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function A() {
|
|
|
|
_classCallCheck(this, A);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(A, null, [{
|
|
|
|
key: "a",
|
|
|
|
value: function a() {}
|
|
|
|
}, {
|
|
|
|
key: "b",
|
|
|
|
get: function () {},
|
|
|
|
set: function (b) {}
|
|
|
|
}]);
|
|
|
|
return A;
|
|
|
|
}();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
// regression_t6755
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
// get_set_memoized_update
|
2019-10-19 06:21:56 +03:00
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-10-19 06:21:56 +03:00
|
|
|
get_set_memoized_update,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Base {}
|
|
|
|
Object.defineProperty(Base.prototype, 0, {
|
|
|
|
value: 0,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
Object.defineProperty(Base.prototype, 1, {
|
|
|
|
value: 1,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
let i = 0;
|
|
|
|
const proper = {
|
|
|
|
get prop() {
|
|
|
|
return i++;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
update() {
|
|
|
|
super[proper.prop]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
update2() {
|
|
|
|
super[i]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
|
|
|
|
obj.update();
|
|
|
|
expect(i).toBe(1);
|
|
|
|
expect(obj[0]).toBe(1);
|
|
|
|
expect(obj[1]).toBe(1);
|
|
|
|
|
|
|
|
obj.update2();
|
|
|
|
expect(i).toBe(1);
|
|
|
|
expect(obj[0]).toBe(1);
|
|
|
|
expect(obj[1]).toBe(2);
|
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
let Base = function Base() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Base);
|
|
|
|
};
|
|
|
|
|
|
|
|
Object.defineProperty(Base.prototype, 0, {
|
|
|
|
value: 0,
|
|
|
|
writable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
Object.defineProperty(Base.prototype, 1, {
|
|
|
|
value: 1,
|
|
|
|
writable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
let i = 0;
|
|
|
|
const proper = {
|
|
|
|
get prop() {
|
|
|
|
return i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "update",
|
|
|
|
value: function update() {
|
|
|
|
var _ref, _superRef;
|
|
|
|
|
|
|
|
_set(_getPrototypeOf(Obj.prototype), _ref = proper.prop, (_superRef = +_get(_getPrototypeOf(Obj.prototype), _ref, this)) + 1, this, true), _superRef;
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
key: "update2",
|
|
|
|
value: function update2() {
|
|
|
|
var _ref, _superRef;
|
|
|
|
|
|
|
|
_set(_getPrototypeOf(Obj.prototype), _ref = i, (_superRef = +_get(_getPrototypeOf(Obj.prototype), _ref, this)) + 1, this, true), _superRef;
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
obj.update();
|
|
|
|
expect(i).toBe(1);
|
|
|
|
expect(obj[0]).toBe(1);
|
|
|
|
expect(obj[1]).toBe(1);
|
|
|
|
obj.update2();
|
|
|
|
expect(i).toBe(1);
|
|
|
|
expect(obj[0]).toBe(1);
|
|
|
|
expect(obj[1]).toBe(2);
|
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#
|
|
|
|
);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
// spec_nested_class_super_property_in_key
|
2019-10-19 06:21:56 +03:00
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-10-19 06:21:56 +03:00
|
|
|
spec_nested_class_super_property_in_key,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Hello {
|
|
|
|
toString() {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Outer extends Hello {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
class Inner {
|
|
|
|
[super.toString()]() {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Inner();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(new Outer().hello()).toBe('hello');
|
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
var Hello =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
function Hello() {
|
|
|
|
_classCallCheck(this, Hello);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Hello, [{
|
|
|
|
key: "toString",
|
|
|
|
value: function toString() {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
return Hello;
|
|
|
|
}();
|
|
|
|
|
2021-09-01 16:11:55 +03:00
|
|
|
var Outer = function (Hello) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Outer, Hello);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Outer() {
|
|
|
|
_classCallCheck(this, Outer);
|
|
|
|
var _this = _possibleConstructorReturn(this, _getPrototypeOf(Outer).call(this));
|
|
|
|
|
|
|
|
var Inner =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
|
|
|
function Inner() {
|
|
|
|
_classCallCheck(this, Inner);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Inner, [{
|
|
|
|
key: _get(_getPrototypeOf(Outer.prototype), "toString", _assertThisInitialized(_this)).call(_this),
|
|
|
|
value: function () {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
return Inner;
|
|
|
|
}();
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(_this, new Inner());
|
|
|
|
}
|
|
|
|
|
|
|
|
return Outer;
|
|
|
|
}(Hello);
|
|
|
|
|
|
|
|
expect(new Outer().hello()).toBe('hello');
|
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#
|
|
|
|
);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
// spec_super_reference_in_prop_exression
|
2019-10-19 06:21:56 +03:00
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-10-19 06:21:56 +03:00
|
|
|
spec_super_reference_in_prop_exression,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
super[super().method]();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
2019-12-09 15:02:51 +03:00
|
|
|
var Foo = function(Bar) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(Foo, Bar);
|
|
|
|
function Foo() {
|
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
var _this;
|
|
|
|
_get(_getPrototypeOf(Foo.prototype), (_this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this))).method, _assertThisInitialized(_this)).call(_this);
|
|
|
|
return _possibleConstructorReturn(_this);
|
|
|
|
}
|
|
|
|
return Foo;
|
2019-01-24 10:07:09 +03:00
|
|
|
}(Bar);
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#
|
|
|
|
);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
// spec_super_reference_before_in_lambda_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_super_reference_before_in_lambda_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Bar {
|
|
|
|
test() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
const t = () => super.test()
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
new Foo();
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_nested_class_super_call_in_key_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_nested_class_super_call_in_key_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Hello {
|
|
|
|
constructor() {
|
|
|
|
return {
|
|
|
|
toString() {
|
|
|
|
return 'hello';
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Outer extends Hello {
|
|
|
|
constructor() {
|
|
|
|
class Inner {
|
|
|
|
[super()]() {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Inner();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(new Outer().hello()).toBe('hello');
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_this_not_allowed_before_super_in_derived_classes_4_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_this_not_allowed_before_super_in_derived_classes_4_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Bar {}
|
|
|
|
|
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
const fn = () => this;
|
|
|
|
super();
|
|
|
|
fn();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
new Foo();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_this_not_allowed_before_super_in_derived_classes_2
|
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-24 10:07:09 +03:00
|
|
|
spec_this_not_allowed_before_super_in_derived_classes_2,
|
|
|
|
r#"
|
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
super(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
var Foo =
|
|
|
|
/*#__PURE__*/
|
2019-12-09 15:02:51 +03:00
|
|
|
function (Bar) {
|
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
_inherits(Foo, Bar);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Foo() {
|
|
|
|
_classCallCheck(this, Foo);
|
2019-12-09 15:02:51 +03:00
|
|
|
var _this;
|
2019-01-24 10:07:09 +03:00
|
|
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this, _assertThisInitialized(_this)));
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Foo;
|
|
|
|
}(Bar);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_accessing_super_properties
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_accessing_super_properties,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Test extends Foo {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
super.test;
|
|
|
|
super.test.whatever;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Test =
|
|
|
|
/*#__PURE__*/
|
2019-12-09 15:02:51 +03:00
|
|
|
function (Foo) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(Test, Foo);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Test() {
|
|
|
|
_classCallCheck(this, Test);
|
|
|
|
var _this = _possibleConstructorReturn(this, _getPrototypeOf(Test).call(this));
|
|
|
|
_get(_getPrototypeOf(Test.prototype), "test", _assertThisInitialized(_this));
|
|
|
|
_get(_getPrototypeOf(Test.prototype), "test", _assertThisInitialized(_this)).whatever;
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Test;
|
|
|
|
}(Foo);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// exec_shadow
|
|
|
|
|
|
|
|
// spec_computed_methods
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_computed_methods,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Foo {
|
|
|
|
foo() {}
|
|
|
|
"foo"() {}
|
|
|
|
[bar]() {}
|
|
|
|
[bar + "foo"]() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Foo =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
|
|
|
function Foo() {
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Foo, [{
|
|
|
|
key: "foo",
|
|
|
|
value: function foo() {}
|
|
|
|
}, {
|
|
|
|
key: "foo",
|
2019-12-09 15:02:51 +03:00
|
|
|
value: function foo() {}
|
2019-01-24 10:07:09 +03:00
|
|
|
}, {
|
|
|
|
key: bar,
|
|
|
|
value: function() {}
|
|
|
|
}, {
|
|
|
|
key: bar + "foo",
|
|
|
|
value: function () {}
|
|
|
|
}]);
|
|
|
|
return Foo;
|
|
|
|
}();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// extend_builtins_shadowed
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
// get_set_set_semantics_data_defined_on_parent
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
get_set_set_semantics_data_defined_on_parent,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
class Base {
|
2019-01-24 10:07:09 +03:00
|
|
|
}
|
2019-12-09 15:02:51 +03:00
|
|
|
Object.defineProperty(Base.prototype, 'test', {
|
|
|
|
value: 1,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
set() {
|
|
|
|
return super.test = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
2019-12-09 15:02:51 +03:00
|
|
|
expect(Base.prototype.test).toBe(1);
|
2019-01-24 10:07:09 +03:00
|
|
|
expect(Obj.prototype.test).toBe(2);
|
|
|
|
expect(obj.test).toBe(3);
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
let Base = function Base() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Base);
|
|
|
|
};
|
|
|
|
|
|
|
|
Object.defineProperty(Base.prototype, 'test', {
|
|
|
|
value: 1,
|
|
|
|
writable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "set",
|
|
|
|
value: function set() {
|
|
|
|
return _set(_getPrototypeOf(Obj.prototype), "test", 3, this, true);
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBe(1);
|
|
|
|
expect(Obj.prototype.test).toBe(2);
|
|
|
|
expect(obj.test).toBe(3);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_set_semantics_not_defined_on_parent_getter_on_obj
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_set_semantics_not_defined_on_parent_getter_on_obj,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Base {
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
get test() { }
|
|
|
|
|
|
|
|
set() {
|
|
|
|
return super.test = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBeUndefined();
|
|
|
|
expect(Obj.prototype.test).toBeUndefined();
|
|
|
|
expect(obj.test).toBe(3);
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
let Base = function Base() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Base);
|
|
|
|
};
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "test",
|
|
|
|
get: function () {}
|
|
|
|
}, {
|
|
|
|
key: "set",
|
|
|
|
value: function set() {
|
|
|
|
return _set(_getPrototypeOf(Obj.prototype), "test", 3, this, true);
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBeUndefined();
|
|
|
|
expect(Obj.prototype.test).toBeUndefined();
|
|
|
|
expect(obj.test).toBe(3);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set
|
|
|
|
|
|
|
|
// spec_returning_from_derived_constructor_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_returning_from_derived_constructor_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Foo {
|
|
|
|
constructor() {
|
|
|
|
return { x: 1 };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(new Foo().x).toBe(1);
|
|
|
|
|
|
|
|
class Bar extends Foo {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(new Bar().x).toBe(1);
|
|
|
|
|
|
|
|
class Bar2 extends Foo {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
expect(this.x).toBe(1);
|
|
|
|
return { x: 2 };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(new Bar2().x).toBe(2);
|
|
|
|
|
|
|
|
|
|
|
|
let singleton;
|
|
|
|
class Sub extends Foo {
|
|
|
|
constructor() {
|
|
|
|
if (singleton) {
|
|
|
|
return singleton;
|
|
|
|
}
|
|
|
|
singleton = super();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let instance = new Sub;
|
|
|
|
expect(instance).toBe(singleton);
|
|
|
|
|
|
|
|
instance = new Sub;
|
|
|
|
expect(instance).toBe(singleton);
|
|
|
|
|
|
|
|
class Null extends Foo {
|
|
|
|
constructor() {
|
|
|
|
if (false) {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(() => {
|
|
|
|
new Null();
|
|
|
|
}).toThrow("this");
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// regression_2694
|
|
|
|
|
|
|
|
// regression_5769
|
2019-10-19 06:21:56 +03:00
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-10-19 06:21:56 +03:00
|
|
|
regression_5769,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Point {
|
|
|
|
getX() {
|
|
|
|
expect(this.x).toBe(3); // C
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ColorPoint extends Point {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.x = 2;
|
|
|
|
super.x = 3;
|
|
|
|
expect(this.x).toBe(3); // A
|
|
|
|
expect(super.x).toBeUndefined(); // B
|
|
|
|
}
|
|
|
|
|
|
|
|
m() {
|
|
|
|
this.getX();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const cp = new ColorPoint();
|
|
|
|
cp.m();
|
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
let Point =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
|
|
|
function Point() {
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Point);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Point, [{
|
|
|
|
key: "getX",
|
|
|
|
value: function getX() {
|
|
|
|
expect(this.x).toBe(3); // C
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
return Point;
|
|
|
|
}();
|
|
|
|
|
|
|
|
let ColorPoint =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Point) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(ColorPoint, Point);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function ColorPoint() {
|
2019-12-09 15:02:51 +03:00
|
|
|
_classCallCheck(this, ColorPoint);
|
2019-01-24 10:07:09 +03:00
|
|
|
var _this;
|
|
|
|
|
|
|
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(ColorPoint).call(this));
|
|
|
|
_this.x = 2;
|
|
|
|
_set(_getPrototypeOf(ColorPoint.prototype), 'x', 3, this, true);
|
|
|
|
expect(_this.x).toBe(3); // A
|
|
|
|
|
|
|
|
expect(_get(_getPrototypeOf(ColorPoint.prototype), "x", _assertThisInitialized(_this))).toBeUndefined(); // B
|
|
|
|
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(ColorPoint, [{
|
|
|
|
key: "m",
|
|
|
|
value: function m() {
|
|
|
|
this.getX();
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
return ColorPoint;
|
|
|
|
}(Point);
|
|
|
|
|
|
|
|
const cp = new ColorPoint();
|
|
|
|
cp.m();
|
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#
|
|
|
|
);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
// spec_super_function_fallback
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_super_function_fallback,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Test {
|
|
|
|
constructor() {
|
|
|
|
super.hasOwnProperty("test");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Test = function Test() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_classCallCheck(this, Test);
|
|
|
|
_get(_getPrototypeOf(Test.prototype), "hasOwnProperty", this).call(this, "test");
|
|
|
|
};
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
// regression_t7537
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
// regression_3028
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
// Module
|
|
|
|
ignore,
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
regression_3028,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class b {
|
|
|
|
}
|
|
|
|
|
|
|
|
class a1 extends b {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.x = () => this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class a2 extends b {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.x = () => this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
value: true
|
|
|
|
});
|
|
|
|
exports.default = void 0;
|
|
|
|
|
|
|
|
var b = function b() {
|
|
|
|
_classCallCheck(this, b);
|
|
|
|
};
|
|
|
|
|
|
|
|
var a1 =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function (_b) {
|
|
|
|
_inherits(a1, _b);
|
|
|
|
|
|
|
|
function a1() {
|
|
|
|
var _this;
|
|
|
|
|
|
|
|
_classCallCheck(this, a1);
|
|
|
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(a1).call(this));
|
|
|
|
|
|
|
|
_this.x = function () {
|
|
|
|
return _assertThisInitialized(_this);
|
|
|
|
};
|
|
|
|
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return a1;
|
|
|
|
}(b);
|
|
|
|
|
|
|
|
var a2 =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function (_b2) {
|
|
|
|
_inherits(a2, _b2);
|
|
|
|
|
|
|
|
function a2() {
|
|
|
|
var _this2;
|
|
|
|
|
|
|
|
_classCallCheck(this, a2);
|
|
|
|
_this2 = _possibleConstructorReturn(this, _getPrototypeOf(a2).call(this));
|
|
|
|
|
|
|
|
_this2.x = function () {
|
|
|
|
return _assertThisInitialized(_assertThisInitialized(_this2));
|
|
|
|
};
|
|
|
|
|
|
|
|
return _this2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return a2;
|
|
|
|
}(b);
|
|
|
|
|
|
|
|
exports.default = a2;
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_super_illegal_non_constructor_call
|
|
|
|
|
|
|
|
// spec_instance_setter
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_instance_setter,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Test {
|
|
|
|
set test(val) {
|
|
|
|
this._test = val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Test =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Test() {
|
|
|
|
_classCallCheck(this, Test);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Test, [{
|
|
|
|
key: "test",
|
|
|
|
set: function (val) {
|
|
|
|
this._test = val;
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
return Test;
|
|
|
|
}();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_nested_object_super_call_in_key
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_nested_object_super_call_in_key,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Hello {
|
|
|
|
constructor() {
|
|
|
|
return {
|
|
|
|
toString() {
|
|
|
|
return 'hello';
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Outer extends Hello {
|
|
|
|
constructor() {
|
|
|
|
const Inner = {
|
|
|
|
[super()]() {
|
|
|
|
return 'hello';
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return Inner;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(new Outer().hello()).toBe('hello');
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
var Hello = function Hello() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Hello);
|
|
|
|
return {
|
|
|
|
toString() {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-09-01 16:11:55 +03:00
|
|
|
var Outer = function (Hello) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Outer, Hello);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Outer() {
|
2019-12-09 15:02:51 +03:00
|
|
|
_classCallCheck(this, Outer);
|
2019-01-24 10:07:09 +03:00
|
|
|
var _this;
|
|
|
|
|
|
|
|
var Inner = {
|
|
|
|
[_this = _possibleConstructorReturn(this, _getPrototypeOf(Outer).call(this))]() {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
return _possibleConstructorReturn(_this, Inner);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Outer;
|
|
|
|
}(Hello);
|
|
|
|
|
|
|
|
expect(new Outer().hello()).toBe('hello');
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_set_semantics_not_defined_on_parent_not_on_obj
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_set_semantics_not_defined_on_parent_not_on_obj,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Base {
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
set() {
|
|
|
|
return super.test = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBeUndefined();
|
|
|
|
expect(Obj.prototype.test).toBeUndefined();
|
|
|
|
expect(obj.test).toBe(3);
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
let Base = function Base() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Base);
|
|
|
|
};
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "set",
|
|
|
|
value: function set() {
|
|
|
|
return _set(_getPrototypeOf(Obj.prototype), "test", 3, this, true);
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBeUndefined();
|
|
|
|
expect(Obj.prototype.test).toBeUndefined();
|
|
|
|
expect(obj.test).toBe(3);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_derived_constructor_no_super_return_falsey
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_derived_constructor_no_super_return_falsey,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Child extends Base {
|
|
|
|
constructor(){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-12-09 15:02:51 +03:00
|
|
|
var Child = function(Base) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(Child, Base);
|
|
|
|
function Child() {
|
|
|
|
_classCallCheck(this, Child);
|
|
|
|
var _this;
|
|
|
|
return _possibleConstructorReturn(_this, false);
|
|
|
|
}
|
|
|
|
return Child;
|
2019-01-24 10:07:09 +03:00
|
|
|
}(Base);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_this_not_allowed_before_super_in_derived_classes_5
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_this_not_allowed_before_super_in_derived_classes_5,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
Foo[this];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Foo =
|
|
|
|
/*#__PURE__*/
|
2019-12-09 15:02:51 +03:00
|
|
|
function (Bar) {
|
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
_inherits(Foo, Bar);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Foo() {
|
|
|
|
_classCallCheck(this, Foo);
|
2019-12-09 15:02:51 +03:00
|
|
|
var _this;
|
2019-01-24 10:07:09 +03:00
|
|
|
Foo[_assertThisInitialized(_this)];
|
|
|
|
return _possibleConstructorReturn(_this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Foo;
|
|
|
|
}(Bar);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// exec_super_change
|
|
|
|
|
|
|
|
// spec_constructor
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_constructor,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Test {
|
|
|
|
constructor() {
|
|
|
|
this.state = "test";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.state = "test";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ConstructorScoping {
|
|
|
|
constructor(){
|
|
|
|
let bar;
|
|
|
|
{
|
|
|
|
let bar;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Test = function Test() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_classCallCheck(this, Test);
|
|
|
|
this.state = "test";
|
|
|
|
};
|
|
|
|
|
|
|
|
var Foo =
|
|
|
|
/*#__PURE__*/
|
2019-12-09 15:02:51 +03:00
|
|
|
function (Bar) {
|
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
_inherits(Foo, Bar);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Foo() {
|
|
|
|
_classCallCheck(this, Foo);
|
2019-12-09 15:02:51 +03:00
|
|
|
var _this;
|
2019-01-24 10:07:09 +03:00
|
|
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this));
|
|
|
|
_this.state = "test";
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Foo;
|
|
|
|
}(Bar);
|
|
|
|
|
|
|
|
var ConstructorScoping = function ConstructorScoping() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_classCallCheck(this, ConstructorScoping);
|
|
|
|
var bar;
|
|
|
|
{
|
2021-09-01 16:11:55 +03:00
|
|
|
var bar;
|
2019-01-24 10:07:09 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_preserves_directives
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_preserves_directives,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class MyCtrl {
|
|
|
|
constructor(a) {
|
|
|
|
"any directive prologue";
|
|
|
|
foo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyCtrl2 {
|
|
|
|
constructor(a) {
|
|
|
|
"a";
|
|
|
|
"b";
|
|
|
|
foo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyCtrl3 {
|
|
|
|
constructor(a) {
|
|
|
|
"a";
|
|
|
|
foo;
|
|
|
|
"b";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var MyCtrl = function MyCtrl(a) {
|
|
|
|
"any directive prologue";
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_classCallCheck(this, MyCtrl);
|
|
|
|
foo;
|
|
|
|
};
|
|
|
|
|
|
|
|
var MyCtrl2 = function MyCtrl2(a) {
|
|
|
|
"a";
|
|
|
|
"b";
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_classCallCheck(this, MyCtrl2);
|
|
|
|
foo;
|
|
|
|
};
|
|
|
|
|
|
|
|
var MyCtrl3 = function MyCtrl3(a) {
|
|
|
|
"a";
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_classCallCheck(this, MyCtrl3);
|
|
|
|
foo;
|
|
|
|
"b";
|
|
|
|
};
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_super_reference_before_in_lambda
|
|
|
|
|
|
|
|
// spec_derived_constructor_no_super_return_object
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_derived_constructor_no_super_return_object,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Child extends Base {
|
|
|
|
constructor(){
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-12-09 15:02:51 +03:00
|
|
|
var Child = function(Base) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(Child, Base);
|
|
|
|
function Child() {
|
|
|
|
_classCallCheck(this, Child);
|
|
|
|
var _this;
|
|
|
|
return _possibleConstructorReturn(_this, {
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return Child;
|
2019-01-24 10:07:09 +03:00
|
|
|
}(Base);
|
|
|
|
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
// regression_t6750
|
2019-01-24 10:07:09 +03:00
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
// Module
|
|
|
|
ignore,
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
regression_t6750,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
export default function() {
|
|
|
|
return class Select {
|
|
|
|
query(query) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
value: true
|
|
|
|
});
|
|
|
|
exports.default = _default;
|
|
|
|
|
|
|
|
function _default() {
|
|
|
|
return (
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
|
|
|
function Select() {
|
|
|
|
_classCallCheck(this, Select);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Select, [{
|
|
|
|
key: "query",
|
|
|
|
value: function query(_query) {}
|
|
|
|
}]);
|
|
|
|
return Select;
|
|
|
|
}()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_instance_method
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_instance_method,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Test {
|
|
|
|
test() {
|
|
|
|
return 5 + 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Test =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Test() {
|
|
|
|
_classCallCheck(this, Test);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Test, [{
|
|
|
|
key: "test",
|
|
|
|
value: function test() {
|
|
|
|
return 5 + 5;
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
return Test;
|
|
|
|
}();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
// regression_t2997
|
2019-10-19 06:21:56 +03:00
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-10-19 06:21:56 +03:00
|
|
|
regression_t2997,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class A {}
|
|
|
|
|
|
|
|
class B extends A {
|
|
|
|
constructor() {
|
|
|
|
return super();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
let A = function A() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
|
|
|
_classCallCheck(this, A);
|
2019-01-24 10:07:09 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
let B =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (A) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(B, A);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function B() {
|
2019-12-09 15:02:51 +03:00
|
|
|
_classCallCheck(this, B);
|
2019-01-24 10:07:09 +03:00
|
|
|
var _this;
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(_this, _this = _possibleConstructorReturn(this, _getPrototypeOf(B).call(this)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return B;
|
|
|
|
}(A);
|
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#
|
|
|
|
);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
// spec_constructor_binding_collision
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_constructor_binding_collision,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Example {
|
|
|
|
constructor() {
|
|
|
|
var Example;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var t = new Example();
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Example = function Example() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
|
|
|
_classCallCheck(this, Example);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
var Example1;
|
|
|
|
};
|
|
|
|
|
|
|
|
var t = new Example();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_super_class_anonymous
|
2019-10-19 06:21:56 +03:00
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-10-19 06:21:56 +03:00
|
|
|
spec_super_class_anonymous,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class TestEmpty extends (class {}) {
|
|
|
|
}
|
|
|
|
|
|
|
|
class TestConstructorOnly extends (class { constructor() {} }) {
|
|
|
|
}
|
|
|
|
|
|
|
|
class TestMethodOnly extends (class { method() {} }) {
|
|
|
|
}
|
|
|
|
|
|
|
|
class TestConstructorAndMethod extends (class {
|
|
|
|
constructor() {}
|
|
|
|
method() {}
|
|
|
|
}) {
|
|
|
|
}
|
|
|
|
|
|
|
|
class TestMultipleMethods extends (class {
|
|
|
|
m1() {}
|
|
|
|
m2() {}
|
|
|
|
}) {}
|
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var TestEmpty =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function (_super) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_inherits(TestEmpty, _super);
|
|
|
|
|
|
|
|
function TestEmpty() {
|
|
|
|
_classCallCheck(this, TestEmpty);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(TestEmpty).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
return TestEmpty;
|
2019-12-09 15:02:51 +03:00
|
|
|
}(function _class() {
|
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, _class);
|
2019-12-09 15:02:51 +03:00
|
|
|
});
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
var TestConstructorOnly =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function (_super) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_inherits(TestConstructorOnly, _super);
|
|
|
|
|
|
|
|
function TestConstructorOnly() {
|
|
|
|
_classCallCheck(this, TestConstructorOnly);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(TestConstructorOnly).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
return TestConstructorOnly;
|
2019-12-09 15:02:51 +03:00
|
|
|
}(function _class() {
|
|
|
|
'use strict';
|
|
|
|
_classCallCheck(this, _class);
|
|
|
|
});
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
var TestMethodOnly =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function (_super) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_inherits(TestMethodOnly, _super);
|
|
|
|
|
|
|
|
function TestMethodOnly() {
|
|
|
|
_classCallCheck(this, TestMethodOnly);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(TestMethodOnly).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
return TestMethodOnly;
|
2019-01-29 17:56:16 +03:00
|
|
|
}(
|
2019-01-24 10:07:09 +03:00
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function _class() {
|
|
|
|
_classCallCheck(this, _class);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(_class, [{
|
|
|
|
key: "method",
|
|
|
|
value: function method() {}
|
|
|
|
}]);
|
|
|
|
return _class;
|
2019-01-29 17:56:16 +03:00
|
|
|
}());
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
var TestConstructorAndMethod =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function (_super) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_inherits(TestConstructorAndMethod, _super);
|
|
|
|
|
|
|
|
function TestConstructorAndMethod() {
|
|
|
|
_classCallCheck(this, TestConstructorAndMethod);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(TestConstructorAndMethod).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
return TestConstructorAndMethod;
|
2019-01-29 17:56:16 +03:00
|
|
|
}(
|
2019-01-24 10:07:09 +03:00
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function _class() {
|
|
|
|
_classCallCheck(this, _class);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(_class, [{
|
|
|
|
key: "method",
|
|
|
|
value: function method() {}
|
|
|
|
}]);
|
|
|
|
return _class;
|
2019-01-29 17:56:16 +03:00
|
|
|
}());
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
var TestMultipleMethods =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function (_super) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_inherits(TestMultipleMethods, _super);
|
|
|
|
|
|
|
|
function TestMultipleMethods() {
|
|
|
|
_classCallCheck(this, TestMultipleMethods);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(TestMultipleMethods).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
return TestMultipleMethods;
|
2019-01-29 17:56:16 +03:00
|
|
|
}(
|
2019-01-24 10:07:09 +03:00
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function _class() {
|
|
|
|
_classCallCheck(this, _class);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(_class, [{
|
|
|
|
key: "m1",
|
|
|
|
value: function m1() {}
|
|
|
|
}, {
|
|
|
|
key: "m2",
|
|
|
|
value: function m2() {}
|
|
|
|
}]);
|
|
|
|
return _class;
|
2019-01-29 17:56:16 +03:00
|
|
|
}());
|
2019-01-24 10:07:09 +03:00
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#
|
|
|
|
);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
// spec_method_return_type_annotation
|
|
|
|
|
|
|
|
// spec_nested_class_super_call_in_key
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_nested_class_super_call_in_key,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Hello {
|
|
|
|
constructor() {
|
|
|
|
return {
|
|
|
|
toString() {
|
|
|
|
return 'hello';
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Outer extends Hello {
|
|
|
|
constructor() {
|
|
|
|
class Inner {
|
|
|
|
[super()]() {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Inner();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(new Outer().hello()).toBe('hello');
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
var Hello = function Hello() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Hello);
|
|
|
|
return {
|
|
|
|
toString() {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-09-01 16:11:55 +03:00
|
|
|
var Outer = function (Hello) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Outer, Hello);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Outer() {
|
2019-12-09 15:02:51 +03:00
|
|
|
_classCallCheck(this, Outer);
|
2019-01-29 17:56:16 +03:00
|
|
|
var _this = this;
|
|
|
|
var _this1;
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
var Inner =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
|
|
|
function Inner() {
|
|
|
|
_classCallCheck(this, Inner);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Inner, [{
|
2019-01-29 17:56:16 +03:00
|
|
|
key: _this1 = _possibleConstructorReturn(_this, _getPrototypeOf(Outer).call(_this)),
|
2019-01-24 10:07:09 +03:00
|
|
|
value: function () {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
return Inner;
|
|
|
|
}();
|
|
|
|
|
2019-01-29 17:56:16 +03:00
|
|
|
return _possibleConstructorReturn(_this1, new Inner());
|
2019-01-24 10:07:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return Outer;
|
|
|
|
}(Hello);
|
|
|
|
|
|
|
|
expect(new Outer().hello()).toBe('hello');
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// extend_builtins_builtin_objects_throw_when_wrapped
|
|
|
|
|
|
|
|
// regression_2663
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
// Module
|
|
|
|
ignore,
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
regression_2663,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
import net from 'net';
|
|
|
|
import { EventEmitter } from 'events';
|
|
|
|
import BinarySerializer from './helpers/binary-serializer';
|
|
|
|
// import ...
|
|
|
|
|
|
|
|
export default class Connection extends EventEmitter {
|
|
|
|
constructor(endpoint, joinKey, joinData, roomId) {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.isConnected = false;
|
|
|
|
this.roomId = roomId;
|
|
|
|
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
|
|
|
|
send(message) {
|
|
|
|
this.sock.write(BinarySerializer.serializeMessage(message));
|
|
|
|
}
|
|
|
|
|
|
|
|
disconnect() {
|
|
|
|
this.sock.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
value: true
|
|
|
|
});
|
|
|
|
exports.default = void 0;
|
|
|
|
|
|
|
|
var _net = _interopRequireDefault(require("net"));
|
|
|
|
|
|
|
|
var _events = require("events");
|
|
|
|
|
|
|
|
var _binarySerializer = _interopRequireDefault(require("./helpers/binary-serializer"));
|
|
|
|
|
|
|
|
// import ...
|
|
|
|
var Connection =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function (_EventEmitter) {
|
|
|
|
_inherits(Connection, _EventEmitter);
|
|
|
|
|
|
|
|
function Connection(endpoint, joinKey, joinData, roomId) {
|
|
|
|
var _this;
|
|
|
|
|
|
|
|
_classCallCheck(this, Connection);
|
|
|
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(Connection).call(this));
|
|
|
|
_this.isConnected = false;
|
|
|
|
_this.roomId = roomId; // ...
|
|
|
|
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Connection, [{
|
|
|
|
key: "send",
|
|
|
|
value: function send(message) {
|
|
|
|
this.sock.write(_binarySerializer.default.serializeMessage(message));
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
key: "disconnect",
|
|
|
|
value: function disconnect() {
|
|
|
|
this.sock.close();
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
return Connection;
|
|
|
|
}(_events.EventEmitter);
|
|
|
|
|
|
|
|
exports.default = Connection;
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_set_semantics_setter_defined_on_parent_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_set_semantics_setter_defined_on_parent_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
let value = 1;
|
|
|
|
class Base {
|
|
|
|
set test(v) {
|
|
|
|
value = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
set() {
|
|
|
|
return super.test = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(value).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBeUndefined();
|
|
|
|
expect(Obj.prototype.test).toBe(2);
|
|
|
|
expect(obj.test).toBe(2);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// regression_5817_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
regression_5817_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
// https://github.com/babel/babel/issues/5817
|
|
|
|
|
|
|
|
class Parent {}
|
|
|
|
|
|
|
|
class Table extends Parent {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.returnParam = (param) => {
|
|
|
|
return param;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const table = new Table();
|
|
|
|
|
|
|
|
expect(table.returnParam(false)).toBe(false);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// exec_class_prototype
|
|
|
|
|
|
|
|
// spec_instance_getter
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_instance_getter,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Test {
|
|
|
|
get test() {
|
|
|
|
return 5 + 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Test =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Test() {
|
|
|
|
_classCallCheck(this, Test);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Test, [{
|
|
|
|
key: "test",
|
|
|
|
get: function () {
|
|
|
|
return 5 + 5;
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
return Test;
|
|
|
|
}();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_this_not_allowed_before_super_in_derived_classes_3
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_this_not_allowed_before_super_in_derived_classes_3,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
const fn = () => this;
|
|
|
|
fn();
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-12-09 15:02:51 +03:00
|
|
|
var Foo = function(Bar) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(Foo, Bar);
|
|
|
|
function Foo() {
|
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
var _this;
|
|
|
|
var fn = ()=>_assertThisInitialized(_this)
|
|
|
|
;
|
|
|
|
fn();
|
|
|
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this));
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
return Foo;
|
2019-01-24 10:07:09 +03:00
|
|
|
}(Bar);
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_accessing_super_class
|
|
|
|
test!(
|
2019-10-19 06:21:56 +03:00
|
|
|
// TODO(kdy1): Unignore this.
|
|
|
|
ignore,
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-10-19 06:21:56 +03:00
|
|
|
spec_accessing_super_class,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Test extends Foo {
|
|
|
|
constructor() {
|
|
|
|
woops.super.test();
|
|
|
|
super();
|
|
|
|
super.test();
|
|
|
|
|
|
|
|
super(...arguments);
|
|
|
|
super("test", ...arguments);
|
|
|
|
|
|
|
|
super.test(...arguments);
|
|
|
|
super.test("test", ...arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
test() {
|
|
|
|
super.test();
|
|
|
|
super.test(...arguments);
|
|
|
|
super.test("test", ...arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
static foo() {
|
|
|
|
super.foo();
|
|
|
|
super.foo(...arguments);
|
|
|
|
super.foo("test", ...arguments);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Test =
|
|
|
|
/*#__PURE__*/
|
2019-12-09 15:02:51 +03:00
|
|
|
function (Foo) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(Test, Foo);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Test() {
|
|
|
|
var _babelHelpers$getProt, _babelHelpers$get;
|
|
|
|
|
|
|
|
var _this;
|
|
|
|
|
|
|
|
_classCallCheck(this, Test);
|
|
|
|
woops.super.test();
|
|
|
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(Test).call(this));
|
|
|
|
_get(_getPrototypeOf(Test.prototype), "test", _assertThisInitialized(_this)).call(_this);
|
|
|
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(Test).apply(this, arguments));
|
|
|
|
_this = _possibleConstructorReturn(this, (_babelHelpers$getProt = _getPrototypeOf(Test)).call.apply(_babelHelpers$getProt, [this, "test"].concat(Array.prototype.slice.call(arguments))));
|
|
|
|
_get(_getPrototypeOf(Test.prototype), "test", _assertThisInitialized(_this)).apply(_assertThisInitialized(_this), arguments);
|
|
|
|
|
|
|
|
(_babelHelpers$get = _get(_getPrototypeOf(Test.prototype), "test", _assertThisInitialized(_this))).call.apply(_babelHelpers$get, [_assertThisInitialized(_this), "test"].concat(Array.prototype.slice.call(arguments)));
|
|
|
|
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Test, [{
|
|
|
|
key: "test",
|
|
|
|
value: function test() {
|
|
|
|
var _babelHelpers$get2;
|
|
|
|
|
|
|
|
_get(_getPrototypeOf(Test.prototype), "test", this).call(this);
|
|
|
|
_get(_getPrototypeOf(Test.prototype), "test", this).apply(this, arguments);
|
|
|
|
|
|
|
|
(_babelHelpers$get2 = _get(_getPrototypeOf(Test.prototype), "test", this)).call.apply(_babelHelpers$get2, [this, "test"].concat(Array.prototype.slice.call(arguments)));
|
|
|
|
}
|
|
|
|
}], [{
|
|
|
|
key: "foo",
|
|
|
|
value: function foo() {
|
|
|
|
var _babelHelpers$get3;
|
|
|
|
|
|
|
|
_get(_getPrototypeOf(Test), "foo", this).call(this);
|
|
|
|
_get(_getPrototypeOf(Test), "foo", this).apply(this, arguments);
|
|
|
|
|
|
|
|
(_babelHelpers$get3 = _get(_getPrototypeOf(Test), "foo", this)).call.apply(_babelHelpers$get3, [this, "test"].concat(Array.prototype.slice.call(arguments)));
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
return Test;
|
|
|
|
}(Foo);
|
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#
|
|
|
|
);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
// spec_this_not_allowed_before_super_in_derived_classes_exec
|
2019-01-24 10:07:09 +03:00
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_this_not_allowed_before_super_in_derived_classes_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Bar {}
|
|
|
|
|
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
this.foo = "bar";
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(() => new Foo()).toThrow();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_nested_object_super_property_in_key_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_nested_object_super_property_in_key_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Hello {
|
|
|
|
toString() {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Outer extends Hello {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
const Inner = {
|
|
|
|
[super.toString()]() {
|
|
|
|
return 'hello';
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return Inner;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(new Outer().hello()).toBe('hello');
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
// regression_t6712
|
2019-01-24 10:07:09 +03:00
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
regression_t6712,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class A {
|
|
|
|
foo() {
|
|
|
|
const foo = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
let A =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
|
|
|
function A() {
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, A);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(A, [{
|
|
|
|
key: "foo",
|
|
|
|
value: function foo() {
|
|
|
|
const foo = 2;
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
return A;
|
|
|
|
}();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_set_semantics_setter_defined_on_parent
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_set_semantics_setter_defined_on_parent,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
let value = 1;
|
|
|
|
class Base {
|
|
|
|
set test(v) {
|
|
|
|
value = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
set() {
|
|
|
|
return super.test = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(value).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBeUndefined();
|
|
|
|
expect(Obj.prototype.test).toBe(2);
|
|
|
|
expect(obj.test).toBe(2);
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
let value = 1;
|
|
|
|
|
|
|
|
let Base =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
function Base() {
|
|
|
|
_classCallCheck(this, Base);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Base, [{
|
|
|
|
key: "test",
|
|
|
|
set: function (v) {
|
|
|
|
value = v;
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Base;
|
|
|
|
}();
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "set",
|
|
|
|
value: function set() {
|
|
|
|
return _set(_getPrototypeOf(Obj.prototype), "test", 3, this, true);
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(value).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBeUndefined();
|
|
|
|
expect(Obj.prototype.test).toBe(2);
|
|
|
|
expect(obj.test).toBe(2);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_call_semantics_not_defined_on_parent
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_call_semantics_not_defined_on_parent,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Base {
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
call() {
|
|
|
|
return super.test();
|
|
|
|
}
|
|
|
|
|
|
|
|
test() {
|
|
|
|
throw new Error("gobbledygook");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(() => {
|
|
|
|
obj.call();
|
|
|
|
|
|
|
|
// Asser that this throws, but that it's not
|
|
|
|
// Obj.p.test's error that is thrown
|
|
|
|
}).toThrowError(TypeError)
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
let Base = function Base() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Base);
|
|
|
|
};
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "call",
|
|
|
|
value: function call() {
|
|
|
|
return _get(_getPrototypeOf(Obj.prototype), "test", this).call(this);
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
key: "test",
|
|
|
|
value: function test() {
|
|
|
|
throw new Error("gobbledygook");
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(() => {
|
|
|
|
obj.call(); // Asser that this throws, but that it's not
|
|
|
|
// Obj.p.test's error that is thrown
|
|
|
|
}).toThrowError(TypeError);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_derived_constructor_must_call_super_2_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_derived_constructor_must_call_super_2_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Bar {}
|
|
|
|
|
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
if (eval("false")) super();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// exec_declaration
|
|
|
|
|
|
|
|
// spec_nested_object_super_property_in_key
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_nested_object_super_property_in_key,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Hello {
|
|
|
|
toString() {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Outer extends Hello {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
const Inner = {
|
|
|
|
[super.toString()]() {
|
|
|
|
return 'hello';
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return Inner;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(new Outer().hello()).toBe('hello');
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
var Hello =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
function Hello() {
|
|
|
|
_classCallCheck(this, Hello);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Hello, [{
|
|
|
|
key: "toString",
|
|
|
|
value: function toString() {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
return Hello;
|
|
|
|
}();
|
|
|
|
|
|
|
|
var Outer =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Hello) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Outer, Hello);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Outer() {
|
|
|
|
_classCallCheck(this, Outer);
|
|
|
|
var _this = _possibleConstructorReturn(this, _getPrototypeOf(Outer).call(this));
|
|
|
|
var Inner = {
|
2021-08-06 17:20:02 +03:00
|
|
|
[_get(_getPrototypeOf(Outer.prototype), 'toString', _assertThisInitialized(_this)).call(_this)] () {
|
2019-01-24 10:07:09 +03:00
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
return _possibleConstructorReturn(_this, Inner);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Outer;
|
|
|
|
}(Hello);
|
|
|
|
|
|
|
|
expect(new Outer().hello()).toBe('hello');
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_set_semantics_not_defined_on_parent_setter_on_obj_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_set_semantics_not_defined_on_parent_setter_on_obj_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Base {
|
|
|
|
}
|
|
|
|
|
|
|
|
let value = 2;
|
|
|
|
class Obj extends Base {
|
|
|
|
set test(v) {
|
|
|
|
value = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
set() {
|
|
|
|
return super.test = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBeUndefined();
|
|
|
|
expect(Obj.prototype.test).toBeUndefined();
|
|
|
|
expect(value).toBe(2);
|
|
|
|
expect(obj.test).toBe(3);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// exec_expression
|
|
|
|
|
|
|
|
// spec_this_not_allowed_before_super_in_derived_classes_2_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_this_not_allowed_before_super_in_derived_classes_2_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Bar {}
|
|
|
|
|
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
super(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_super_reference_before_bare_super_inline_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_super_reference_before_bare_super_inline_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Bar {}
|
|
|
|
|
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
super.foo(super());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_call_semantics_setter_defined_on_parent
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_call_semantics_setter_defined_on_parent,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Base {
|
|
|
|
set test(v) {
|
|
|
|
throw new Error("gobbledygook");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
call() {
|
|
|
|
return super.test();
|
|
|
|
}
|
|
|
|
|
|
|
|
test() {
|
|
|
|
throw new Error("gobbledygook");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(() => {
|
|
|
|
obj.call();
|
|
|
|
|
|
|
|
// Assert that this throws, but that it's not
|
|
|
|
// a gobbledygook error that is thrown
|
|
|
|
}).toThrowError(TypeError)
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
let Base =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
function Base() {
|
|
|
|
_classCallCheck(this, Base);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Base, [{
|
|
|
|
key: "test",
|
|
|
|
set: function (v) {
|
|
|
|
throw new Error("gobbledygook");
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Base;
|
|
|
|
}();
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "call",
|
|
|
|
value: function call() {
|
|
|
|
return _get(_getPrototypeOf(Obj.prototype), "test", this).call(this);
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
key: "test",
|
|
|
|
value: function test() {
|
|
|
|
throw new Error("gobbledygook");
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(() => {
|
|
|
|
obj.call(); // Assert that this throws, but that it's not
|
|
|
|
// a gobbledygook error that is thrown
|
|
|
|
}).toThrowError(TypeError);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_super_class
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_super_class,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Test extends Foo { }
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Test =
|
|
|
|
/*#__PURE__*/
|
2019-12-09 15:02:51 +03:00
|
|
|
function (Foo) {
|
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
_inherits(Test, Foo);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Test() {
|
|
|
|
_classCallCheck(this, Test);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Test).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
return Test;
|
|
|
|
}(Foo);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_super_call_only_allowed_in_derived_constructor
|
|
|
|
|
|
|
|
// spec_nested_object_super_call_in_key_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_nested_object_super_call_in_key_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Hello {
|
|
|
|
constructor() {
|
|
|
|
return {
|
|
|
|
toString() {
|
|
|
|
return 'hello';
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Outer extends Hello {
|
|
|
|
constructor() {
|
|
|
|
const Inner = {
|
|
|
|
[super()]() {
|
|
|
|
return 'hello';
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return Inner;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(new Outer().hello()).toBe('hello');
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_derived_constructor_must_call_super_2
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_derived_constructor_must_call_super_2,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
if (eval("false")) super();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Foo =
|
|
|
|
/*#__PURE__*/
|
2019-12-09 15:02:51 +03:00
|
|
|
function (Bar) {
|
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
_inherits(Foo, Bar);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Foo() {
|
2019-12-09 15:02:51 +03:00
|
|
|
_classCallCheck(this, Foo);
|
2019-01-24 10:07:09 +03:00
|
|
|
var _this;
|
|
|
|
|
|
|
|
if (eval("false")) _this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this));
|
|
|
|
return _possibleConstructorReturn(_this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Foo;
|
|
|
|
}(Bar);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_derived_constructor_must_call_super_3
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_derived_constructor_must_call_super_3,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
const fn = () => super();
|
|
|
|
fn();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Foo =
|
|
|
|
/*#__PURE__*/
|
2019-12-09 15:02:51 +03:00
|
|
|
function (Bar) {
|
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
_inherits(Foo, Bar);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Foo() {
|
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
var _this;
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
var fn = () => _this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this));
|
|
|
|
|
|
|
|
fn();
|
|
|
|
return _possibleConstructorReturn(_this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Foo;
|
|
|
|
}(Bar);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_this_not_allowed_before_super_in_derived_classes_3_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_this_not_allowed_before_super_in_derived_classes_3_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Bar {}
|
|
|
|
|
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
const fn = () => this;
|
|
|
|
fn();
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_set_semantics_not_defined_on_parent_data_on_obj
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_set_semantics_not_defined_on_parent_data_on_obj,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Base {
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
set() {
|
|
|
|
return super.test = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBeUndefined();
|
|
|
|
expect(Obj.prototype.test).toBe(2);
|
|
|
|
expect(obj.test).toBe(3);
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
let Base = function Base() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Base);
|
|
|
|
};
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "set",
|
|
|
|
value: function set() {
|
|
|
|
return _set(_getPrototypeOf(Obj.prototype), "test", 3, this, true);
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBeUndefined();
|
|
|
|
expect(Obj.prototype.test).toBe(2);
|
|
|
|
expect(obj.test).toBe(3);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_memoized_assign
|
2019-10-19 06:21:56 +03:00
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-10-19 06:21:56 +03:00
|
|
|
get_set_memoized_assign,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Base {}
|
|
|
|
Object.defineProperty(Base.prototype, 0, {
|
|
|
|
value: 0,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
Object.defineProperty(Base.prototype, 1, {
|
|
|
|
value: 1,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
let i = 0;
|
|
|
|
const proper = {
|
|
|
|
get prop() {
|
|
|
|
return i++;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
assign() {
|
|
|
|
super[proper.prop] += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
assign2() {
|
|
|
|
super[i] += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
|
|
|
|
obj.assign();
|
|
|
|
expect(i).toBe(1);
|
|
|
|
expect(obj[0]).toBe(1);
|
|
|
|
expect(obj[1]).toBe(1);
|
|
|
|
|
|
|
|
obj.assign2();
|
|
|
|
expect(i).toBe(1);
|
|
|
|
expect(obj[0]).toBe(1);
|
|
|
|
expect(obj[1]).toBe(2);
|
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
let Base = function Base() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Base);
|
|
|
|
};
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
Object.defineProperty(Base.prototype, 0, {
|
|
|
|
value: 0,
|
|
|
|
writable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
Object.defineProperty(Base.prototype, 1, {
|
|
|
|
value: 1,
|
|
|
|
writable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
let i = 0;
|
|
|
|
const proper = {
|
|
|
|
get prop() {
|
|
|
|
return i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "assign",
|
|
|
|
value: function assign() {
|
|
|
|
var _ref;
|
|
|
|
|
|
|
|
_set(_getPrototypeOf(Obj.prototype), _ref = proper.prop, _get(_getPrototypeOf(Obj.prototype), _ref, this) + 1, this, true);
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
key: "assign2",
|
|
|
|
value: function assign2() {
|
|
|
|
var _ref;
|
|
|
|
|
|
|
|
_set(_getPrototypeOf(Obj.prototype), _ref = i, _get(_getPrototypeOf(Obj.prototype), _ref, this) + 1, this, true);
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
obj.assign();
|
|
|
|
expect(i).toBe(1);
|
|
|
|
expect(obj[0]).toBe(1);
|
|
|
|
expect(obj[1]).toBe(1);
|
|
|
|
obj.assign2();
|
|
|
|
expect(i).toBe(1);
|
|
|
|
expect(obj[0]).toBe(1);
|
|
|
|
expect(obj[1]).toBe(2);
|
|
|
|
|
2019-10-19 06:21:56 +03:00
|
|
|
"#
|
|
|
|
);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
// spec_nested_class_super_property_in_key_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_nested_class_super_property_in_key_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
class Hello {
|
|
|
|
toString() {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Outer extends Hello {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
class Inner {
|
|
|
|
[super.toString()]() {
|
|
|
|
return 'hello';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Inner();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(new Outer().hello()).toBe('hello');
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_relaxed_method_coercion
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_relaxed_method_coercion,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
// #1649
|
|
|
|
|
|
|
|
class Foo {
|
|
|
|
[Symbol()]() {}
|
|
|
|
[Symbol()]() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
// #1649
|
|
|
|
var Foo =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Foo() {
|
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Foo, [{
|
|
|
|
key: Symbol(),
|
|
|
|
value: function () {}
|
|
|
|
}, {
|
|
|
|
key: Symbol(),
|
|
|
|
value: function () {}
|
|
|
|
}]);
|
|
|
|
return Foo;
|
|
|
|
}();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_derived_constructor_must_call_super_3_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_derived_constructor_must_call_super_3_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Bar {}
|
|
|
|
|
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
const fn = () => super();
|
|
|
|
fn();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
new Foo();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_computed_methods_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_computed_methods_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
const sym = Symbol();
|
|
|
|
|
|
|
|
class Foo {
|
|
|
|
[sym] () {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Bar extends Foo {
|
|
|
|
[sym] () {
|
|
|
|
return super[sym]() + 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let i = new Bar();
|
|
|
|
|
|
|
|
expect(i[sym]()).toBe(3);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
// spec_derived_constructor_must_call_super_4
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
spec_derived_constructor_must_call_super_4,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-12-09 15:02:51 +03:00
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
const fn = () => super();
|
|
|
|
}
|
|
|
|
}
|
2019-01-24 10:07:09 +03:00
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
var Foo =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function (Bar) {
|
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
_inherits(Foo, Bar);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
function Foo() {
|
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
var _this;
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
var fn = () => _this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this));
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
return _possibleConstructorReturn(_this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Foo;
|
|
|
|
}(Bar);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_super_class_id_member_expression
|
2019-02-05 06:50:19 +03:00
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-02-05 06:50:19 +03:00
|
|
|
spec_super_class_id_member_expression,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class BaseController extends Chaplin.Controller {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class BaseController2 extends Chaplin.Controller.Another {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-02-05 06:50:19 +03:00
|
|
|
"#,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var BaseController =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function (_Controller) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_inherits(BaseController, _Controller);
|
|
|
|
|
|
|
|
function BaseController() {
|
|
|
|
_classCallCheck(this, BaseController);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(BaseController).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
return BaseController;
|
|
|
|
}(Chaplin.Controller);
|
|
|
|
|
|
|
|
var BaseController2 =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function (_Another) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_inherits(BaseController2, _Another);
|
|
|
|
|
|
|
|
function BaseController2() {
|
|
|
|
_classCallCheck(this, BaseController2);
|
2019-02-05 06:50:19 +03:00
|
|
|
return _possibleConstructorReturn(this,_getPrototypeOf(BaseController2).apply(this, arguments));
|
2019-01-24 10:07:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return BaseController2;
|
|
|
|
}(Chaplin.Controller.Another);
|
|
|
|
|
2019-02-05 06:50:19 +03:00
|
|
|
"#
|
|
|
|
);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
// spec_delay_arrow_function_for_bare_super_derived
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_delay_arrow_function_for_bare_super_derived,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
super(() => {
|
|
|
|
this.test;
|
|
|
|
});
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Foo =
|
|
|
|
/*#__PURE__*/
|
2019-12-09 15:02:51 +03:00
|
|
|
function (Bar) {
|
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
2019-12-09 15:02:51 +03:00
|
|
|
_inherits(Foo, Bar);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Foo() {
|
2019-12-09 15:02:51 +03:00
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
var _this;
|
|
|
|
|
|
|
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(Foo).call(this, () => {
|
|
|
|
_this.test;
|
|
|
|
}));
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Foo;
|
|
|
|
}(Bar);
|
|
|
|
|
|
|
|
"#
|
2018-12-22 06:15:04 +03:00
|
|
|
);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// extend_builtins_overwritten_null
|
|
|
|
|
|
|
|
// spec_default_super_exec
|
2018-12-22 06:15:04 +03:00
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_default_super_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Test {
|
|
|
|
constructor() {
|
|
|
|
return super.constructor;
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
static test() {
|
|
|
|
return super.constructor;
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// Instances
|
|
|
|
expect(Object.getPrototypeOf(Test.prototype)).toBe(Object.prototype);
|
|
|
|
expect(new Test()).toBe(Object);
|
2018-12-22 06:15:04 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// Static
|
|
|
|
expect(Object.getPrototypeOf(Test)).toBe(Function.prototype);
|
|
|
|
expect(Test.test()).toBe(Function);
|
|
|
|
|
|
|
|
"#
|
2018-12-22 06:15:04 +03:00
|
|
|
);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// spec_super_reference_before_in_lambda_3_exec
|
2018-12-22 06:15:04 +03:00
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_super_reference_before_in_lambda_3_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Bar {
|
|
|
|
test() {}
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
const t = () => super.test()
|
|
|
|
super();
|
|
|
|
t();
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
new Foo();
|
2018-12-22 06:15:04 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#
|
2018-12-22 06:15:04 +03:00
|
|
|
);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// regression
|
|
|
|
|
|
|
|
// get_set_get_semantics_not_defined_on_parent
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_get_semantics_not_defined_on_parent,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
2018-12-22 06:15:04 +03:00
|
|
|
class Base {
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
get() {
|
|
|
|
return super.test;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.test).toBe(2);
|
2019-01-24 10:07:09 +03:00
|
|
|
expect(obj.get()).toBeUndefined();
|
2018-12-22 06:15:04 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2018-12-22 06:15:04 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
let Base = function Base() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
_classCallCheck(this, Base);
|
|
|
|
};
|
|
|
|
|
|
|
|
let Obj =
|
|
|
|
/*#__PURE__*/
|
2021-09-01 16:11:55 +03:00
|
|
|
function (Base) {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2021-09-01 16:11:55 +03:00
|
|
|
_inherits(Obj, Base);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function Obj() {
|
|
|
|
_classCallCheck(this, Obj);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Obj).apply(this, arguments));
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_createClass(Obj, [{
|
|
|
|
key: "get",
|
|
|
|
value: function get() {
|
|
|
|
return _get(_getPrototypeOf(Obj.prototype), "test", this);
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Obj;
|
|
|
|
}(Base);
|
|
|
|
|
2018-12-22 06:15:04 +03:00
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
2019-01-24 10:07:09 +03:00
|
|
|
configurable: true
|
2018-12-22 06:15:04 +03:00
|
|
|
});
|
|
|
|
const obj = new Obj();
|
2019-01-24 10:07:09 +03:00
|
|
|
expect(obj.test).toBe(2);
|
|
|
|
expect(obj.get()).toBeUndefined();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// extend_builtins_super_called
|
|
|
|
|
|
|
|
// spec_plain_class
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_plain_class,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Test { }
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var Test = function Test() {
|
2019-12-09 15:02:51 +03:00
|
|
|
'use strict';
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
_classCallCheck(this, Test);
|
|
|
|
};
|
|
|
|
|
2018-12-22 06:15:04 +03:00
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// spec_super_reference_before_bare_super_exec
|
2018-12-22 06:15:04 +03:00
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_super_reference_before_bare_super_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Bar {}
|
|
|
|
|
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
super.foo();
|
|
|
|
super();
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
2019-01-24 10:07:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_super_reference_before_in_lambda_2_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_super_reference_before_in_lambda_2_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Bar {
|
|
|
|
test() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
const t = () => super.test()
|
|
|
|
t();
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// spec_derived_constructor_must_call_super_exec
|
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_derived_constructor_must_call_super_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
class Bar {}
|
|
|
|
|
|
|
|
class Foo extends Bar {
|
|
|
|
constructor() {
|
|
|
|
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// exec_return
|
|
|
|
|
|
|
|
// spec_export_super_class
|
|
|
|
test!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_export_super_class,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
export default class extends A {}
|
|
|
|
|
|
|
|
"#,
|
2019-01-30 07:05:45 +03:00
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
var _default =
|
|
|
|
/*#__PURE__*/
|
2019-12-09 15:02:51 +03:00
|
|
|
function (A) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(_default, A);
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
function _default() {
|
|
|
|
_classCallCheck(this, _default);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(_default).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
return _default;
|
|
|
|
}(A);
|
|
|
|
|
|
|
|
export { _default as default };
|
|
|
|
|
|
|
|
"#
|
2018-12-22 06:15:04 +03:00
|
|
|
);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// extend_builtins_wrap_native_super_exec
|
2018-12-22 06:15:04 +03:00
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
extend_builtins_wrap_native_super_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
// basic sanity check to confirm the external wrapNativeSuper helper works
|
|
|
|
|
|
|
|
class Test1 extends Array {
|
|
|
|
name() {
|
|
|
|
return 'test1';
|
|
|
|
}
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
class Test2 extends Array {
|
|
|
|
name() {
|
|
|
|
return 'test2';
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
var t1 = new Test1();
|
|
|
|
var t2 = new Test2();
|
|
|
|
|
|
|
|
expect(Test1).not.toBe(Test2);
|
|
|
|
expect(t1).not.toBe(t2);
|
|
|
|
expect(t1.name()).toBe('test1');
|
|
|
|
expect(t2.name()).toBe('test2');
|
|
|
|
expect(t1).toBeInstanceOf(Test1);
|
|
|
|
expect(t2).toBeInstanceOf(Test2);
|
|
|
|
expect(t1).toBeInstanceOf(Array);
|
|
|
|
expect(t2).toBeInstanceOf(Array);
|
|
|
|
|
|
|
|
"#
|
2018-12-22 06:15:04 +03:00
|
|
|
);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// spec_super_reference_in_prop_exression_exec
|
2018-12-22 06:15:04 +03:00
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
spec_super_reference_in_prop_exression_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
let called = false;
|
2018-12-22 06:15:04 +03:00
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
class A {
|
|
|
|
method() {
|
|
|
|
called = true;
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
get methodName() {
|
|
|
|
return "method";
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
class B extends A {
|
|
|
|
constructor() {
|
|
|
|
super[super().methodName]()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
new B();
|
|
|
|
expect(called).toBe(true);
|
|
|
|
|
|
|
|
"#
|
2018-12-22 06:15:04 +03:00
|
|
|
);
|
|
|
|
|
2019-01-24 10:07:09 +03:00
|
|
|
// extend_builtins_imported_babel_plugin_transform_builtin_classes
|
|
|
|
|
|
|
|
// get_set_set_semantics_getter_defined_on_parent_exec
|
2018-12-22 06:15:04 +03:00
|
|
|
test_exec!(
|
2019-01-30 07:05:45 +03:00
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-01-30 07:05:45 +03:00
|
|
|
get_set_set_semantics_getter_defined_on_parent_exec,
|
|
|
|
r#"
|
2019-01-24 10:07:09 +03:00
|
|
|
|
|
|
|
let called = false;
|
2018-12-22 06:15:04 +03:00
|
|
|
class Base {
|
2019-01-24 10:07:09 +03:00
|
|
|
get test() {
|
|
|
|
called = true;
|
|
|
|
return 1;
|
2018-12-22 06:15:04 +03:00
|
|
|
}
|
2019-01-24 10:07:09 +03:00
|
|
|
};
|
2018-12-22 06:15:04 +03:00
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
set() {
|
|
|
|
return super.test = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const obj = new Obj();
|
2019-01-24 10:07:09 +03:00
|
|
|
expect(() => {
|
|
|
|
obj.set();
|
|
|
|
}).toThrow();
|
|
|
|
expect(called).toBe(false);
|
|
|
|
expect(Base.prototype.test).toBe(1);
|
2018-12-22 06:15:04 +03:00
|
|
|
expect(Obj.prototype.test).toBe(2);
|
2019-01-24 10:07:09 +03:00
|
|
|
expect(obj.test).toBe(2);
|
|
|
|
|
|
|
|
"#
|
2018-12-22 06:15:04 +03:00
|
|
|
);
|
2019-11-19 13:10:15 +03:00
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-11-19 13:10:15 +03:00
|
|
|
issue_454_followup,
|
|
|
|
"if (true){
|
|
|
|
class Foo extends Bar { }
|
|
|
|
}",
|
|
|
|
"if (true) {
|
2019-12-09 15:02:51 +03:00
|
|
|
var Foo = function(Bar) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(Foo, Bar);
|
2019-11-19 13:10:15 +03:00
|
|
|
function Foo() {
|
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Foo).apply(this, arguments));
|
|
|
|
}
|
|
|
|
return Foo;
|
|
|
|
}(Bar);
|
|
|
|
}"
|
|
|
|
);
|
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| spec_tr(t),
|
2019-11-19 13:10:15 +03:00
|
|
|
issue_454_followup_2,
|
|
|
|
"function broken(x, ...foo) {
|
|
|
|
if (true) {
|
|
|
|
class Foo extends Bar { }
|
|
|
|
return hello(...foo)
|
|
|
|
}
|
|
|
|
}",
|
|
|
|
"function broken(x, ...foo) {
|
|
|
|
if (true) {
|
2019-12-09 15:02:51 +03:00
|
|
|
var Foo = function(Bar) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(Foo, Bar);
|
2019-11-19 13:10:15 +03:00
|
|
|
function Foo() {
|
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Foo).apply(this, \
|
|
|
|
arguments));
|
|
|
|
}
|
|
|
|
return Foo;
|
|
|
|
}(Bar);
|
2019-12-09 15:02:51 +03:00
|
|
|
return hello.apply(void 0, _toConsumableArray(foo));
|
2019-11-19 13:10:15 +03:00
|
|
|
}
|
|
|
|
}"
|
|
|
|
);
|
2019-12-09 15:02:51 +03:00
|
|
|
|
|
|
|
//// regression_3028
|
|
|
|
//test!(
|
|
|
|
// syntax(),
|
|
|
|
// |_| tr(r#"{
|
|
|
|
// "plugins": [ "proposal-class-properties"],
|
|
|
|
// "presets": ["env", "react"]
|
|
|
|
//}
|
|
|
|
//"#),
|
|
|
|
// regression_3028,
|
|
|
|
// r#"
|
|
|
|
//class b {
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//class a1 extends b {
|
|
|
|
// constructor() {
|
|
|
|
// super();
|
|
|
|
// this.x = () => this;
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//export default class a2 extends b {
|
|
|
|
// constructor() {
|
|
|
|
// super();
|
|
|
|
// this.x = () => this;
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//"#,
|
|
|
|
// r#"
|
|
|
|
//"use strict";
|
|
|
|
//
|
|
|
|
//Object.defineProperty(exports, "__esModule", {
|
|
|
|
// value: true
|
|
|
|
//});
|
|
|
|
//exports["default"] = void 0;
|
|
|
|
//
|
|
|
|
//var b = function b() {
|
|
|
|
// _classCallCheck(this, b);
|
|
|
|
//};
|
|
|
|
//
|
|
|
|
//var a1 =
|
|
|
|
// /*#__PURE__*/
|
|
|
|
//function (_b) {
|
|
|
|
// _inherits(a1, _b);
|
|
|
|
//
|
|
|
|
// function a1() {
|
|
|
|
// var _this;
|
|
|
|
//
|
|
|
|
// _classCallCheck(this, a1);
|
|
|
|
// _this = _possibleConstructorReturn(this, _getPrototypeOf(a1).call(this));
|
|
|
|
//
|
|
|
|
// _this.x = function () {
|
|
|
|
// return _assertThisInitialized(_this);
|
|
|
|
// };
|
|
|
|
//
|
|
|
|
// return _this;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// return a1;
|
|
|
|
//}(b);
|
|
|
|
//
|
|
|
|
//var a2 =
|
|
|
|
// /*#__PURE__*/
|
|
|
|
//function (_b2) {
|
|
|
|
// _inherits(a2, _b2);
|
|
|
|
//
|
|
|
|
// function a2() {
|
|
|
|
// var _this2;
|
|
|
|
//
|
|
|
|
// _classCallCheck(this, a2);
|
|
|
|
// _this2 = _possibleConstructorReturn(this, _getPrototypeOf(a2).call(this));
|
|
|
|
//
|
|
|
|
// _this2.x = function () {
|
|
|
|
// return _assertThisInitialized(_this2);
|
|
|
|
// };
|
|
|
|
//
|
|
|
|
// return _this2;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// return a2;
|
|
|
|
//}(b);
|
|
|
|
//
|
|
|
|
//exports["default"] = a2;
|
|
|
|
//
|
|
|
|
//"#
|
|
|
|
//);
|
|
|
|
|
|
|
|
//// regression_t2997
|
|
|
|
//test!(
|
|
|
|
// syntax(),
|
|
|
|
// |_| tr(r#"{
|
|
|
|
// "plugins": [ "proposal-class-properties"],
|
|
|
|
// "presets": ["env", "react"]
|
|
|
|
//}
|
|
|
|
//"#),
|
|
|
|
// regression_t2997,
|
|
|
|
// r#"
|
|
|
|
//class A {}
|
|
|
|
//
|
|
|
|
//class B extends A {
|
|
|
|
// constructor() {
|
|
|
|
// return super();
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//"#,
|
|
|
|
// r#"
|
|
|
|
//var A = function A() {
|
|
|
|
// "use strict";
|
|
|
|
//
|
|
|
|
// _classCallCheck(this, A);
|
|
|
|
//};
|
|
|
|
//
|
|
|
|
//var B =
|
|
|
|
// /*#__PURE__*/
|
|
|
|
//function (A) {
|
|
|
|
// "use strict";
|
|
|
|
//
|
|
|
|
// _inherits(B, A);
|
|
|
|
//
|
|
|
|
// function B() {
|
|
|
|
// var _this;
|
|
|
|
//
|
|
|
|
// _classCallCheck(this, B);
|
|
|
|
// return _possibleConstructorReturn(_this, _this =
|
|
|
|
// _possibleConstructorReturn(this, _getPrototypeOf(B).call(this))); }
|
|
|
|
//
|
|
|
|
// return B;
|
|
|
|
//}(A);
|
|
|
|
//
|
|
|
|
//"#
|
|
|
|
//);
|
|
|
|
|
|
|
|
// extend_builtins_shadowed
|
|
|
|
test!(
|
|
|
|
// Cost is too high while being uesless
|
|
|
|
ignore,
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
extend_builtins_shadowed,
|
|
|
|
r#"
|
|
|
|
class Array {}
|
|
|
|
|
|
|
|
class List extends Array {}
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
let Array = function Array() {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
_classCallCheck(this, Array);
|
|
|
|
};
|
|
|
|
|
|
|
|
let List =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function (Array) {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
_inherits(List, Array);
|
|
|
|
|
|
|
|
function List() {
|
|
|
|
_classCallCheck(this, List);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(List).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
return List;
|
|
|
|
}(Array);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
//// regression_2694
|
|
|
|
//test!(
|
|
|
|
// syntax(),
|
|
|
|
// |_| tr(r#"{
|
|
|
|
// "plugins": [],
|
|
|
|
// "presets": ["env"]
|
|
|
|
//}
|
|
|
|
//"#),
|
|
|
|
// regression_2694,
|
|
|
|
// r#"
|
|
|
|
//import BaseFoo from './BaseFoo';
|
|
|
|
//
|
|
|
|
//export default class SubFoo extends BaseFoo {
|
|
|
|
// static talk() {
|
|
|
|
// super.talk();
|
|
|
|
// console.log('SubFoo.talk');
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//"#,
|
|
|
|
// r#"
|
|
|
|
//"use strict";
|
|
|
|
//
|
|
|
|
//Object.defineProperty(exports, "__esModule", {
|
|
|
|
// value: true
|
|
|
|
//});
|
|
|
|
//exports["default"] = void 0;
|
|
|
|
//
|
|
|
|
//var BaseFoo2 = _interopRequireDefault(require("./BaseFoo"));
|
|
|
|
//
|
|
|
|
//var SubFoo =
|
|
|
|
// /*#__PURE__*/
|
|
|
|
//function (BaseFoo) {
|
|
|
|
// _inherits(SubFoo, BaseFoo);
|
|
|
|
//
|
|
|
|
// function SubFoo() {
|
|
|
|
// _classCallCheck(this, SubFoo);
|
|
|
|
// return _possibleConstructorReturn(this,
|
|
|
|
// _getPrototypeOf(SubFoo).apply(this, arguments)); }
|
|
|
|
//
|
|
|
|
// _createClass(SubFoo, null, [{
|
|
|
|
// key: "talk",
|
|
|
|
// value: function talk() {
|
|
|
|
// _get(_getPrototypeOf(SubFoo), "talk", this).call(this);
|
|
|
|
// console.log('SubFoo.talk');
|
|
|
|
// }
|
|
|
|
// }]);
|
|
|
|
// return SubFoo;
|
|
|
|
//}(BaseFoo2["default"]);
|
|
|
|
//
|
|
|
|
//exports["default"] = SubFoo;
|
|
|
|
//
|
|
|
|
//"#
|
|
|
|
//);
|
|
|
|
|
|
|
|
//// regression_t2494
|
|
|
|
//test!(
|
|
|
|
// syntax(),
|
|
|
|
// |_| tr(r#"{
|
|
|
|
// "plugins": [ "proposal-class-properties"],
|
|
|
|
// "presets": ["env", "react"]
|
|
|
|
//}
|
|
|
|
//"#),
|
|
|
|
// regression_t2494,
|
|
|
|
// r#"
|
|
|
|
//var x = {
|
|
|
|
// Foo: class extends Foo {}
|
|
|
|
//};
|
|
|
|
//
|
|
|
|
//"#,
|
|
|
|
// r#"
|
|
|
|
//var x = {
|
|
|
|
// Foo:
|
|
|
|
// /*#__PURE__*/
|
|
|
|
// function (Foo) {
|
|
|
|
// "use strict";
|
|
|
|
//
|
|
|
|
// _inherits(_class, Foo);
|
|
|
|
//
|
|
|
|
// function _class() {
|
|
|
|
// _classCallCheck(this, _class);
|
|
|
|
// return _possibleConstructorReturn(this,
|
|
|
|
// _getPrototypeOf(_class).apply(this, arguments)); }
|
|
|
|
//
|
|
|
|
// return _class;
|
|
|
|
// }(Foo)
|
|
|
|
//};
|
|
|
|
//
|
|
|
|
//"#
|
|
|
|
//);
|
|
|
|
|
|
|
|
// extend_builtins_imported_babel_plugin_transform_builtin_classes
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| chain!(classes(Some(t.comments.clone())), block_scoping()),
|
2019-12-09 15:02:51 +03:00
|
|
|
extend_builtins_imported_babel_plugin_transform_builtin_classes_exec,
|
|
|
|
r#"
|
|
|
|
// Imported from
|
|
|
|
// https://github.com/WebReflection/babel-plugin-transform-builtin-classes/blob/85efe1374e1c59a8323c7eddd4326f6c93d9f64f/test/test.js
|
|
|
|
|
|
|
|
class List extends Array {
|
|
|
|
constructor(value) {
|
|
|
|
super().push(value);
|
|
|
|
}
|
|
|
|
push(value) {
|
|
|
|
super.push(value);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(new List(1)).toBeInstanceOf(List);
|
|
|
|
expect(new List(2)).toBeInstanceOf(Array);
|
|
|
|
|
|
|
|
var l = new List(3);
|
|
|
|
expect(l).toHaveLength(1);
|
|
|
|
expect(l[0]).toBe(3);
|
|
|
|
expect(l.push(4)).toBe(l);
|
|
|
|
expect(l).toHaveLength(2);
|
|
|
|
expect(l.join()).toBe('3,4');
|
|
|
|
|
|
|
|
class SecondLevel extends List {
|
|
|
|
method() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(new SecondLevel(1)).toBeInstanceOf(SecondLevel);
|
|
|
|
expect(new SecondLevel(2)).toBeInstanceOf(List);
|
|
|
|
expect(new SecondLevel(3)).toBeInstanceOf(Array);
|
|
|
|
|
|
|
|
var s = new SecondLevel(4);
|
|
|
|
expect(s).toHaveLength(1);
|
|
|
|
expect(s[0]).toBe(4);
|
|
|
|
expect(s.push(5)).toBe(s);
|
|
|
|
expect(s).toHaveLength(2);
|
|
|
|
expect(s.join()).toBe('4,5');
|
|
|
|
expect(s.method()).toBe(s);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_call_semantics_setter_defined_on_parent
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
get_set_call_semantics_setter_defined_on_parent_exec,
|
|
|
|
r#"
|
|
|
|
"use strict";
|
|
|
|
class Base {
|
|
|
|
set test(v) {
|
|
|
|
throw new Error("gobbledygook");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
call() {
|
|
|
|
return super.test();
|
|
|
|
}
|
|
|
|
|
|
|
|
test() {
|
|
|
|
throw new Error("gobbledygook");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(() => {
|
|
|
|
obj.call();
|
|
|
|
|
|
|
|
// Asser that this throws, but that it's not
|
|
|
|
// a gobbledygook error that is thrown
|
|
|
|
}).toThrowError(TypeError)
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_call_semantics_not_defined_on_parent
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
get_set_call_semantics_not_defined_on_parent_exec,
|
|
|
|
r#"
|
|
|
|
"use strict";
|
|
|
|
class Base {
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
call() {
|
|
|
|
return super.test();
|
|
|
|
}
|
|
|
|
|
|
|
|
test() {
|
|
|
|
throw new Error("gobbledygook");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(() => {
|
|
|
|
obj.call();
|
|
|
|
|
|
|
|
// Asser that this throws, but that it's not
|
|
|
|
// Obj.p.test's error that is thrown
|
|
|
|
}).toThrowError(TypeError)
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_set_semantics_not_defined_on_parent_getter_on_obj
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
get_set_set_semantics_not_defined_on_parent_getter_on_obj_exec,
|
|
|
|
r#"
|
|
|
|
"use strict";
|
|
|
|
class Base {
|
|
|
|
}
|
|
|
|
|
|
|
|
let called = false;
|
|
|
|
class Obj extends Base {
|
|
|
|
get test() {
|
|
|
|
called = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
set() {
|
|
|
|
return super.test = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(called).toBe(false);
|
|
|
|
expect(Base.prototype.test).toBeUndefined();
|
|
|
|
expect(Obj.prototype.test).toBeUndefined();
|
|
|
|
expect(obj.test).toBe(3);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
//// regression_t6712
|
|
|
|
//test!(
|
|
|
|
// syntax(),
|
|
|
|
// |_| tr(r#"{
|
|
|
|
// "plugins": [ "proposal-class-properties"],
|
|
|
|
// "presets": ["env", "react"]
|
|
|
|
//}
|
|
|
|
//"#),
|
|
|
|
// regression_t6712,
|
|
|
|
// r#"
|
|
|
|
//class A {
|
|
|
|
// foo() {
|
|
|
|
// const foo = 2;
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//"#,
|
|
|
|
// r#"
|
|
|
|
//var A =
|
|
|
|
// /*#__PURE__*/
|
|
|
|
//function () {
|
|
|
|
// "use strict";
|
|
|
|
//
|
|
|
|
// function A() {
|
|
|
|
// _classCallCheck(this, A);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// _createClass(A, [{
|
|
|
|
// key: "foo",
|
|
|
|
// value: function foo() {
|
|
|
|
// var foo = 2;
|
|
|
|
// }
|
|
|
|
// }]);
|
|
|
|
// return A;
|
|
|
|
//}();
|
|
|
|
//
|
|
|
|
//"#
|
|
|
|
//);
|
|
|
|
|
|
|
|
// get_set_set_semantics_not_defined_on_parent_data_on_obj
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
get_set_set_semantics_not_defined_on_parent_data_on_obj_exec,
|
|
|
|
r#"
|
|
|
|
"use strict";
|
|
|
|
class Base {
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
set() {
|
|
|
|
return super.test = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBeUndefined();
|
|
|
|
expect(Obj.prototype.test).toBe(2);
|
|
|
|
expect(obj.test).toBe(3);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
//// regression_2663
|
|
|
|
//test!(
|
|
|
|
// syntax(),
|
|
|
|
// |_| tr(r#"{
|
|
|
|
// "plugins": [ "proposal-class-properties"],
|
|
|
|
// "presets": ["env", "react"]
|
|
|
|
//}
|
|
|
|
//"#),
|
|
|
|
// regression_2663,
|
|
|
|
// r#"
|
|
|
|
//import net from 'net';
|
|
|
|
//import { EventEmitter } from 'events';
|
|
|
|
//import BinarySerializer from './helpers/binary-serializer';
|
|
|
|
//// import ...
|
|
|
|
//
|
|
|
|
//export default class Connection extends EventEmitter {
|
|
|
|
// constructor(endpoint, joinKey, joinData, roomId) {
|
|
|
|
// super();
|
|
|
|
//
|
|
|
|
// this.isConnected = false;
|
|
|
|
// this.roomId = roomId;
|
|
|
|
//
|
|
|
|
// // ...
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// send(message) {
|
|
|
|
// this.sock.write(BinarySerializer.serializeMessage(message));
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// disconnect() {
|
|
|
|
// this.sock.close();
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//"#,
|
|
|
|
// r#"
|
|
|
|
//"use strict";
|
|
|
|
//
|
|
|
|
//Object.defineProperty(exports, "__esModule", {
|
|
|
|
// value: true
|
|
|
|
//});
|
|
|
|
//exports["default"] = void 0;
|
|
|
|
//
|
|
|
|
//var _net = _interopRequireDefault(require("net"));
|
|
|
|
//
|
|
|
|
//var _events = require("events");
|
|
|
|
//
|
|
|
|
//var _binarySerializer =
|
|
|
|
// _interopRequireDefault(require("./helpers/binary-serializer"));
|
|
|
|
//
|
|
|
|
//// import ...
|
|
|
|
//var Connection =
|
|
|
|
// /*#__PURE__*/
|
|
|
|
//function (_EventEmitter) {
|
|
|
|
// _inherits(Connection, _EventEmitter);
|
|
|
|
//
|
|
|
|
// function Connection(endpoint, joinKey, joinData, roomId) {
|
|
|
|
// var _this;
|
|
|
|
//
|
|
|
|
// _classCallCheck(this, Connection);
|
|
|
|
// _this = _possibleConstructorReturn(this,
|
|
|
|
// _getPrototypeOf(Connection).call(this)); _this.isConnected = false;
|
|
|
|
// _this.roomId = roomId; // ...
|
|
|
|
//
|
|
|
|
// return _this;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// _createClass(Connection, [{
|
|
|
|
// key: "send",
|
|
|
|
// value: function send(message) {
|
|
|
|
// this.sock.write(_binarySerializer["default"].serializeMessage(message));
|
|
|
|
// }
|
|
|
|
// }, {
|
|
|
|
// key: "disconnect",
|
|
|
|
// value: function disconnect() {
|
|
|
|
// this.sock.close();
|
|
|
|
// }
|
|
|
|
// }]);
|
|
|
|
// return Connection;
|
|
|
|
//}(_events.EventEmitter);
|
|
|
|
//
|
|
|
|
//exports["default"] = Connection;
|
|
|
|
//
|
|
|
|
//"#
|
|
|
|
//);
|
|
|
|
|
|
|
|
// extend_builtins_spec
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| chain!(classes(Some(t.comments.clone())), block_scoping()),
|
2019-12-09 15:02:51 +03:00
|
|
|
extend_builtins_spec_exec,
|
|
|
|
r#"
|
|
|
|
class List extends Array {}
|
|
|
|
|
|
|
|
expect(new List).toBeInstanceOf(List);
|
|
|
|
expect(new List).toBeInstanceOf(Array);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_call_semantics_data_defined_on_parent
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
get_set_call_semantics_data_defined_on_parent_exec,
|
|
|
|
r#"
|
|
|
|
"use strict";
|
|
|
|
class Base {
|
|
|
|
test(...args) {
|
|
|
|
expect(this).toBe(obj);
|
|
|
|
expect(args).toEqual([1, 2, 3]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
call() {
|
|
|
|
super.test(1, 2, 3);
|
|
|
|
super.test(1, ...[2, 3]);
|
|
|
|
super.test(...[1, 2, 3]);
|
|
|
|
return super.test(...arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
test() {
|
|
|
|
throw new Error("called");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.call(1, 2, 3)).toBe(1);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_memoized_assign
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
get_set_memoized_assign_exec,
|
|
|
|
r#"
|
|
|
|
"use strict";
|
|
|
|
class Base {}
|
|
|
|
Object.defineProperty(Base.prototype, 0, {
|
|
|
|
value: 0,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
Object.defineProperty(Base.prototype, 1, {
|
|
|
|
value: 1,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
let i = 0;
|
|
|
|
const proper = {
|
|
|
|
get prop() {
|
|
|
|
return i++;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
assign() {
|
|
|
|
super[proper.prop] += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
assign2() {
|
|
|
|
super[i] += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
|
|
|
|
obj.assign();
|
|
|
|
expect(i).toBe(1);
|
|
|
|
expect(obj[0]).toBe(1);
|
|
|
|
expect(obj[1]).toBe(1);
|
|
|
|
|
|
|
|
obj.assign2();
|
|
|
|
expect(i).toBe(1);
|
|
|
|
expect(obj[0]).toBe(1);
|
|
|
|
expect(obj[1]).toBe(2);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
//// regression_5769
|
|
|
|
//test_exec!(
|
|
|
|
// syntax(),
|
|
|
|
// |_| tr(r#"{
|
|
|
|
// "plugins": [ "proposal-class-properties"],
|
|
|
|
// "presets": ["env", "react"]
|
|
|
|
//}
|
|
|
|
//"#),
|
|
|
|
// regression_5769_exec,
|
|
|
|
// r#"
|
|
|
|
//class Point {
|
|
|
|
// getX() {
|
|
|
|
// expect(this.x).toBe(3); // C
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//class ColorPoint extends Point {
|
|
|
|
// constructor() {
|
|
|
|
// super();
|
|
|
|
// this.x = 2;
|
|
|
|
// super.x = 3;
|
|
|
|
// expect(this.x).toBe(3); // A
|
|
|
|
// expect(super.x).toBeUndefined(); // B
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// m() {
|
|
|
|
// this.getX()
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//const cp = new ColorPoint();
|
|
|
|
//cp.m();
|
|
|
|
//
|
|
|
|
//"#
|
|
|
|
//);
|
|
|
|
|
|
|
|
// get_set_get_semantics_setter_defined_on_parent
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
get_set_get_semantics_setter_defined_on_parent_exec,
|
|
|
|
r#"
|
|
|
|
"use strict";
|
|
|
|
class Base {
|
|
|
|
set test(v) {
|
|
|
|
throw new Error("called");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
get() {
|
|
|
|
return super.test;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.test).toBe(2);
|
|
|
|
expect(obj.get()).toBeUndefined();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
//// regression_t7537
|
|
|
|
//test!(
|
|
|
|
// syntax(),
|
|
|
|
// |_| tr(r#"{
|
|
|
|
// "plugins": ["transform-exponentiation-operator"],
|
|
|
|
// "presets": ["env"]
|
|
|
|
//}
|
|
|
|
//"#),
|
|
|
|
// regression_t7537,
|
|
|
|
// r#"
|
|
|
|
//class B{}
|
|
|
|
//class A extends B{
|
|
|
|
// constructor(track){
|
|
|
|
// if (track !== undefined) super(track);
|
|
|
|
// else super();
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//"#,
|
|
|
|
// r#"
|
|
|
|
//function _typeof(obj) { if (typeof Symbol === "function" && typeof
|
|
|
|
// Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return
|
|
|
|
// typeof obj; }; } else { _typeof = function _typeof(obj) { return obj &&
|
|
|
|
// typeof Symbol === "function" && obj.constructor === Symbol && obj !==
|
|
|
|
// Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
//
|
|
|
|
//function _possibleConstructorReturn(self, call) { if (call && (_typeof(call)
|
|
|
|
// === "object" || typeof call === "function")) { return call; } return
|
|
|
|
// _assertThisInitialized(self); }
|
|
|
|
//
|
|
|
|
//function _assertThisInitialized(self) { if (self === void 0) { throw new
|
|
|
|
// ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
|
|
// } return self; }
|
|
|
|
//
|
|
|
|
//function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ?
|
|
|
|
// Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ ||
|
|
|
|
// Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
//
|
|
|
|
//function _inherits(subClass, superClass) { if (typeof superClass !==
|
|
|
|
// "function" && superClass !== null) { throw new TypeError("Super expression
|
|
|
|
// must either be null or a function"); } subClass.prototype =
|
|
|
|
// Object.create(superClass && superClass.prototype, { constructor: { value:
|
|
|
|
// subClass, writable: true, configurable: true } }); if (superClass)
|
|
|
|
// _setPrototypeOf(subClass, superClass); }
|
|
|
|
//
|
|
|
|
//function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ||
|
|
|
|
// function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return
|
|
|
|
// _setPrototypeOf(o, p); }
|
|
|
|
//
|
|
|
|
//function _classCallCheck(instance, Constructor) { if (!(instance instanceof
|
|
|
|
// Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
//
|
|
|
|
//var B = function B() {
|
|
|
|
// "use strict";
|
|
|
|
//
|
|
|
|
// _classCallCheck(this, B);
|
|
|
|
//};
|
|
|
|
//
|
|
|
|
//var A =
|
|
|
|
// /*#__PURE__*/
|
|
|
|
//function (_B) {
|
|
|
|
// "use strict";
|
|
|
|
//
|
|
|
|
// _inherits(A, _B);
|
|
|
|
//
|
|
|
|
// function A(track) {
|
|
|
|
// var _this;
|
|
|
|
//
|
|
|
|
// _classCallCheck(this, A);
|
|
|
|
//
|
|
|
|
// if (track !== undefined) _this = _possibleConstructorReturn(this,
|
|
|
|
// _getPrototypeOf(A).call(this, track));else _this =
|
|
|
|
// _possibleConstructorReturn(this, _getPrototypeOf(A).call(this));
|
|
|
|
// return _possibleConstructorReturn(_this);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// return A;
|
|
|
|
//}(B);
|
|
|
|
//
|
|
|
|
//"#
|
|
|
|
//);
|
|
|
|
|
|
|
|
// regression_t7010
|
|
|
|
test!(
|
|
|
|
// TODO: Unignore this
|
|
|
|
ignore,
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| chain!(tr(t), block_scoping()),
|
2019-12-09 15:02:51 +03:00
|
|
|
regression_t7010,
|
|
|
|
r#"
|
|
|
|
class Foo {
|
|
|
|
constructor(val){
|
|
|
|
this._val = val;
|
|
|
|
}
|
|
|
|
foo2(){
|
|
|
|
return foo2(this._val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
var Foo =
|
|
|
|
/*#__PURE__*/
|
|
|
|
function () {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
function Foo(val) {
|
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
this._val = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Foo, [{
|
|
|
|
key: "foo2",
|
|
|
|
value: function (_foo) {
|
|
|
|
function foo2() {
|
|
|
|
return _foo.apply(this, arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
foo2.toString = function () {
|
|
|
|
return _foo.toString();
|
|
|
|
};
|
|
|
|
|
|
|
|
return foo2;
|
|
|
|
}(function () {
|
|
|
|
return foo2(this._val);
|
|
|
|
})
|
|
|
|
}]);
|
|
|
|
return Foo;
|
|
|
|
}();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
//// regression_2941
|
|
|
|
//test!(
|
|
|
|
// syntax(),
|
|
|
|
// |_| tr(r#"{
|
|
|
|
// "plugins": [ "proposal-class-properties"],
|
|
|
|
// "presets": ["env", "react"]
|
|
|
|
//}
|
|
|
|
//"#),
|
|
|
|
// regression_2941,
|
|
|
|
// r#"
|
|
|
|
//export default class {}
|
|
|
|
//
|
|
|
|
//"#,
|
|
|
|
// r#"
|
|
|
|
//"use strict";
|
|
|
|
//
|
|
|
|
//Object.defineProperty(exports, "__esModule", {
|
|
|
|
// value: true
|
|
|
|
//});
|
|
|
|
//exports["default"] = void 0;
|
|
|
|
//
|
|
|
|
//var _default = function _default() {
|
|
|
|
// _classCallCheck(this, _default);
|
|
|
|
//};
|
|
|
|
//
|
|
|
|
//exports["default"] = _default;
|
|
|
|
//
|
|
|
|
//"#
|
|
|
|
//);
|
|
|
|
|
|
|
|
// get_set_call_semantics_getter_defined_on_parent
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
get_set_call_semantics_getter_defined_on_parent_exec,
|
|
|
|
r#"
|
|
|
|
"use strict";
|
|
|
|
class Base {
|
|
|
|
get test() {
|
|
|
|
expect(this).toBe(obj);
|
|
|
|
return function(...args) {
|
|
|
|
expect(this).toBe(obj);
|
|
|
|
expect(args).toEqual([1, 2, 3]);
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
call() {
|
|
|
|
super.test(1, 2, 3);
|
|
|
|
super.test(1, ...[2, 3]);
|
|
|
|
super.test(...[1, 2, 3]);
|
|
|
|
return super.test(...arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
test() {
|
|
|
|
throw new Error("called");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.call(1, 2, 3)).toBe(1);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_set_semantics_data_defined_on_parent
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
get_set_set_semantics_data_defined_on_parent_exec,
|
|
|
|
r#"
|
|
|
|
"use strict";
|
|
|
|
class Base {
|
|
|
|
}
|
|
|
|
Object.defineProperty(Base.prototype, 'test', {
|
|
|
|
value: 1,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
set() {
|
|
|
|
return super.test = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBe(1);
|
|
|
|
expect(Obj.prototype.test).toBe(2);
|
|
|
|
expect(obj.test).toBe(3);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_get_semantics_getter_defined_on_parent
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
get_set_get_semantics_getter_defined_on_parent_exec,
|
|
|
|
r#"
|
|
|
|
"use strict";
|
|
|
|
class Base {
|
|
|
|
get test() {
|
|
|
|
expect(this).toBe(obj);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
get() {
|
|
|
|
return super.test;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.test).toBe(2);
|
|
|
|
expect(obj.get()).toBe(1);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_memoized_update
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
get_set_memoized_update_exec,
|
|
|
|
r#"
|
|
|
|
"use strict";
|
|
|
|
class Base {}
|
|
|
|
Object.defineProperty(Base.prototype, 0, {
|
|
|
|
value: 0,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
Object.defineProperty(Base.prototype, 1, {
|
|
|
|
value: 1,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
let i = 0;
|
|
|
|
const proper = {
|
|
|
|
get prop() {
|
|
|
|
return i++;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
update() {
|
|
|
|
super[proper.prop]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
update2() {
|
|
|
|
super[i]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
|
|
|
|
obj.update();
|
|
|
|
expect(i).toBe(1);
|
|
|
|
expect(obj[0]).toBe(1);
|
|
|
|
expect(obj[1]).toBe(1);
|
|
|
|
|
|
|
|
obj.update2();
|
|
|
|
expect(i).toBe(1);
|
|
|
|
expect(obj[0]).toBe(1);
|
|
|
|
expect(obj[1]).toBe(2);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_get_semantics_not_defined_on_parent
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
get_set_get_semantics_not_defined_on_parent_exec,
|
|
|
|
r#"
|
|
|
|
"use strict";
|
|
|
|
class Base {
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
get() {
|
|
|
|
return super.test;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.test).toBe(2);
|
|
|
|
expect(obj.get()).toBeUndefined();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_set_semantics_not_defined_on_parent_not_on_obj
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
get_set_set_semantics_not_defined_on_parent_not_on_obj_exec,
|
|
|
|
r#"
|
|
|
|
"use strict";
|
|
|
|
class Base {
|
|
|
|
}
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
set() {
|
|
|
|
return super.test = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.set()).toBe(3);
|
|
|
|
expect(Base.prototype.test).toBeUndefined();
|
|
|
|
expect(Obj.prototype.test).toBeUndefined();
|
|
|
|
expect(obj.test).toBe(3);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// extend_builtins_builtin_objects_throw_when_wrapped
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| chain!(classes(Some(t.comments.clone())), block_scoping()),
|
2019-12-09 15:02:51 +03:00
|
|
|
extend_builtins_builtin_objects_throw_when_wrapped_exec,
|
|
|
|
r#"
|
|
|
|
// JSON is wrapped because it starts with an uppercase letter, but it
|
|
|
|
// should not be possible to extend it anyway.
|
|
|
|
|
|
|
|
expect(() => class BetterJSON extends JSON {}).toThrow();
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// get_set_get_semantics_data_defined_on_parent
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| tr(t),
|
2019-12-09 15:02:51 +03:00
|
|
|
get_set_get_semantics_data_defined_on_parent_exec,
|
|
|
|
r#"
|
|
|
|
"use strict";
|
|
|
|
class Base {
|
|
|
|
}
|
|
|
|
Object.defineProperty(Base.prototype, 'test', {
|
|
|
|
value: 1,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
class Obj extends Base {
|
|
|
|
get() {
|
|
|
|
return super.test;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.defineProperty(Obj.prototype, 'test', {
|
|
|
|
value: 2,
|
|
|
|
writable: true,
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
const obj = new Obj();
|
|
|
|
expect(obj.test).toBe(2);
|
|
|
|
expect(obj.get()).toBe(1);
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// extend_builtins_overwritten_null
|
|
|
|
test_exec!(
|
|
|
|
// Just don't do this.
|
|
|
|
ignore,
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| chain!(classes(Some(t.comments.clone())), block_scoping()),
|
2019-12-09 15:02:51 +03:00
|
|
|
extend_builtins_overwritten_null_exec,
|
|
|
|
r#"
|
|
|
|
var env = {
|
|
|
|
Array: null,
|
|
|
|
};
|
|
|
|
|
|
|
|
// We need to use "with" to avoid leaking the modified Array to other tests.
|
|
|
|
with (env) {
|
|
|
|
class List extends Array {}
|
|
|
|
expect(List.prototype.__proto__).toBeUndefined();
|
|
|
|
}
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
// extend_builtins_super_called
|
|
|
|
test_exec!(
|
|
|
|
// Just don't do this. With is evil.
|
|
|
|
ignore,
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| chain!(classes(Some(t.comments.clone())), block_scoping()),
|
2019-12-09 15:02:51 +03:00
|
|
|
extend_builtins_super_called_exec,
|
|
|
|
r#"
|
|
|
|
var called = false;
|
|
|
|
|
|
|
|
var env = {
|
|
|
|
Array: function Array() {
|
|
|
|
called = true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// We need to use "with" to avoid leaking the modified Array to other tests.
|
|
|
|
with (env) {
|
|
|
|
class List extends Array {};
|
|
|
|
new List();
|
|
|
|
|
|
|
|
expect(called).toBe(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
"#
|
|
|
|
);
|
2020-06-18 11:04:49 +03:00
|
|
|
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| classes(Some(t.comments.clone())),
|
2020-06-18 11:04:49 +03:00
|
|
|
issue_846,
|
|
|
|
r#"
|
|
|
|
class SomeClass {
|
|
|
|
someMethod() {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class OtherClass extends SomeClass {
|
|
|
|
anotherMethod() {
|
|
|
|
expect(super.someMethod()).toBe(1);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const obj = new OtherClass();
|
|
|
|
expect(obj.anotherMethod()).toBe(2);
|
|
|
|
"#
|
|
|
|
);
|
2021-03-30 10:47:12 +03:00
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| classes(Some(t.comments.clone())),
|
2021-03-30 10:47:12 +03:00
|
|
|
issue_1490_1,
|
|
|
|
"
|
|
|
|
class ColouredCanvasElement extends CanvasElement {
|
|
|
|
createFacets(hidden) {
|
|
|
|
hidden = super.createFacets(hidden);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
",
|
|
|
|
"
|
|
|
|
let ColouredCanvasElement = function (CanvasElement) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(ColouredCanvasElement, CanvasElement);
|
|
|
|
function ColouredCanvasElement() {
|
|
|
|
_classCallCheck(this, ColouredCanvasElement);
|
|
|
|
return _possibleConstructorReturn(this, \
|
|
|
|
_getPrototypeOf(ColouredCanvasElement).apply(this, arguments));
|
|
|
|
}
|
|
|
|
_createClass(ColouredCanvasElement, [
|
|
|
|
{
|
|
|
|
key: 'createFacets',
|
|
|
|
value: function createFacets(hidden) {
|
|
|
|
hidden = _get(_getPrototypeOf(ColouredCanvasElement.prototype), \
|
|
|
|
'createFacets', this).call(this, hidden);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
return ColouredCanvasElement;
|
|
|
|
}(CanvasElement);
|
|
|
|
"
|
|
|
|
);
|
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| classes(Some(t.comments.clone())),
|
2021-03-30 10:47:12 +03:00
|
|
|
issue_1490_2,
|
|
|
|
"
|
|
|
|
class ColouredCanvasElement extends CanvasElement {
|
|
|
|
createFacets(hidden) {
|
|
|
|
super.createFacets(hidden);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
",
|
|
|
|
"
|
|
|
|
let ColouredCanvasElement = function (CanvasElement) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(ColouredCanvasElement, CanvasElement);
|
|
|
|
function ColouredCanvasElement() {
|
|
|
|
_classCallCheck(this, ColouredCanvasElement);
|
|
|
|
return _possibleConstructorReturn(this, \
|
|
|
|
_getPrototypeOf(ColouredCanvasElement).apply(this, arguments));
|
|
|
|
}
|
|
|
|
_createClass(ColouredCanvasElement, [
|
|
|
|
{
|
|
|
|
key: 'createFacets',
|
|
|
|
value: function createFacets(hidden) {
|
|
|
|
_get(_getPrototypeOf(ColouredCanvasElement.prototype), 'createFacets', \
|
|
|
|
this).call(this, hidden);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
return ColouredCanvasElement;
|
|
|
|
}(CanvasElement);
|
|
|
|
"
|
|
|
|
);
|
2021-04-18 18:40:06 +03:00
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| classes(Some(t.comments.clone())),
|
2021-04-18 18:40:06 +03:00
|
|
|
super_binding,
|
|
|
|
"
|
|
|
|
class Foo {}
|
|
|
|
class Test extends Foo {
|
|
|
|
foo() {
|
|
|
|
console.log(Foo)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
",
|
|
|
|
"
|
|
|
|
let Foo = function Foo() {
|
|
|
|
'use strict';
|
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
};
|
2021-09-24 13:26:01 +03:00
|
|
|
let Test = function(Foo1) {
|
2021-04-18 18:40:06 +03:00
|
|
|
'use strict';
|
2021-09-24 13:26:01 +03:00
|
|
|
_inherits(Test, Foo1);
|
2021-04-18 18:40:06 +03:00
|
|
|
function Test() {
|
|
|
|
_classCallCheck(this, Test);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Test).apply(this, arguments));
|
|
|
|
}
|
|
|
|
_createClass(Test, [
|
|
|
|
{
|
|
|
|
key: 'foo',
|
|
|
|
value: function foo() {
|
|
|
|
console.log(Foo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
return Test;
|
|
|
|
}(Foo);
|
|
|
|
"
|
|
|
|
);
|
|
|
|
|
|
|
|
test_exec!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| classes(Some(t.comments.clone())),
|
2021-04-18 18:40:06 +03:00
|
|
|
super_binding_exec,
|
|
|
|
"
|
|
|
|
class Foo {}
|
|
|
|
class Test extends Foo {
|
|
|
|
foo() {
|
2021-09-01 16:11:55 +03:00
|
|
|
return 3;
|
2021-04-18 18:40:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Foo = 3;
|
|
|
|
expect(new Test().foo()).toBe(3);
|
|
|
|
"
|
|
|
|
);
|
2021-04-30 09:25:24 +03:00
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| classes(Some(t.comments.clone())),
|
2021-04-30 09:25:24 +03:00
|
|
|
issue_1617_1,
|
|
|
|
"
|
|
|
|
class A extends B {
|
|
|
|
foo() {
|
|
|
|
super.foo(), bar();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
",
|
|
|
|
r#"
|
|
|
|
let A = function(B) {
|
|
|
|
"use strict";
|
|
|
|
_inherits(A, B);
|
|
|
|
function A() {
|
|
|
|
_classCallCheck(this, A);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(A).apply(this, arguments));
|
|
|
|
}
|
|
|
|
_createClass(A, [
|
|
|
|
{
|
|
|
|
key: "foo",
|
|
|
|
value: function foo() {
|
|
|
|
_get(_getPrototypeOf(A.prototype), "foo", this).call(this), bar();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
return A;
|
|
|
|
}(B);
|
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
2021-05-08 09:47:20 +03:00
|
|
|
|t| classes(Some(t.comments.clone())),
|
2021-04-30 09:25:24 +03:00
|
|
|
issue_1617_2,
|
|
|
|
"
|
|
|
|
class A extends B {
|
|
|
|
foo() {
|
|
|
|
super.foo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
",
|
|
|
|
r#"
|
|
|
|
let A = function(B) {
|
|
|
|
"use strict";
|
|
|
|
_inherits(A, B);
|
|
|
|
function A() {
|
|
|
|
_classCallCheck(this, A);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(A).apply(this, arguments));
|
|
|
|
}
|
|
|
|
_createClass(A, [
|
|
|
|
{
|
|
|
|
key: "foo",
|
|
|
|
value: function foo() {
|
|
|
|
_get(_getPrototypeOf(A.prototype), "foo", this).call(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
return A;
|
|
|
|
}(B);
|
|
|
|
"#
|
|
|
|
);
|
2021-05-09 08:23:03 +03:00
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|t| classes(Some(t.comments.clone())),
|
|
|
|
issue_1660_1,
|
|
|
|
"
|
|
|
|
class A {
|
|
|
|
|
|
|
|
}
|
|
|
|
",
|
|
|
|
"
|
|
|
|
let A = function A() {
|
|
|
|
'use strict';
|
|
|
|
_classCallCheck(this, A);
|
|
|
|
};
|
|
|
|
"
|
|
|
|
);
|
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|t| classes(Some(t.comments.clone())),
|
|
|
|
issue_1660_2,
|
|
|
|
"
|
|
|
|
const foo = class {run(){}};
|
|
|
|
",
|
|
|
|
"
|
|
|
|
const foo = function() {
|
|
|
|
'use strict';
|
|
|
|
function _class() {
|
|
|
|
_classCallCheck(this, _class);
|
|
|
|
}
|
|
|
|
_createClass(_class, [
|
|
|
|
{
|
|
|
|
key: 'run',
|
|
|
|
value: function run() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
return _class;
|
|
|
|
}();
|
|
|
|
"
|
|
|
|
);
|
2021-05-10 10:18:31 +03:00
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|t| classes(Some(t.comments.clone())),
|
|
|
|
issue_1660_3,
|
|
|
|
"
|
|
|
|
console.log(class { run() { } });
|
|
|
|
",
|
|
|
|
"
|
|
|
|
console.log(function() {
|
|
|
|
'use strict';
|
|
|
|
function _class() {
|
|
|
|
_classCallCheck(this, _class);
|
|
|
|
}
|
|
|
|
_createClass(_class, [
|
|
|
|
{
|
|
|
|
key: 'run',
|
|
|
|
value: function run() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
return _class;
|
|
|
|
}());
|
|
|
|
"
|
|
|
|
);
|
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|t| {
|
|
|
|
let global_mark = Mark::fresh(Mark::root());
|
|
|
|
|
|
|
|
chain!(
|
2021-09-27 11:03:48 +03:00
|
|
|
es2020::es2020(es2020::Config { loose: false }),
|
2021-05-10 10:18:31 +03:00
|
|
|
es2018::es2018(),
|
|
|
|
es2017::es2017(),
|
|
|
|
es2016::es2016(),
|
|
|
|
es2015::es2015(
|
|
|
|
global_mark,
|
|
|
|
Some(t.comments.clone()),
|
|
|
|
es2015::Config {
|
|
|
|
..Default::default()
|
|
|
|
}
|
|
|
|
),
|
|
|
|
)
|
|
|
|
},
|
|
|
|
issue_1660_4,
|
|
|
|
"
|
|
|
|
console.log(class { run() { } });
|
|
|
|
",
|
|
|
|
"
|
|
|
|
console.log(function() {
|
|
|
|
'use strict';
|
|
|
|
function _class() {
|
|
|
|
_classCallCheck(this, _class);
|
|
|
|
}
|
|
|
|
_createClass(_class, [
|
|
|
|
{
|
|
|
|
key: 'run',
|
|
|
|
value: function run() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
return _class;
|
|
|
|
}());
|
|
|
|
"
|
|
|
|
);
|
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|t| {
|
|
|
|
let global_mark = Mark::fresh(Mark::root());
|
|
|
|
|
|
|
|
chain!(
|
2021-09-27 11:03:48 +03:00
|
|
|
class_properties(class_properties::Config { loose: false }),
|
2021-05-10 10:18:31 +03:00
|
|
|
es2015::es2015(
|
|
|
|
global_mark,
|
|
|
|
Some(t.comments.clone()),
|
|
|
|
es2015::Config {
|
|
|
|
..Default::default()
|
|
|
|
}
|
|
|
|
),
|
|
|
|
)
|
|
|
|
},
|
|
|
|
issue_1660_5,
|
|
|
|
"
|
|
|
|
console.log(class { run() { } });
|
|
|
|
",
|
|
|
|
"
|
|
|
|
console.log(function() {
|
|
|
|
'use strict';
|
|
|
|
function _class() {
|
|
|
|
_classCallCheck(this, _class);
|
|
|
|
}
|
|
|
|
_createClass(_class, [
|
|
|
|
{
|
|
|
|
key: 'run',
|
|
|
|
value: function run() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
return _class;
|
|
|
|
}());
|
|
|
|
"
|
|
|
|
);
|
2021-07-04 13:44:33 +03:00
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|t| tr(t),
|
|
|
|
issue_1838,
|
|
|
|
r#"
|
|
|
|
class Foo {
|
|
|
|
let() {}
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
r#"
|
|
|
|
let Foo = /*#__PURE__*/ function() {
|
|
|
|
"use strict";
|
|
|
|
function Foo() {
|
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
}
|
|
|
|
_createClass(Foo, [
|
|
|
|
{
|
|
|
|
key: "let",
|
|
|
|
value: function _let() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
return Foo;
|
|
|
|
}();
|
|
|
|
"#
|
|
|
|
);
|
2021-07-08 07:54:57 +03:00
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|t| tr(t),
|
|
|
|
issue_1799_1,
|
|
|
|
"
|
|
|
|
export default function Foo() {
|
|
|
|
return call(async (e) => { await doSomething(); })
|
|
|
|
}
|
|
|
|
",
|
|
|
|
"
|
|
|
|
export default function Foo() {
|
|
|
|
return call(async (e)=>{
|
|
|
|
await doSomething();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
"
|
|
|
|
);
|
2021-08-06 17:20:02 +03:00
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|t| {
|
|
|
|
let global_mark = Mark::fresh(Mark::root());
|
|
|
|
|
|
|
|
chain!(
|
2021-09-27 11:03:48 +03:00
|
|
|
class_properties(class_properties::Config { loose: false }),
|
2021-08-06 17:20:02 +03:00
|
|
|
es2015::es2015(
|
|
|
|
global_mark,
|
|
|
|
Some(t.comments.clone()),
|
|
|
|
es2015::Config {
|
|
|
|
..Default::default()
|
|
|
|
}
|
|
|
|
),
|
|
|
|
)
|
|
|
|
},
|
|
|
|
issue_1959_1,
|
|
|
|
"
|
|
|
|
class Extended extends Base {
|
|
|
|
getNext() {
|
|
|
|
return super.getNext(114514) + 114514
|
|
|
|
}
|
|
|
|
}
|
|
|
|
",
|
|
|
|
"
|
|
|
|
var Extended = function(Base) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(Extended, Base);
|
|
|
|
function Extended() {
|
|
|
|
_classCallCheck(this, Extended);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Extended).apply(this, arguments));
|
|
|
|
}
|
|
|
|
_createClass(Extended, [
|
|
|
|
{
|
|
|
|
key: 'getNext',
|
|
|
|
value: function getNext() {
|
|
|
|
return _get(_getPrototypeOf(Extended.prototype), 'getNext', this).call(this, \
|
|
|
|
114514) + 114514;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
return Extended;
|
|
|
|
}(Base);
|
|
|
|
"
|
|
|
|
);
|
|
|
|
|
|
|
|
test!(
|
|
|
|
syntax(),
|
|
|
|
|t| {
|
|
|
|
let global_mark = Mark::fresh(Mark::root());
|
|
|
|
|
|
|
|
chain!(
|
2021-09-27 11:03:48 +03:00
|
|
|
class_properties(class_properties::Config { loose: false }),
|
2021-08-06 17:20:02 +03:00
|
|
|
es2015::es2015(
|
|
|
|
global_mark,
|
|
|
|
Some(t.comments.clone()),
|
|
|
|
es2015::Config {
|
|
|
|
..Default::default()
|
|
|
|
}
|
|
|
|
),
|
|
|
|
)
|
|
|
|
},
|
|
|
|
issue_1959_2,
|
|
|
|
"
|
|
|
|
class Extended extends Base {
|
|
|
|
getNext() {
|
|
|
|
return super.getNext(114514)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
",
|
|
|
|
"
|
|
|
|
var Extended = function(Base) {
|
|
|
|
'use strict';
|
|
|
|
_inherits(Extended, Base);
|
|
|
|
function Extended() {
|
|
|
|
_classCallCheck(this, Extended);
|
|
|
|
return _possibleConstructorReturn(this, _getPrototypeOf(Extended).apply(this, arguments));
|
|
|
|
}
|
|
|
|
_createClass(Extended, [
|
|
|
|
{
|
|
|
|
key: 'getNext',
|
|
|
|
value: function getNext() {
|
|
|
|
return _get(_getPrototypeOf(Extended.prototype), 'getNext', this).call(this, \
|
|
|
|
114514);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
return Extended;
|
|
|
|
}(Base);
|
|
|
|
"
|
|
|
|
);
|
2021-08-30 07:08:24 +03:00
|
|
|
|
|
|
|
#[testing::fixture("tests/fixture/classes/**/exec.js")]
|
|
|
|
fn exec(input: PathBuf) {
|
|
|
|
let src = read_to_string(&input).unwrap();
|
|
|
|
compare_stdout(
|
|
|
|
Default::default(),
|
2021-09-27 11:03:48 +03:00
|
|
|
|t| {
|
|
|
|
chain!(
|
|
|
|
class_properties(class_properties::Config { loose: false }),
|
|
|
|
classes(Some(t.comments.clone()))
|
|
|
|
)
|
|
|
|
},
|
2021-08-30 07:08:24 +03:00
|
|
|
&src,
|
|
|
|
);
|
|
|
|
}
|