• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Flags: --expose-internals
2'use strict';
3const common = require('../common');
4const { PassThrough } = require('stream');
5const readline = require('readline');
6const assert = require('assert');
7
8const ctrlU = { ctrl: true, name: 'u' };
9
10common.skipIfDumbTerminal();
11
12{
13  const input = new PassThrough();
14  const rl = readline.createInterface({
15    terminal: true,
16    input: input,
17    prompt: ''
18  });
19
20  const tests = [
21    [1, 'a'],
22    [2, 'ab'],
23    [2, '丁'],
24    [0, '\u0301'],   // COMBINING ACUTE ACCENT
25    [1, 'a\u0301'],  // á
26    [0, '\u20DD'],   // COMBINING ENCLOSING CIRCLE
27    [2, 'a\u20DDb'], // a⃝b
28    [0, '\u200E'],   // LEFT-TO-RIGHT MARK
29  ];
30
31  for (const [cursor, string] of tests) {
32    rl.write(string);
33    assert.strictEqual(rl.getCursorPos().cols, cursor);
34    rl.write(null, ctrlU);
35  }
36}
37