* test: add test for nullish coalescing Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com> * test: add control group * test: add tests for optional chaining Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com> * test: add tests on optional chaining mixed with private class elements * fix: wrap member chains to IIFE when it is in parameter default * chore: add more testcases * chore: update test fixtures * fix: NodePath.get is always non nullish Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
47 lines
798 B
JavaScript
47 lines
798 B
JavaScript
class Foo {
|
|
static #x = 1;
|
|
static #m = function() { return this.#x; };
|
|
static #self = Foo;
|
|
static self = Foo;
|
|
static getSelf() { return this }
|
|
|
|
static test() {
|
|
const o = { Foo: Foo };
|
|
const deep = { very: { o } };
|
|
function fn() {
|
|
return o;
|
|
}
|
|
function fnDeep() {
|
|
return deep;
|
|
}
|
|
|
|
function f(o, r = o?.Foo.#m()) {
|
|
return r;
|
|
}
|
|
|
|
function g(o, r = o?.Foo.#self.getSelf().#m?.()) {
|
|
return r;
|
|
}
|
|
|
|
function h(fnDeep, r = fnDeep?.().very.o?.Foo?.#m()) {
|
|
return r;
|
|
}
|
|
|
|
function i(fn, r = fn?.().Foo.#self?.getSelf()?.self.#m()) {
|
|
return r;
|
|
}
|
|
|
|
function j(fn, r = (fn().Foo.#self.getSelf().self.#m)?.()) {
|
|
return r;
|
|
}
|
|
|
|
f(o);
|
|
g(o);
|
|
h(fnDeep);
|
|
i(fn);
|
|
j(fn);
|
|
}
|
|
}
|
|
|
|
Foo.test();
|