Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ const nameArb = fc.oneof(
maxLength: 15,
}),
fc.string({
// Iterate by code point, not by `.split('')`: the astral-plane samples
// below (U+2000B, U+2A600) are two UTF-16 code units each, so splitting by
// code unit would offer their surrogate halves as standalone units and
// generate names holding lone surrogates. Those have no UTF-8 encoding —
// every one of them serializes to U+FFFD — which collapses names this
// helper orders as distinct and makes Property 4 fail on ~9% of seeds.
unit: fc.constantFrom(
...'ЯрославльΩμέγα山田太郎홍길동محمدמשהสมชาย𠀋𪘀'.split(''),
...'ЯрославльΩμέγα山田太郎홍길동محمدמשהสมชาย𠀋𪘀',
'\u{10FFFD}',
'�',
'~'
Expand All @@ -41,9 +47,18 @@ const namesArb = fc.array(fc.oneof(nameArb, fc.constantFrom(null, undefined)), {
maxLength: 5,
});

/** Arbitrary: a list holding at least one name that survives normalization. */
const nonEmptyNamesArb = namesArb.filter((names) =>
names.some((n) => typeof n === 'string' && n.trim().length > 0)
/**
* Arbitrary: a list holding at least one name that survives normalization.
*
* Survival is decided by asking the helper itself, not by `.trim()`: `trim`
* only strips whitespace, while normalizeName strips combining marks first, so
* a name made purely of diacritics is non-blank to `trim` yet normalizes away.
* U+1FDD, say, decomposes under NFKD to a space plus two combining marks and
* leaves nothing behind — a `trim`-based precondition would hand such a name to
* the properties below as "authored" and they would rightly disagree.
*/
const nonEmptyNamesArb = namesArb.filter(
(names) => computeDocumentAuthorsSort(names) !== EMPTY_AUTHORS_SORT_KEY
);

/** Strip the ordering bucket prefix to recover the normalized name. */
Expand Down