blob: f4f20fdabb0934975101e3519e4a7819218c90f0 [file] [log] [blame]
let assert = {
sameValue: function (a, e) {
if (a !== e)
throw new Error("Expected: " + e + " but got: " + a);
},
shouldThrow: function(exception, functor) {
let threwException;
try {
functor();
threwException = false;
} catch(e) {
threwException = true;
if (!e instanceof exception)
throw new Error("Expected to throw: " + exception.name + " but it throws: " + e.name);
}
if (!threwException)
throw new Error("Expected to throw: " + exception.name + " but executed without exception");
}
}
let i = 0;
class Base {
constructor() {
if (i % 2)
this.anotherField = i;
}
}
class C extends Base {
#method() {
return 'test';
}
access() {
return this.#method();
}
}
noInline(C.prototype.access);
for (; i < 10000; i++) {
count = i;
let c = new C();
assert.sameValue(c.access(), 'test');
}
assert.shouldThrow(TypeError, () => {
c.access.call({});
});