11cb0ef41Sopenharmony_ci// Flags: --expose-internals
21cb0ef41Sopenharmony_ci'use strict';
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst { PassThrough } = require('stream');
51cb0ef41Sopenharmony_ciconst readline = require('readline');
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst ctrlU = { ctrl: true, name: 'u' };
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_cicommon.skipIfDumbTerminal();
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ci{
131cb0ef41Sopenharmony_ci  const input = new PassThrough();
141cb0ef41Sopenharmony_ci  const rl = readline.createInterface({
151cb0ef41Sopenharmony_ci    terminal: true,
161cb0ef41Sopenharmony_ci    input: input,
171cb0ef41Sopenharmony_ci    prompt: ''
181cb0ef41Sopenharmony_ci  });
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ci  const tests = [
211cb0ef41Sopenharmony_ci    [1, 'a'],
221cb0ef41Sopenharmony_ci    [2, 'ab'],
231cb0ef41Sopenharmony_ci    [2, '丁'],
241cb0ef41Sopenharmony_ci    [0, '\u0301'],   // COMBINING ACUTE ACCENT
251cb0ef41Sopenharmony_ci    [1, 'a\u0301'],  // á
261cb0ef41Sopenharmony_ci    [0, '\u20DD'],   // COMBINING ENCLOSING CIRCLE
271cb0ef41Sopenharmony_ci    [2, 'a\u20DDb'], // a⃝b
281cb0ef41Sopenharmony_ci    [0, '\u200E'],   // LEFT-TO-RIGHT MARK
291cb0ef41Sopenharmony_ci  ];
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ci  for (const [cursor, string] of tests) {
321cb0ef41Sopenharmony_ci    rl.write(string);
331cb0ef41Sopenharmony_ci    assert.strictEqual(rl.getCursorPos().cols, cursor);
341cb0ef41Sopenharmony_ci    rl.write(null, ctrlU);
351cb0ef41Sopenharmony_ci  }
361cb0ef41Sopenharmony_ci}
37