Skip to content

Commit 3b0ef0b

Browse files
committed
test: fix test-readline-position w/o ICU
PR-URL: nodejs#14489 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
1 parent 34d1b11 commit 3b0ef0b

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

test/parallel/test-readline-position.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,26 @@ const ctrlU = { ctrl: true, name: 'u' };
1414
prompt: ''
1515
});
1616

17-
for (const [cursor, string] of [
17+
const tests = [
1818
[1, 'a'],
1919
[2, 'ab'],
20-
[2, '丁'],
21-
[0, '\u0301'], // COMBINING ACUTE ACCENT
22-
[1, 'a\u0301'], // á
23-
[0, '\u20DD'], // COMBINING ENCLOSING CIRCLE
24-
[2, 'a\u20DDb'], // a⃝b
25-
[0, '\u200E'] // LEFT-TO-RIGHT MARK
26-
]) {
20+
[2, '丁']
21+
];
22+
23+
// The non-ICU JS implementation of character width calculation is only aware
24+
// of the wide/narrow distinction. Only test these more advanced cases when
25+
// ICU is available.
26+
if (process.binding('config').hasIntl) {
27+
tests.push(
28+
[0, '\u0301'], // COMBINING ACUTE ACCENT
29+
[1, 'a\u0301'], // á
30+
[0, '\u20DD'], // COMBINING ENCLOSING CIRCLE
31+
[2, 'a\u20DDb'], // a⃝b
32+
[0, '\u200E'] // LEFT-TO-RIGHT MARK
33+
);
34+
}
35+
36+
for (const [cursor, string] of tests) {
2737
rl.write(string);
2838
assert.strictEqual(rl._getCursorPos().cols, cursor);
2939
rl.write(null, ctrlU);

0 commit comments

Comments
 (0)