class D {
@decorate_initializer accessor #x = 1;
@decorate_getter accessor #x2 = 1;
@decorate_setter @decorate_getter accessor #x3 = 1;
getX() { returnthis.#x;
}
setX(v) { this.#x = v;
}
getX2() { returnthis.#x2;
}
setX2(v) { this.#x2 = v;
}
getX3() { returnthis.#x3;
}
setX3(v) { this.#x3 = v;
}
}
let d = new D();
assertEq(d.getX(), 2);
d.setX(4);
assertEq(d.getX(), 4);
assertEq(d.getX2(), 2);
d.setX2(4);
assertEq(d.getX2(), 8);
assertEq(d.getX3(), 2);
d.setX3(4);
assertEq(d.getX3(), 16);
class E {
@decorate_getter static accessor x = 1;
}
assertEq(E.x, 2);
E.x = 2;
assertEq(E.x, 4);
class F {
@decorate_getter static accessor #x = 1;
getX() { return F.#x;
}
setX(v) {
F.#x = v;
}
}
let f = new F();
assertEq(f.getX(), 2);
f.setX(4);
assertEq(f.getX(), 8);
assertThrowsInstanceOf(() => { class G {
@(() => { return"hello!"; }) accessor x;
}
}, TypeError), "Returning a value other than undefined or a callable throws.";
assertThrowsInstanceOf(() => { class G {
@(() => { return {get: "hello!"}; }) accessor x;
}
}, TypeError), "Returning a value other than undefined or a callable throws.";
assertThrowsInstanceOf(() => { class G {
@(() => { return {set: "hello!"}; }) accessor x;
}
}, TypeError), "Returning a value other than undefined or a callable throws.";
assertThrowsInstanceOf(() => { class G {
@(() => { return {init: "hello!"}; }) accessor x;
}
}, TypeError), "Returning a value other than undefined or a callable throws.";
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.