Skip to content

Commit e723c07

Browse files
JLHwungmathiasbynens
authored andcommitted
Preserve explicit Non_Joining records in the default set
Assisted-By: GPT-6 Issue: #110
1 parent 6f33a74 commit e723c07

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

‎scripts/parse-joining-type.mjs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ const parseDerivedJoiningType = (source) => {
3535
}
3636
// Code points that aren’t listed have the default value `Non_Joining`.
3737
const nonJoining = regenerate().addRange(0, 0x10ffff);
38-
for (const codePoints of Object.values(map)) {
39-
nonJoining.remove(codePoints);
38+
for (const [joiningType, codePoints] of Object.entries(map)) {
39+
if (joiningType !== 'Non_Joining') {
40+
nonJoining.remove(codePoints);
41+
}
4042
}
4143
map.Non_Joining = nonJoining;
4244
return map;

‎tests/parser-formats.mjs‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,39 @@ import parseEmojiSequences from '../scripts/parse-emoji-sequences.mjs';
55
import parseBidiBrackets from '../scripts/parse-bidi-brackets.mjs';
66
import parseNameAliases from '../scripts/parse-name-aliases.mjs';
77
import parseSimpleCaseMapping from '../scripts/parse-simple-case-mapping.mjs';
8+
import parseJoiningType from '../scripts/parse-joining-type.mjs';
89
import {
910
parseBlocks,
1011
parseDerivedCoreProperties,
1112
} from '../scripts/parse-blocks-scripts-properties.mjs';
1213
import utils from '../scripts/utils.mjs';
1314

15+
test('Explicit Non_Joining records remain in the default joining set', async (t) => {
16+
t.mock.method(utils, 'readDataFile', (version, type) =>
17+
type === 'derived-joining-type'
18+
? '0041; U\n0042..0043; U\n0628; D\n0300..0301; T\n'
19+
: undefined,
20+
);
21+
const map = await parseJoiningType('18.0.0');
22+
for (const [cp, type] of [
23+
[0x41, 'Non_Joining'],
24+
[0x42, 'Non_Joining'],
25+
[0x43, 'Non_Joining'],
26+
[0x378, 'Non_Joining'],
27+
[0x10ffff, 'Non_Joining'],
28+
[0x628, 'Dual_Joining'],
29+
[0x300, 'Transparent'],
30+
[0x301, 'Transparent'],
31+
]) {
32+
t.assert.ok(map[type].contains(cp));
33+
t.assert.equal(
34+
Object.values(map).filter((set) => set.contains(cp)).length,
35+
1,
36+
);
37+
}
38+
t.assert.equal(map.Non_Joining.toArray().length, 0x110000 - 3);
39+
});
40+
1441
test('Null simple titlecase mappings default to uppercase mappings', async (t) => {
1542
t.mock.method(utils, 'readDataFile', () =>
1643
[

0 commit comments

Comments
 (0)