Skip to content

Commit

Permalink
add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Mar 3, 2021
1 parent 34b6c92 commit f9123cf
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 0 deletions.
@@ -0,0 +1,29 @@
expect(() => {
class C {
static #_ = new C;
static #p;
constructor() {
C.#p;
}
}
}).toThrow(/attempted to use private field on non-instance/);

expect(() => {
class C {
static #_ = new C;
static #p;
constructor() {
C.#p = 0;
}
}
}).toThrow(/attempted to use private field on non-instance/);

expect(() => {
class C {
static #_ = new C;
static #p;
constructor() {
for (C.#p of [0]);
}
}
}).toThrow(/attempted to use private field on non-instance/);
@@ -0,0 +1,29 @@
expect(() => {
class C {
static #_ = new C;
static #p;
constructor() {
C.#p;
}
}
}).toThrow(/attempted to get private static field before its declaration/);

expect(() => {
class C {
static #_ = new C;
static #p;
constructor() {
C.#p = 0;
}
}
}).toThrow(/attempted to set private static field before its declaration/);

expect(() => {
class C {
static #_ = new C;
static #p;
constructor() {
for (C.#p of [0]);
}
}
}).toThrow(/attempted to set private static field before its declaration/);
@@ -0,0 +1,29 @@
expect(() => {
class C {
static #_ = new C;
static get #p() { return C };
constructor() {
C.#p;
}
}
}).toThrow(/attempted to use private field on non-instance/);

expect(() => {
class C {
static #_ = new C;
static set #p(v) {};
constructor() {
C.#p = 0;
}
}
}).toThrow(/attempted to use private field on non-instance/);

expect(() => {
class C {
static #_ = new C;
static set #p(v) {};
constructor() {
for (C.#p of [0]);
}
}
}).toThrow(/attempted to use private field on non-instance/);
@@ -0,0 +1,29 @@
expect(() => {
class C {
static #_ = new C;
static get #p() { return C };
constructor() {
C.#p;
}
}
}).toThrow(/attempted to use private field on non-instance/);

expect(() => {
class C {
static #_ = new C;
static set #p(v) {};
constructor() {
C.#p = 0;
}
}
}).toThrow(/attempted to use private field on non-instance/);

expect(() => {
class C {
static #_ = new C;
static set #p(v) {};
constructor() {
for (C.#p of [0]);
}
}
}).toThrow(/attempted to use private field on non-instance/);
@@ -0,0 +1,29 @@
expect(() => {
class C {
static #_ = new C;
static get #p() { return C };
constructor() {
C.#p;
}
}
}).toThrow(/attempted to get private static field before its declaration/);

expect(() => {
class C {
static #_ = new C;
static set #p(v) {};
constructor() {
C.#p = 0;
}
}
}).toThrow(/attempted to set private static field before its declaration/);

expect(() => {
class C {
static #_ = new C;
static set #p(v) {};
constructor() {
for (C.#p of [0]);
}
}
}).toThrow(/attempted to set private static field before its declaration/);

0 comments on commit f9123cf

Please sign in to comment.