Skip to content

Commit 8973e90

Browse files
committed
Add testcase that unhandled exception occurs when a private variable increments. (#5238)
1 parent d5dd7e8 commit 8973e90

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

tests/jerry/private_fields.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ check_syntax_error("class A { static *#bar(x) { } #bar }");
5353
check_syntax_error("class A { async *#bar(x) { } #bar }");
5454
check_syntax_error("class A { async #bar(x) { } #bar }");
5555
check_syntax_error("class A { *#bar(x) { } #bar }");
56+
check_syntax_error("class A { #a; foo(){ ++this.#a; --this.#a; this.#a++; this.#a--; }}");
5657

5758

5859
class A {
@@ -350,3 +351,23 @@ class Q extends Array {
350351

351352
var var18 = new Q();
352353
assert(var18.b() == 1);
354+
355+
class R {
356+
#a = 0;
357+
test() {
358+
++this.#a;
359+
assert(this.#a == 1);
360+
assert(++this.#a == 2);
361+
--this.#a;
362+
assert(this.#a == 1);
363+
assert(--this.#a == 0);
364+
this.#a++;
365+
assert(this.#a == 1);
366+
assert(this.#a++ == 1);
367+
this.#a--;
368+
assert(this.#a == 1);
369+
assert(this.#a-- == 1);
370+
}
371+
}
372+
var var19 = new R();
373+
var19.test();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
class A {
16+
#a = 0;
17+
incr() {
18+
this.#a++;
19+
}
20+
}

0 commit comments

Comments
 (0)