Skip to content

Commit

Permalink
test: fix test-readline-position w/o ICU
Browse files Browse the repository at this point in the history
PR-URL: #14489
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
  • Loading branch information
TimothyGu committed Aug 5, 2017
1 parent 34d1b11 commit 3b0ef0b
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions test/parallel/test-readline-position.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,26 @@ const ctrlU = { ctrl: true, name: 'u' };
prompt: ''
});

for (const [cursor, string] of [
const tests = [
[1, 'a'],
[2, 'ab'],
[2, '丁'],
[0, '\u0301'], // COMBINING ACUTE ACCENT
[1, 'a\u0301'], // á
[0, '\u20DD'], // COMBINING ENCLOSING CIRCLE
[2, 'a\u20DDb'], // a⃝b
[0, '\u200E'] // LEFT-TO-RIGHT MARK
]) {
[2, '丁']
];

// The non-ICU JS implementation of character width calculation is only aware
// of the wide/narrow distinction. Only test these more advanced cases when
// ICU is available.
if (process.binding('config').hasIntl) {
tests.push(
[0, '\u0301'], // COMBINING ACUTE ACCENT
[1, 'a\u0301'], // á
[0, '\u20DD'], // COMBINING ENCLOSING CIRCLE
[2, 'a\u20DDb'], // a⃝b
[0, '\u200E'] // LEFT-TO-RIGHT MARK
);
}

for (const [cursor, string] of tests) {
rl.write(string);
assert.strictEqual(rl._getCursorPos().cols, cursor);
rl.write(null, ctrlU);
Expand Down

0 comments on commit 3b0ef0b

Please sign in to comment.