Commit a3f0f0c6 authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[class] Add tests for private fields with eval

Bug: v8:5368
Change-Id: I3119ce753737afd44a03d2c44348912a96da6c97
Reviewed-on: https://chromium-review.googlesource.com/952481
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51794}
parent e0895667
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
"use strict"; "use strict";
// TODO(gsathya): Missing tests:
// (d) tests involving eval
{ {
class C { class C {
#a; #a;
...@@ -439,3 +437,42 @@ ...@@ -439,3 +437,42 @@
c.b = () => c; c.b = () => c;
assertEquals(1, c.getA(c)); assertEquals(1, c.getA(c));
} }
{
class C {
#a = 1;
getA() { return eval('this.#a'); }
}
let c = new C;
assertEquals(1, c.getA());
}
{
var C;
eval('C = class {#a = 1;getA() { return eval(\'this.#a\'); }}');
let c = new C;
assertEquals(1, c.getA());
}
{
class C {
#a = 1;
getA() { return this.#a; }
setA() { eval('this.#a = 4'); }
}
let c = new C;
assertEquals(1, c.getA());
c.setA();
assertEquals(4, c.getA());
}
{
class C {
getA() { return eval('this.#a'); }
}
let c = new C;
assertThrows(() => c.getA(), SyntaxError);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment