chore!: rename 'fit' to 'mustMatch'
MODIFY
packages/exo/src/interface-tools.js
packages/exo/src/interface-tools.js
import { E, Far } from '@endo/far';
-import { listDifference, objectMap, fit, M } from '@endo/patterns';
+import { listDifference, objectMap, mustMatch, M } from '@endo/patterns';
const { quote: q, Fail } = assert;
const { apply, ownKeys } = Reflect;
@@ -20,7 +20,7 @@ const defendSyncArgs = (args, methodGuard, label) => {
optionalArgGuards,
restArgGuard,
);
- fit(harden(args), paramsPattern, label);
+ mustMatch(harden(args), paramsPattern, label);
};
/**
@@ -36,7 +36,7 @@ const defendSyncMethod = (method, methodGuard, label) => {
syncMethod(...args) {
defendSyncArgs(harden(args), methodGuard, label);
const result = apply(method, this, args);
- fit(harden(result), returnGuard, `${label}: result`);
+ mustMatch(harden(result), returnGuard, `${label}: result`);
return result;
},
};
@@ -87,7 +87,7 @@ const defendAsyncMethod = (method, methodGuard, label) => {
return apply(method, this, rawArgs);
});
return E.when(resultP, result => {
- fit(harden(result), returnGuard, `${label}: result`);
+ mustMatch(harden(result), returnGuard, `${label}: result`);
return result;
});
},

MODIFY
packages/patterns/index.js
packages/patterns/index.js
@@ -51,7 +51,7 @@ export {
assertPattern,
assertKeyPattern,
matches,
- fit,
+ mustMatch,
} from './src/patterns/patternMatchers.js';
// ////////////////// Temporary, until these find their proper home ////////////

MODIFY
packages/patterns/src/patterns/patternMatchers.js
packages/patterns/src/patterns/patternMatchers.js
@@ -590,7 +590,7 @@ const makePatternKit = () => {
* @param {Pattern} patt
* @param {string|number} [label]
*/
- const fit = (specimen, patt, label = undefined) => {
+ const mustMatch = (specimen, patt, label = undefined) => {
if (checkMatches(specimen, patt, identChecker, label)) {
return;
}
@@ -1809,7 +1809,7 @@ const makePatternKit = () => {
return harden({
checkMatches,
matches,
- fit,
+ mustMatch,
assertPattern,
isPattern,
assertKeyPattern,
@@ -1828,7 +1828,7 @@ const makePatternKit = () => {
export const {
checkMatches,
matches,
- fit,
+ mustMatch,
assertPattern,
isPattern,
assertKeyPattern,

MODIFY
packages/patterns/src/types.js
packages/patterns/src/types.js
* label?: string|number
* ) => boolean} checkMatches
* @property {(specimen: Passable, patt: Pattern) => boolean} matches
- * @property {(specimen: Passable, patt: Pattern, label?: string|number) => void} fit
+ * @property {(specimen: Passable, patt: Pattern, label?: string|number) => void} mustMatch
* @property {(patt: Pattern) => void} assertPattern
* @property {(patt: Passable) => boolean} isPattern
* @property {(patt: Pattern) => void} assertKeyPattern

MODIFY
packages/patterns/test/test-pattern-limits.js
packages/patterns/test/test-pattern-limits.js
import { test } from './prepare-test-env-ava.js';
import { makeCopyBag, makeCopyMap, makeCopySet } from '../src/keys/checkKey.js';
import {
- fit,
+ mustMatch,
matches,
M,
defaultLimits,
@@ -259,13 +259,17 @@ test('test pattern limits', t => {
const successCase = (specimen, yesPattern) => {
harden(specimen);
harden(yesPattern);
- t.notThrows(() => fit(specimen, yesPattern), `${yesPattern}`);
+ t.notThrows(() => mustMatch(specimen, yesPattern), `${yesPattern}`);
t.assert(matches(specimen, yesPattern), `${yesPattern}`);
};
const failCase = (specimen, noPattern, msg) => {
harden(specimen);
harden(noPattern);
- t.throws(() => fit(specimen, noPattern), { message: msg }, `${noPattern}`);
+ t.throws(
+ () => mustMatch(specimen, noPattern),
+ { message: msg },
+ `${noPattern}`,
+ );
t.false(matches(specimen, noPattern), `${noPattern}`);
};
runTests(successCase, failCase);

MODIFY
packages/patterns/test/test-patterns.js
packages/patterns/test/test-patterns.js
@@ -2,7 +2,7 @@ import { test } from './prepare-test-env-ava.js';
// eslint-disable-next-line import/order
import { makeTagged } from '@endo/marshal';
import { makeCopyBag, makeCopyMap, makeCopySet } from '../src/keys/checkKey.js';
-import { fit, matches, M } from '../src/patterns/patternMatchers.js';
+import { mustMatch, matches, M } from '../src/patterns/patternMatchers.js';
import '../src/types.js';
const runTests = (successCase, failCase) => {
@@ -453,13 +453,17 @@ test('test simple matches', t => {
const successCase = (specimen, yesPattern) => {
harden(specimen);
harden(yesPattern);
- t.notThrows(() => fit(specimen, yesPattern), `${yesPattern}`);
+ t.notThrows(() => mustMatch(specimen, yesPattern), `${yesPattern}`);
t.assert(matches(specimen, yesPattern), `${yesPattern}`);
};
const failCase = (specimen, noPattern, msg) => {
harden(specimen);
harden(noPattern);
- t.throws(() => fit(specimen, noPattern), { message: msg }, `${noPattern}`);
+ t.throws(
+ () => mustMatch(specimen, noPattern),
+ { message: msg },
+ `${noPattern}`,
+ );
t.false(matches(specimen, noPattern), `${noPattern}`);
};
runTests(successCase, failCase);
@@ -472,13 +476,13 @@ test('masking match failure', t => {
'copyMap',
harden({ keys: [M.string()], values: ['x'] }),
);
- t.throws(() => fit(nonSet, M.set()), {
+ t.throws(() => mustMatch(nonSet, M.set()), {
message: 'A passable tagged "match:string" is not a key: "[match:string]"',
});
- t.throws(() => fit(nonBag, M.bag()), {
+ t.throws(() => mustMatch(nonBag, M.bag()), {
message: 'A passable tagged "match:string" is not a key: "[match:string]"',
});
- t.throws(() => fit(nonMap, M.map()), {
+ t.throws(() => mustMatch(nonMap, M.map()), {
message: 'A passable tagged "match:string" is not a key: "[match:string]"',
});
});

chore!: rename 'fit' to 'mustMatch' (#1464)