From 3f48c147fb282e03c54ed97fb490dd92febf1b48 Mon Sep 17 00:00:00 2001 From: Nicolas DUBIEN Date: Sat, 7 Mar 2026 23:56:49 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Check=20for=20missing=20imports=20i?= =?UTF-8?q?n=20test-bundle=20(#920)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary This PR adds the missing `uniformFloat32` and `uniformFloat64` distribution exports to the legacy test bundle and implements validation to ensure all package exports are tested. ## Key Changes - Added imports for `uniformFloat32` and `uniformFloat64` distributions to `test-bundle/run-legacy.cjs` - Added test cases for both float distribution functions to verify they return valid number values in the [0, 1] range - Implemented a new CI check in the build workflow that validates all package exports are imported in the test bundle, preventing future regressions ## Implementation Details The new CI validation step: - Extracts all export paths from `package.json` (excluding the package.json export itself) - Converts export paths to their corresponding import names (e.g., `./distribution/uniformFloat32` → `pure-rand/distribution/uniformFloat32`) - Verifies each export is referenced in `test-bundle/run-legacy.cjs` - Fails the build if any export is missing from the test bundle This ensures comprehensive test coverage of all public API exports going forward. https://claude.ai/code/session_01MosXG7JQU1HtiBDhyxCu7Q --------- Co-authored-by: Claude --- .github/workflows/build-status.yml | 14 ++++++++++++++ test-bundle/run-legacy.cjs | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/.github/workflows/build-status.yml b/.github/workflows/build-status.yml index cc7fb8f..986f05c 100644 --- a/.github/workflows/build-status.yml +++ b/.github/workflows/build-status.yml @@ -471,6 +471,20 @@ jobs: run: mv .git node_modules/.git && pnpm exec packaged --keep-node-modules && mv node_modules/.git .git - name: Retrieve potentially dropped test-bundle run: git restore -s@ -SW -- test-bundle + - name: Ensure all exports are imported in test-bundle + run: | + EXPORTS=$(node -e " + Object.keys(require('./package.json').exports) + .filter(e => e !== './package.json') + .forEach(e => console.log('pure-rand' + e.slice(1))); + ") + for EXPORT in $EXPORTS; do + if ! grep -q "$EXPORT" test-bundle/run-legacy.cjs; then + echo "ERROR: Export '$EXPORT' is not imported in test-bundle/run-legacy.cjs" + exit 1 + fi + done + echo "All exports are imported in test-bundle/run-legacy.cjs" - name: Check bundle run: pnpm test-bundle - name: Check legacy bundle diff --git a/test-bundle/run-legacy.cjs b/test-bundle/run-legacy.cjs index e32eb49..67ccde6 100644 --- a/test-bundle/run-legacy.cjs +++ b/test-bundle/run-legacy.cjs @@ -8,6 +8,8 @@ const { xorshift128plus } = require('pure-rand/generator/xorshift128plus'); const { xoroshiro128plus } = require('pure-rand/generator/xoroshiro128plus'); const { uniformInt } = require('pure-rand/distribution/uniformInt'); const { uniformBigInt } = require('pure-rand/distribution/uniformBigInt'); +const { uniformFloat32 } = require('pure-rand/distribution/uniformFloat32'); +const { uniformFloat64 } = require('pure-rand/distribution/uniformFloat64'); const { generateN } = require('pure-rand/utils/generateN'); const { skipN } = require('pure-rand/utils/skipN'); const { purify } = require('pure-rand/utils/purify'); @@ -32,6 +34,14 @@ const rng = xorshift128plus(42); const value = uniformBigInt(rng, 0n, 100n); assert.ok(typeof value === 'bigint' && value >= 0n && value <= 100n); } +{ + const value = uniformFloat32(rng); + assert.ok(typeof value === 'number' && value >= 0 && value < 1); +} +{ + const value = uniformFloat64(rng); + assert.ok(typeof value === 'number' && value >= 0 && value < 1); +} // Test utils { -- 2.51.2