Skip to content

Commit

Permalink
add accessor test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Mar 1, 2021
1 parent f58c7a5 commit 430c7f8
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 10 deletions.
@@ -0,0 +1,13 @@
let counter = 0;
class Foo {
constructor() {
this.#privateFieldValue = ++counter;
}

get #privateFieldValue() {
return 42;
}
}

expect(() => new Foo).toThrow();
expect(counter).toBe(1);
@@ -0,0 +1,10 @@
let counter = 0;
class Foo {
constructor() {
this.#privateFieldValue = ++counter;
}

get #privateFieldValue() {
return 42;
}
}
@@ -0,0 +1,18 @@
var counter = 0;

var _privateFieldValue = babelHelpers.classPrivateFieldLooseKey("privateFieldValue");

class Foo {
constructor() {
Object.defineProperty(this, _privateFieldValue, {
get: _get_privateFieldValue,
set: void 0
});
babelHelpers.classPrivateFieldLooseBase(this, _privateFieldValue)[_privateFieldValue] = ++counter;
}

}

var _get_privateFieldValue = function () {
return 42;
};
@@ -0,0 +1,13 @@
let counter = 0;
class Foo {
constructor() {
this.#privateFieldValue = ++counter;
}

get #privateFieldValue() {
return 42;
}
}

expect(() => new Foo).toThrow();
expect(counter).toBe(1);
@@ -0,0 +1,10 @@
let counter = 0;
class Foo {
constructor() {
this.#privateFieldValue = ++counter;
}

get #privateFieldValue() {
return 42;
}
}
@@ -0,0 +1,19 @@
var counter = 0;

var _privateFieldValue = new WeakMap();

class Foo {
constructor() {
_privateFieldValue.set(this, {
get: _get_privateFieldValue,
set: void 0
});

babelHelpers.classPrivateMethodSet(++counter);
}

}

var _get_privateFieldValue = function () {
return 42;
};
Expand Up @@ -9,8 +9,5 @@ class Foo {
}
}

try {
new Foo;
} catch (e) {
expect(counter).toBe(1);
}
expect(() => new Foo).toThrow();
expect(counter).toBe(1);
Expand Up @@ -9,8 +9,5 @@ class Foo {
}
}

try {
new Foo;
} catch (e) {
expect(counter).toBe(1);
}
expect(() => new Foo).toThrow();
expect(counter).toBe(1);

0 comments on commit 430c7f8

Please sign in to comment.