Skip to content

Commit fbeb949

Browse files
committed
squash: rename from can to must
1 parent be6b1f6 commit fbeb949

4 files changed

Lines changed: 21 additions & 21 deletions

File tree

test/common/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ If `fn` is not provided, an empty function will be used.
299299
Returns a function that triggers an `AssertionError` if it is invoked. `msg` is
300300
used as the error message for the `AssertionError`.
301301

302-
### `canNotMutateObjectDeep([target])`
302+
### `mustNotMutateObjectDeep([target])`
303303

304304
* `target` [\<any>][<any>] default = `undefined`
305305
* return [\<any>][<any>]
@@ -313,10 +313,10 @@ APIs that work with user-provided objects.
313313

314314
```mjs
315315
import { open } from 'node:fs/promises';
316-
import { canNotMutateObjectDeep } from '../common/index.mjs';
316+
import { mustNotMutateObjectDeep } from '../common/index.mjs';
317317

318318
const _mutableOptions = { length: 4, position: 8 };
319-
const options = canNotMutateObjectDeep(_mutableOptions);
319+
const options = mustNotMutateObjectDeep(_mutableOptions);
320320

321321
// In filehandle.read or filehandle.write, attempt to mutate options will throw
322322
// In the test code, options can still be mutated via _mutableOptions
@@ -326,7 +326,7 @@ _mutableOptions.position = 4;
326326
await fh.write(buffer, options);
327327

328328
// Inline usage
329-
const stats = await fh.stat(canNotMutateObjectDeep({ bigint: true }));
329+
const stats = await fh.stat(mustNotMutateObjectDeep({ bigint: true }));
330330
console.log(stats.size);
331331
```
332332

test/common/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -519,22 +519,22 @@ function mustNotCall(msg) {
519519
};
520520
}
521521

522-
const _canNotMutateObjectDeepProxies = new WeakMap();
522+
const _mustNotMutateObjectDeepProxies = new WeakMap();
523523

524-
function canNotMutateObjectDeep(original) {
524+
function mustNotMutateObjectDeep(original) {
525525
// Return primitives and functions directly. Primitives are immutable, and
526526
// proxied functions are impossible to compare against originals, e.g. with
527527
// `assert.deepEqual()`.
528528
if (original === null || typeof original !== 'object') {
529529
return original;
530530
}
531531

532-
const cachedProxy = _canNotMutateObjectDeepProxies.get(original);
532+
const cachedProxy = _mustNotMutateObjectDeepProxies.get(original);
533533
if (cachedProxy) {
534534
return cachedProxy;
535535
}
536536

537-
const _canNotMutateObjectDeepHandler = {
537+
const _mustNotMutateObjectDeepHandler = {
538538
__proto__: null,
539539
defineProperty(target, property, descriptor) {
540540
assert.fail(`Expected no side effects, got ${inspect(property)} ` +
@@ -545,7 +545,7 @@ function canNotMutateObjectDeep(original) {
545545
'deleted');
546546
},
547547
get(target, prop, receiver) {
548-
return canNotMutateObjectDeep(Reflect.get(target, prop, receiver));
548+
return mustNotMutateObjectDeep(Reflect.get(target, prop, receiver));
549549
},
550550
preventExtensions(target) {
551551
assert.fail('Expected no side effects, got extensions prevented on ' +
@@ -560,8 +560,8 @@ function canNotMutateObjectDeep(original) {
560560
}
561561
};
562562

563-
const proxy = new Proxy(original, _canNotMutateObjectDeepHandler);
564-
_canNotMutateObjectDeepProxies.set(original, proxy);
563+
const proxy = new Proxy(original, _mustNotMutateObjectDeepHandler);
564+
_mustNotMutateObjectDeepProxies.set(original, proxy);
565565
return proxy;
566566
}
567567

@@ -873,7 +873,7 @@ const common = {
873873
mustCall,
874874
mustCallAtLeast,
875875
mustNotCall,
876-
canNotMutateObjectDeep,
876+
mustNotMutateObjectDeep,
877877
mustSucceed,
878878
nodeProcessAborted,
879879
PIPE,

test/common/index.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const {
3535
canCreateSymLink,
3636
getCallSite,
3737
mustNotCall,
38-
canNotMutateObjectDeep,
38+
mustNotMutateObjectDeep,
3939
printSkipMessage,
4040
skip,
4141
nodeProcessAborted,
@@ -82,7 +82,7 @@ export {
8282
canCreateSymLink,
8383
getCallSite,
8484
mustNotCall,
85-
canNotMutateObjectDeep,
85+
mustNotMutateObjectDeep,
8686
printSkipMessage,
8787
skip,
8888
nodeProcessAborted,

test/parallel/test-common-can-not-mutate-object-deep.mjs renamed to test/parallel/test-common-must-not-mutate-object-deep.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { canNotMutateObjectDeep } from '../common/index.mjs';
1+
import { mustNotMutateObjectDeep } from '../common/index.mjs';
22
import assert from 'node:assert';
33
import { promisify } from 'node:util';
44

5-
// Test common.canNotMutateObjectDeep()
5+
// Test common.mustNotMutateObjectDeep()
66

77
const original = {
88
foo: { bar: 'baz' },
@@ -17,7 +17,7 @@ const original = {
1717
const backup = structuredClone(original);
1818

1919
// Wrapper for convenience
20-
const obj = () => canNotMutateObjectDeep(original);
20+
const obj = () => mustNotMutateObjectDeep(original);
2121

2222
function testOriginal(root) {
2323
assert.deepStrictEqual(root, backup);
@@ -194,16 +194,16 @@ function setPrototypeOfQuux(root) {
194194
undefined, null, false, true, 42, 42n, Symbol('42'), NaN, Infinity, {}, [],
195195
() => {}, async () => {}, Promise.resolve(), Math, Object.create(null),
196196
].forEach((target) => {
197-
assert.deepStrictEqual(canNotMutateObjectDeep(target), target);
198-
assert.deepStrictEqual(canNotMutateObjectDeep({ target }), { target });
199-
assert.deepStrictEqual(canNotMutateObjectDeep([ target ]), [ target ]);
197+
assert.deepStrictEqual(mustNotMutateObjectDeep(target), target);
198+
assert.deepStrictEqual(mustNotMutateObjectDeep({ target }), { target });
199+
assert.deepStrictEqual(mustNotMutateObjectDeep([ target ]), [ target ]);
200200
});
201201

202202
// Test that passed functions keep working correctly
203203
{
204204
const fn = () => 'blep';
205205
fn.foo = {};
206-
const fnImmutableView = canNotMutateObjectDeep(fn);
206+
const fnImmutableView = mustNotMutateObjectDeep(fn);
207207
assert.deepStrictEqual(fnImmutableView, fn);
208208

209209
// The function works

0 commit comments

Comments
 (0)