From e844cd3f277b65bc84212b18e2d4702919244c94 Mon Sep 17 00:00:00 2001 From: Ivan Kopeykin Date: Fri, 12 Apr 2024 11:13:27 +0300 Subject: [PATCH] add more test cases --- lib/util/AppendOnlyStackedSet.js | 8 ++++++++ test/configCases/compiletime/exports-presence/index.js | 9 +++++++++ .../configCases/compiletime/exports-presence/warnings.js | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/lib/util/AppendOnlyStackedSet.js b/lib/util/AppendOnlyStackedSet.js index a87409b69..b4bfa8c07 100644 --- a/lib/util/AppendOnlyStackedSet.js +++ b/lib/util/AppendOnlyStackedSet.js @@ -9,8 +9,13 @@ * @template T */ class AppendOnlyStackedSet { + /** + * @param {Array>} sets an optional array of sets + */ constructor(sets = []) { + /** @type {Array>} */ this._sets = sets; + /** @type {Set|undefined} */ this._current = undefined; } @@ -41,6 +46,9 @@ class AppendOnlyStackedSet { if (this._current) this._current.clear(); } + /** + * @returns {AppendOnlyStackedSet} child + */ createChild() { return new AppendOnlyStackedSet( this._sets.length ? this._sets.slice() : [] diff --git a/test/configCases/compiletime/exports-presence/index.js b/test/configCases/compiletime/exports-presence/index.js index fafc4f5ab..74aa264cb 100644 --- a/test/configCases/compiletime/exports-presence/index.js +++ b/test/configCases/compiletime/exports-presence/index.js @@ -60,6 +60,15 @@ describe("should not add additional warnings/errors", () => { if (`${a}`) {} }); + it("ternary operator", () => { + (c && c.a ? c.a() : 0); + const b1 = c ? c() : 0; + (c && c.a && d && d.a ? c.a(d.a) : 0); + ("a" in c ? c.a() : 0); + ("a" in c && "a" in b ? b.a(c.a) : 0); + (c ? d() : (() => {})()); + }); + it("in operator", () => { if ("a" in m) { justFunction(m.a); } if ("b" in m && "c" in m.b) { justFunction(m.b.c); } diff --git a/test/configCases/compiletime/exports-presence/warnings.js b/test/configCases/compiletime/exports-presence/warnings.js index 0fd6484a2..cd4a0b140 100644 --- a/test/configCases/compiletime/exports-presence/warnings.js +++ b/test/configCases/compiletime/exports-presence/warnings.js @@ -59,6 +59,10 @@ module.exports = [ moduleName: /index/, message: /d.+not found/ }, + { + moduleName: /index/, + message: /d.+not found/ + }, { moduleName: /index/, message: /c.+not found/