Skip to content

Commit

Permalink
test case for loose private-loose
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhauhau committed May 26, 2019
1 parent b374e44 commit 1772067
Show file tree
Hide file tree
Showing 18 changed files with 225 additions and 0 deletions.
@@ -0,0 +1,17 @@
class Foo {
#client

constructor(props) {
this.#client = 1;
;([this.x = this.#client, this.#client, this.y = this.#client] = props);
}

getClient() {
return this.#client;
}
}

const foo = new Foo([undefined, 'bar']);
expect(foo.getClient()).toBe('bar');
expect(foo.x).toBe(1);
expect(foo.y).toBe('bar');
@@ -0,0 +1,8 @@
class Foo {
#client

constructor(props) {
this.#client = 1;
;([this.x = this.#client, this.#client, this.y = this.#client] = props);
}
}
@@ -0,0 +1,14 @@
var Foo = function Foo(props) {
"use strict";

babelHelpers.classCallCheck(this, Foo);
Object.defineProperty(this, _client, {
writable: true,
value: void 0
});
babelHelpers.classPrivateFieldLooseBase(this, _client)[_client] = 1;
;
[this.x = babelHelpers.classPrivateFieldLooseBase(this, _client)[_client], babelHelpers.classPrivateFieldLooseBase(this, _client)[_client], this.y = babelHelpers.classPrivateFieldLooseBase(this, _client)[_client]] = props;

This comment has been minimized.

Copy link
@nicolo-ribaudo

nicolo-ribaudo May 26, 2019

Member

In loose mode it should already work

};

var _client = babelHelpers.classPrivateFieldLooseKey("client");
@@ -0,0 +1,15 @@
class Foo {
#client

constructor(props) {
let x;
;([x, ...this.#client] = props);
}

getClient() {
return this.#client;
}
}

const foo = new Foo(['foo', 'bar', 'baz', 'quu']);
expect(foo.getClient()).toEqual(['bar', 'baz', 'quu']);
@@ -0,0 +1,7 @@
class Foo {
#client

constructor(props) {
;([x, ...this.#client] = props);
}
}
@@ -0,0 +1,13 @@
var Foo = function Foo(props) {
"use strict";

babelHelpers.classCallCheck(this, Foo);
Object.defineProperty(this, _client, {
writable: true,
value: void 0
});
;
[x, ...babelHelpers.classPrivateFieldLooseBase(this, _client)[_client]] = props;
};

var _client = babelHelpers.classPrivateFieldLooseKey("client");
@@ -0,0 +1,14 @@
class Foo {
#client

constructor(props) {
;([this.#client] = props);
}

getClient() {
return this.#client;
}
}

const foo = new Foo(['bar']);
expect(foo.getClient()).toBe('bar');
@@ -0,0 +1,7 @@
class Foo {
#client

constructor(props) {
;([this.#client] = props);
}
}
@@ -0,0 +1,13 @@
var Foo = function Foo(props) {
"use strict";

babelHelpers.classCallCheck(this, Foo);
Object.defineProperty(this, _client, {
writable: true,
value: void 0
});
;
[babelHelpers.classPrivateFieldLooseBase(this, _client)[_client]] = props;
};

var _client = babelHelpers.classPrivateFieldLooseKey("client");
@@ -0,0 +1,17 @@
class Foo {
#client

constructor(props) {
this.#client = 'foo';
;({ x: this.x = this.#client, y: this.#client, z: this.z = this.#client } = props)
}

getClient() {
return this.#client;
}
}

const foo = new Foo({ y: 'bar' });
expect(foo.getClient()).toBe('bar');
expect(foo.x).toBe('foo');
expect(foo.z).toBe('bar');
@@ -0,0 +1,8 @@
class Foo {
#client

constructor(props) {
this.#client = 'foo';
;({ x: this.x = this.#client, y: this.#client, z: this.z = this.#client } = props)
}
}
@@ -0,0 +1,18 @@
var Foo = function Foo(props) {
"use strict";

babelHelpers.classCallCheck(this, Foo);
Object.defineProperty(this, _client, {
writable: true,
value: void 0
});
babelHelpers.classPrivateFieldLooseBase(this, _client)[_client] = 'foo';
;
({
x: this.x = babelHelpers.classPrivateFieldLooseBase(this, _client)[_client],
y: babelHelpers.classPrivateFieldLooseBase(this, _client)[_client],
z: this.z = babelHelpers.classPrivateFieldLooseBase(this, _client)[_client]
} = props);
};

var _client = babelHelpers.classPrivateFieldLooseKey("client");
@@ -0,0 +1,15 @@
class Foo {
#client

constructor(props) {
let x;
;({ x, ...this.#client } = props)
}

getClient() {
return this.#client;
}
}

const foo = new Foo({ x: 'foo', y: 'bar', z: 'baz' });
expect(foo.getClient()).toEqual({ y: 'bar', z: 'baz' });
@@ -0,0 +1,7 @@
class Foo {
#client

constructor(props) {
;({ x, ...this.#client } = props)
}
}
@@ -0,0 +1,16 @@
var Foo = function Foo(props) {
"use strict";

babelHelpers.classCallCheck(this, Foo);
Object.defineProperty(this, _client, {
writable: true,
value: void 0
});
;
({
x,
...babelHelpers.classPrivateFieldLooseBase(this, _client)[_client]
} = props);
};

var _client = babelHelpers.classPrivateFieldLooseKey("client");
@@ -0,0 +1,14 @@
class Foo {
#client

constructor(props) {
;({ client: this.#client } = props)
}

getClient() {
return this.#client;
}
}

const foo = new Foo({ client: 'bar' });
expect(foo.getClient()).toBe('bar');
@@ -0,0 +1,7 @@
class Foo {
#client

constructor(props) {
;({ client: this.#client } = props)
}
}
@@ -0,0 +1,15 @@
var Foo = function Foo(props) {
"use strict";

babelHelpers.classCallCheck(this, Foo);
Object.defineProperty(this, _client, {
writable: true,
value: void 0
});
;
({
client: babelHelpers.classPrivateFieldLooseBase(this, _client)[_client]
} = props);
};

var _client = babelHelpers.classPrivateFieldLooseKey("client");

0 comments on commit 1772067

Please sign in to comment.