diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f9811df147..f1122862ef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -103,3 +103,16 @@ jobs: node-version: 12.x - run: npm ci - run: npm run test-cookbook + test-validstrings: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: use node.js v16.x + uses: actions/setup-node@v1 + with: + node-version: 16.x + - run: npm ci + - run: | + cd polyfill + npm install + node --experimental-modules --no-warnings --icu-data-dir ./node_modules/full-icu/ test/validStrings.mjs diff --git a/polyfill/test/validStrings.mjs b/polyfill/test/validStrings.mjs index 67921051cc..13be9766d0 100644 --- a/polyfill/test/validStrings.mjs +++ b/polyfill/test/validStrings.mjs @@ -450,29 +450,34 @@ const comparisonItems = { }; const plainModes = ['Date', 'DateTime', 'MonthDay', 'Time', 'YearMonth']; -const mode = 'Instant'; - -for (let count = 0; count < 1000; count++) { - let generatedData, fuzzed; - do { - generatedData = {}; - fuzzed = goals[mode].generate(generatedData); - } while (plainModes.includes(mode) && /[0-9][zZ]/.test(fuzzed)); - try { - const parsed = ES[`ParseTemporal${mode}String`](fuzzed); - for (let prop of comparisonItems[mode]) { - let expected = generatedData[prop]; - if (prop !== 'ianaName' && prop !== 'offset' && prop !== 'calendar') expected = expected || 0; - assert.equal(parsed[prop], expected); - } - console.log(`${fuzzed} => ok`); - } catch (e) { - if (e instanceof assert.AssertionError) { - console.log(`${fuzzed} => parsed wrong: expected`, e.expected, 'actual', e.actual); - console.log('generated data:', generatedData); - } else { - console.log(`${fuzzed} failed!`, e); +function fuzzMode(mode) { + console.log('// starting to fuzz ' + mode); + for (let count = 0; count < 1000; count++) { + let generatedData, fuzzed; + do { + generatedData = {}; + fuzzed = goals[mode].generate(generatedData); + } while (plainModes.includes(mode) && /[0-9][zZ]/.test(fuzzed)); + try { + const parsed = ES[`ParseTemporal${mode}String`](fuzzed); + for (let prop of comparisonItems[mode]) { + let expected = generatedData[prop]; + if (prop !== 'ianaName' && prop !== 'offset' && prop !== 'calendar') expected = expected || 0; + assert.equal(parsed[prop], expected); + } + console.log(`${fuzzed} => ok`); + } catch (e) { + if (e instanceof assert.AssertionError) { + console.log(`${fuzzed} => parsed wrong: expected`, e.expected, 'actual', e.actual); + console.log('generated data:', generatedData); + } else { + console.log(`${fuzzed} failed!`, e); + } + return 0; } - break; } + console.log('// done fuzzing ' + mode); + return 1; } + +Object.keys(goals).every(fuzzMode);