Skip to content

Commit

Permalink
add check-compat-tests script
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Oct 5, 2021
1 parent 60388ae commit c6e9e48
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@
"bundle-helpers": "webpack --entry ./tests/helpers/qunit-helpers.js --output-filename qunit-helpers.js",
"bundle-tests-global": "webpack --entry ./tests/tests/index.js --output-filename tests.js",
"bundle-tests-pure": "webpack --entry ./tests/pure/index.js --output-filename pure.js",
"check-compat-tests": "zx scripts/check-compat-tests.mjs",
"check-dependencies": "zx scripts/check-dependencies.mjs",
"check-mapping": "zx scripts/check-compat-data-mapping.mjs",
"check-modules-by-versions": "zx scripts/check-compat-data-modules-by-versions.mjs",
"check-unused-modules": "zx scripts/check-unused-modules.mjs",
"check": "run-s check-unused-modules check-modules-by-versions check-mapping check-dependencies",
"check": "run-s check-unused-modules check-compat-tests check-modules-by-versions check-mapping check-dependencies",
"generate-indexes": "zx scripts/generate-indexes.mjs",
"lint": "run-s init test-lint",
"test-lint": "eslint --ext .js,.mjs,.json ./",
Expand Down
46 changes: 46 additions & 0 deletions scripts/check-compat-tests.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { modules } from 'core-js-compat/src/data.mjs';
import '../tests/compat/tests.js';

const modulesSet = new Set(modules);
const tested = new Set(Object.keys(globalThis.tests));
const ignore = new Set([
'esnext.array.filter-out',
'esnext.array.last-index',
'esnext.array.last-item',
'esnext.map.update-or-insert',
'esnext.map.upsert',
'esnext.math.iaddh',
'esnext.math.imulh',
'esnext.math.isubh',
'esnext.math.seeded-prng',
'esnext.math.umulh',
'esnext.object.iterate-entries',
'esnext.object.iterate-keys',
'esnext.object.iterate-values',
'esnext.promise.try',
'esnext.reflect.define-metadata',
'esnext.reflect.delete-metadata',
'esnext.reflect.get-metadata',
'esnext.reflect.get-metadata-keys',
'esnext.reflect.get-own-metadata',
'esnext.reflect.get-own-metadata-keys',
'esnext.reflect.has-metadata',
'esnext.reflect.has-own-metadata',
'esnext.reflect.metadata',
'esnext.string.at',
'esnext.symbol.pattern-match',
'esnext.symbol.replace-all',
'esnext.typed-array.filter-out',
'esnext.weak-map.upsert',
]);

const missed = modules.filter(it => !(tested.has(it) || tested.has(it.replace(/^esnext\./, 'es.')) || ignore.has(it)));

for (const it of tested) {
if (!modulesSet.has(it)) console.log(chalk.red(`added extra compat data test: ${ chalk.cyan(it) }`));
}

if (missed.length) {
console.log(chalk.red('some of compat data tests missed:'));
for (const it of missed) console.log(chalk.cyan(it));
} else console.log(chalk.green('adding of compat data tests not required'));
11 changes: 10 additions & 1 deletion tests/compat/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ GLOBAL.tests = {
&& set.has(0)
&& set[Symbol.toStringTag];
}],
'es.string.at': function () {
'es.string.at-alternative': function () {
return 'a'.at(-1) === 'a';
},
'es.string.code-point-at': function () {
Expand Down Expand Up @@ -1210,6 +1210,9 @@ GLOBAL.tests = {
'esnext.array.find-last-index': function () {
return [].findLastIndex;
},
'esnext.array.group-by': function () {
return [].groupBy;
},
'esnext.array.is-template-object': function () {
return Array.isTemplateObject;
},
Expand Down Expand Up @@ -1485,6 +1488,12 @@ GLOBAL.tests = {
'esnext.typed-array.find-last-index': function () {
return Int8Array.prototype.findLastIndex;
},
'esnext.typed-array.group-by': function () {
return Int8Array.prototype.groupBy;
},
'esnext.typed-array.unique-by': function () {
return Int8Array.prototype.uniqueBy;
},
'esnext.weak-map.delete-all': function () {
return WeakMap.prototype.deleteAll;
},
Expand Down

0 comments on commit c6e9e48

Please sign in to comment.