o
    e.                    @   sR  d dl mZmZmZ d dlZd dlZd dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d dlT d dlT ejd d G d	d
 d
eZG dd deZG dd dejZedkre  eej Zed dd ed!e e  e"dd e#e j$% D Z&e#e& Z&edd e&D Z'ed dd ed!e' dS dS )    )absolute_importprint_functionunicode_literalsN)StringIO)keysyms)lineobj)log)*z../..c                   @   sh   e Zd Zi Zdd Zdd ZeeZdd Zdd Z	ee	Z
d	d
 ZeeZdd Zdd Zdd ZdS )
ViModeTestc                 C   sH   t | t  t | _| d  | d g | _| j| _	d| _
d| _d S )NT    )ViMode__init__ZMockReadlineZMockConsolemock_consoleZinit_editing_modeZvi_set_insert_modelst_completionsmock_completerZ	completerZcompleter_delimsZtabstopself r   HD:\Projects\ConvertPro\env\Lib\site-packages\pyreadline3/test/test_vi.pyr      s   


zViModeTest.__init__c                 C   s   | j S N)r   r   r   r   r   get_mock_console'   s   zViModeTest.get_mock_consolec                 C   s   | j | d S r   )l_bufferZset_line)r   textr   r   r   	_set_line+   s   zViModeTest._set_linec                 C   s
   | j  S r   )r   Zget_line_textr   r   r   r   get_line.      
zViModeTest.get_linec                 C   s   | j jS r   )r   pointr   r   r   r   get_line_cursor2   s   zViModeTest.get_line_cursorc                 C   sx   |d dkr|d dkrdd |dd D }n|g}|D ]}t |\}}| j| | j}|| j|j< || qd S )Nr   "c                 S   s   g | ]}d | qS )z"%s"r   ).0cr   r   r   
<listcomp>8   s    z$ViModeTest.input.<locals>.<listcomp>   )keytext_to_keyinfo_and_eventkey_dispatchgettupleZvi_keytested_commands__name__)r   ZkeytextZlst_keykeykeyinfoeventZdispatch_funcr   r   r   input6   s   
zViModeTest.inputc                 C   s   t | |r| j  d S d S r   )r   vi_accept_liner   Z
reset_line)r   er   r   r   r/   A   s   zViModeTest.vi_accept_linec                 C   s
   | j | S r   )r   )r   r   stater   r   r   r   G   r   zViModeTest.mock_completerN)r*   
__module____qualname__r)   r   r   propertyconsoler   r   liner   line_cursorr.   r/   r   r   r   r   r   r
      s    
r
   c                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )ViExternalEditorTestc                 C   s"   t  | _t d| _t| | d S )Nqwerty after)r   	sio_writesio_readViExternalEditorr   )r   r6   r   r   r   r   L   s   
zViExternalEditorTest.__init__c                 C      dS )Ntemp.pyr   r   r   r   r   get_tempfileQ      z!ViExternalEditorTest.get_tempfilec                 C   r=   )Nzvim.exer   r   r   r   r   
get_editorT   r@   zViExternalEditorTest.get_editorc                 C   s   |dkr| j S | jS )Nw)r:   r;   )r   filenamemoder   r   r   	file_openW   s   zViExternalEditorTest.file_openc                 C   
   || _ d S r   )remove)r   rC   r   r   r   file_remove]   r   z ViExternalEditorTest.file_removec                 C   rF   r   )command)r   rI   r   r   r   run_command`   r   z ViExternalEditorTest.run_commandN)	r*   r2   r3   r   r?   rA   rE   rH   rJ   r   r   r   r   r8   K   s    r8   c                   @   s  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#dCdD Z$dEdF Z%dGdH Z&dIdJ Z'dKdL Z(dMdN Z)dOdP Z*dQdR Z+dSdT Z,dUdV Z-dWdX Z.dYdZ Z/d[d\ Z0d]d^ Z1d_d` Z2dadb Z3dcdd Z4dedf Z5dgdh Z6didj Z7dkdl Z8dmdn Z9dodp Z:dqdr Z;dsdt Z<dudv Z=dwdx Z>dydz Z?d{d| Z@d}d~ ZAdd ZBdd ZCdd ZDdd ZEdd ZFdd ZGdd ZHdd ZIdd ZJdd ZKdd ZLdd ZMdd ZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`dd Zadd Zbdd ZcddĄ ZdddƄ ZeddȄ Zfddʄ Zgdd̄ Zhdd΄ ZiddЄ Zjdd҄ ZkddԄ Zlddք Zmdd؄ Znddڄ Zodd܄ Zpddބ Zqdd Zrdd Zsdd Ztdd Zudd Zvdd Zwdd Zxdd Zydd Zzdd Z{dd Z|dd Z}dd Z~dd Zdd ZdS )Testsc                 C   sl   t d\}}| d|j t d\}}| d|j t d\}}| d|j t d\}}| d|j d S )	N"d"d"D"D"$"$Escape)r%   assertEqualchar)r   r,   r-   r   r   r   test_keyinfoh   s   zTests.test_keyinfoc                 C   s   t  }|d | |j |d | |j | d|j |d | |j  | d|j |d | |j | d|j |d | d|j |d | d	|j d S )
NabcrL   abcdrR   "i""x"Zabcxd"y"Zabcxyd)r
   r   
assertTruevi_is_insert_moder.   rT   r6   r   rr   r   r   test_simpler   s    





zTests.test_simplec                 C   s   t  }|d | d|j |d | d|j |d | d|j |d | d|j |d | d|j d S )	NrW      rR      "0"r   rP   z"^")r
   r   rT   r7   r.   r^   r   r   r   test_begin_and_end   s   




zTests.test_begin_and_endc                 C   sl   t  }|d |d |d |d |d |d | d|j |d | d|j d S )N"abc"Returnz"def"rR   "k"defrW   r
   r.   rT   r6   r^   r   r   r   test_history_add   s   






zTests.test_history_addc                 C   s   t  }|d |d |d |d |d | d|j | d|j |d | d|j | d|jj |d | d|j |d | d|j | d|j |d | d|j |d | d|j | d|j d S )	NrW   rh   ghirR   rg   r   "j"rb   )	r
   add_historyr   r.   rT   r7   r6   r5   
bell_countr^   r   r   r   test_history_alpha   s*   









zTests.test_history_alphac                 C   s  t  }|d |d |d | d|j |d | d|j | d|j |d | d|j | d|j | d|jj |d | d|j |d | d|j | d|j |d | d|j | d|j |d | d|j | d|j d S )	NrW   rh   z"ghi"ra   Upr   Downrk   )r
   rm   r.   rT   r7   r6   r5   rn   r^   r   r   r   test_history_arrow   s.   








zTests.test_history_arrowc                 C   s   t  }|d |d |d |d |d | |jd |d | |jd |d | |jjd	 |d
 |d | |jd d S )Nz"aaa"rf   z	"bbb ccc"rR   z"F D"bbb"u"zbbb cccr   z"ddd"rq   Zddd)r
   r.   rT   r6   r5   rn   r^   r   r   r   test_history_arrow_after_undo   s   








z#Tests.test_history_arrow_after_undoc                 C   s"   |  td |  td  d S )Naz u)r\   Z
vi_is_wordr   r   r   r   test_vi_is_word   s   zTests.test_vi_is_wordc                 C   s   |  dtd |  dtd |  dtdd |  dtdd |  dtdd |  dtd |  d	td
d |  dtddd |  dtddd |  dtddd |  dtddd d S )Nr    r   	abc def urb   ra      	abc.def u   
abc..def uab  cd  ef  ghcountr$      
   )rT   Zvi_pos_word_shortr   r   r   r   test_pos_word_short   s   zTests.test_pos_word_shortc                 C   s   |  dtd |  dtd |  dtdd |  dtdd |  dtdd |  dtd |  d	td
d |  dtddd |  dtddd |  dtddd d S )Nr   rx   r   ry   rb   ra   rz   r{   	   r}   r   a.b  c.d  e.f  g.hr   )rT   Zvi_pos_word_longr   r   r   r   test_pos_word_long   s   zTests.test_pos_word_longc                 C   s   |  dtd |  dtd |  dtdd |  dtdd |  dtdd |  dtd |  d	td
d |  d	td
d |  dtd
d |  dtddd |  dtddd |  dtddd d S )Nr   rx   rb   ry      ra   r   r{      zabc  ...  def ur|      rz   r~   r   r   r$   )rT   Zvi_pos_end_shortr   r   r   r   test_pos_end_short  s   zTests.test_pos_end_shortc                 C   s   |  dtd |  dtd |  dtdd |  dtdd |  dtdd |  dtd |  d	td
 |  d	tdd |  dtddd |  dtddd |  dtddd d S )Nr   rx   rb   ry   r   ra   r   r{   r   z  abc...def uabc  ...def ur|   r   r   r   r   )rT   Zvi_pos_end_longr   r   r   r   test_pos_end_long  s   zTests.test_pos_end_longc                 C   s  |  dtd |  dtdd |  dtdd |  dtdd |  dtdd |  dtd	d
 |  dtd	d |  dtd	d |  dtd	 |  dtdd
 |  dtdd |  dtdd |  d
tdddd |  dtdd
dd d S )Nr   rx   r   abc defr   r|   ra   rz   r      abc  def... uabc def... ghi...   rb   r   )rT   Zvi_pos_back_shortr   r   r   r   test_pos_back_short  s$   zTests.test_pos_back_shortc                 C   s   |  dtd |  dtdd |  dtdd |  dtdd |  dtdd |  dtdd	 |  dtdd |  dtd |  dtd
d	 |  dtd
d |  dtdddd d S )Nr   rx   r   r   r   r|   ra   r   r   r   r   r   rb   r   )rT   Zvi_pos_back_longr   r   r   r   test_pos_back_long/  s   zTests.test_pos_back_longc                 C   s   |  dtdd |  dtdd |  dtdd |  dtddd |  dtddd |  dtdddd	 |  d
tdddd	 d S )Nr    rx   xr   r   rM   ra   rb   r   r   abc def abc def)rT   Zvi_pos_find_char_forwardr   r   r   r   test_pos_find_char_forward<     z Tests.test_pos_find_char_forwardc              	   C   s   |  dtdd |  dtddd |  dtddd |  dtddd |  dtddd |  dtdddd	d
 |  dtdddd	d
 d S )Nr    rx   r   r   r   r   rM   r|   rb   r   r   r   )rT   Zvi_pos_find_char_backwardr   r   r   r   test_pos_find_char_backwardG  s"   z!Tests.test_pos_find_char_backwardc                 C   s   |  dtdd |  dtdd |  dtdd |  dtddd |  dtddd |  dtdddd	 |  d
tdddd	 d S )Nr    rx   r   r   ra   rM   rb   r   r   r   r   )rT   Zvi_pos_to_char_forwardr   r   r   r   test_pos_to_char_forwardV  r   zTests.test_pos_to_char_forwardc              	   C   s   |  dtdd |  dtddd |  dtddd |  dtddd |  dtddd |  dtdddd	d
 |  dtdddd	d
 d S )Nr    rx   r   r   r   r|   rM   r   rb   r   r   r   )rT   Zvi_pos_to_char_backwardr   r   r   r   test_pos_to_char_backwarda  s   
zTests.test_pos_to_char_backwardc                 C      t  }|d |d |d |d | d|j |d | d|j |d | d|j |d | d	|j d
S )zpmotions: lowercase mode is alpha, digit and _, uppercase is delim by spaces
        w/W: forward short/long wordabc_123  def--456.789  xrR   rc   "w"r   r   r   "W"   Nr
   r   r.   rT   r7   r^   r   r   r   test_motion_wordm     






zTests.test_motion_wordc                 C   s   t  }|d |d |d |d | d|j |d | d|j |d |d |d | d|j |d |d	 | d
|j d S )Nz3a b c d e f g h i j k l m n o p q r s t u v w x y zrR   rc   "2"r   r   r   ,   r   0   r   r^   r   r   r   test_motion_word_multiplier}  s   









z!Tests.test_motion_word_multiplierc                 C   r   )zrmotions: lowercase mode is alpha, digit and _, uppercase is delim by spaces
        e/E: to end of short/long wordz  abc_123  --def--456.789  xrR   rc   "e"rz   r      "E"   Nr   r^   r   r   r   test_motion_end  r   zTests.test_motion_endc                 C   sl   t  }|d |d |d |d |d | d|j |d |d | d	|j d S )
N&ab cd ef gh ij kl mn op qr st uv wx yzrR   rc   "3"r   r   z"4"r      r   r^   r   r   r   test_motion_end_multiplier  s   






z Tests.test_motion_end_multiplierc                 C   s   t  }|d |d |d | d|j |d | d|j |d | d|j |d | d	|j |d | d
|j dS )zqmotions: lowercase mode is alpha, digit and _, uppercase is delim by spaces
        b/B: backward short/long wordr   rR   rP   r   "b"      z"B"r   r   Nr   r^   r   r   r   test_motion_backward  s   






zTests.test_motion_backwardc                 C   sz   t  }|d |d |d | d|j |d |d | d|j |d |d | d	|j d S )
Nr   rR   rP   %   r   r      "5"r   r   r^   r   r   r   test_motion_backward_multiplier  s   






z%Tests.test_motion_backward_multiplierc                 C   X   t  }|d |d |d |d | d|j |d | d|j d S )Nr   rR   rc   "f"r   "c"rb   r   r^   r   r   r   test_motion_find_char_forward     




z#Tests.test_motion_find_char_forwardc                 C   f   t  }|d |d |d | d|j |d | d|j |d | d|j d S )Nr   rR   rP   r   "F"r   rb   r   r^   r   r   r   test_motion_find_char_backward     




z$Tests.test_motion_find_char_backwardc                 C   T   t  }|d |d |d |d |d |d | d|j d S )N5ab cd ef 01 23 45 ab cd ef 01 23 45 ab cd ef 01 23 45rR   rc   r   r      r   r^   r   r   r   (test_motion_find_char_forward_multiplier     





z.Tests.test_motion_find_char_forward_multiplierc                 C   b   t  }|d |d |d | d|j |d |d |d | d|j d S )	Nr   rR   rP   4   r   r   rc   r   r   r^   r   r   r   )test_motion_find_char_backward_multiplier     





z/Tests.test_motion_find_char_backward_multiplierc                 C   s   t  }|d |d |d |d |d |d | d|j |d | d	|j |d |d | d
|j |d | d|j |d |d | d|j d S )N1234512345123451234512345rR   rc   r   r   r   r   ";"r      ","r   r   r^   r   r   r   test_motion_find_char_again  s$   











z!Tests.test_motion_find_char_againc                 C   s   t  }|d |d |d |d |d |d | d|j |d | d	|j |d |d | d
|j |d | d|j |d |d | d|j |d |d | d|j d S )Nr   rR   rP   r   r   r   r   r   r   rb   r   r   r   r^   r   r   r   test_motion_find_char_opposite  s*   













z$Tests.test_motion_find_char_oppositec                 C   r   )Nr   rR   rc   "t"r   r   r$   r   r^   r   r   r   test_motion_to_char_forward  r   z!Tests.test_motion_to_char_forwardc                 C   r   )Nr   rR   rP   r   "T"r   ra   r   r^   r   r   r   test_motion_to_char_backward'  r   z"Tests.test_motion_to_char_backwardc                 C   r   )Nr   rR   rc   r   r      r   r^   r   r   r   &test_motion_to_char_forward_multiplier2  r   z,Tests.test_motion_to_char_forward_multiplierc                 C   r   )	Nr   rR   rP   r   r   r   rc      r   r^   r   r   r   'test_motion_to_char_backward_multiplier<  r   z-Tests.test_motion_to_char_backward_multiplierc                 C   s   t  }|d |d |d |d |d | d|j | |jd |d |d |d | d|j | |jd	 |d |d |d | d|j | |jd
 d S )Nzabc de fghi jkl mnopq rstrR   rc   rL   r   r   zde fghi jkl mnopq rstr   zjkl mnopq rstrstr
   r   r.   rT   r7   r6   r^   r   r   r   test_delete_wordG  s$   










zTests.test_delete_wordc                 C   sN   t  }|d |d |d |d | d|j | |jd d S )N"abc de fghi jkl mnopq rst uv wx yzrR   "0w"z"2d3w"r   z	abc wx yzr   r^   r   r   r    test_delete_word_two_multipliers[  s   



z&Tests.test_delete_word_two_multipliersc                 C   @   t  }|d |d |d |d | |jd d S )NZF0123456789012345678901234567890123456789012345678901234567890123456789rR   rc   z"2d3f4"Z567890123456789r
   r   r.   rT   r6   r^   r   r   r   -test_delete_find_char_forward_two_multipliersd  s   


z3Tests.test_delete_find_char_forward_two_multipliersc                 C   r   )Nr   rR   r   rN   abc r   r^   r   r   r   test_delete_end_of_linem  s   



zTests.test_delete_end_of_linec                 C   st   t  }|d | |jd |d |d | |jd |d | |jd |d | |jd	 d S )
Nz"abcdef"ZabcdefrR   z"0iqq"Zqqabcdefrf   rx   z"xyz"Zxyzri   r^   r   r   r   test_two_linesu  s   




zTests.test_two_linesc                 C   b   t  }|d |d |d | d|j |d |d |d | d|j d S )Nabc def ghirR   z"03dw"rx   abc def ghi  r   r^   r   r   r   %test_delete_word_short_to_end_of_line  r   z+Tests.test_delete_word_short_to_end_of_linec                 C   r   )Na.c d.f g.irR   z"03dW"rx   a.c d.f g.i  r   r^   r   r   r   $test_delete_word_long_to_end_of_line  r   z*Tests.test_delete_word_long_to_end_of_linec                 C   b   t  }|d |d |d | d|j |d |d |d | d|j d S )Nr   rR   z"03de"rx   r     r   r^   r   r   r   $test_delete_end_short_to_end_of_line  r   z*Tests.test_delete_end_short_to_end_of_linec                 C   r   )Nr   rR   z"03dE"rx   r   r   r   r^   r   r   r   #test_delete_end_long_to_end_of_line  r   z)Tests.test_delete_end_long_to_end_of_linec                 C   r   )Nr   rR   z"$3db"ir   r   r   r^   r   r   r   *test_delete_back_short_to_begining_of_line  r   z0Tests.test_delete_back_short_to_begining_of_linec                 C   r   )Nr   rR   z"$3dB"r   r   r   r   r^   r   r   r   )test_delete_back_long_to_begining_of_line  r   z/Tests.test_delete_back_long_to_begining_of_linec                 C   sD   t  }|d |d |d | |jd | |jd d S )Nr   rR   z"0ld$"rv   r   r
   r   r.   rT   r6   r7   r^   r   r   r   test_delete_dollar  s   


zTests.test_delete_dollarc                 C   s   t  }|d |d |d | d|j |d | d|j |d | d|j |d	 | d
|j | d|j |d | d|j | d|j d S )Nr   rR   rP   r   z"h"r   z"2h"r   z"2d3h"r$   a ghiz"4dh"r    ghir   r^   r   r   r   test_motion_left     






zTests.test_motion_leftc                 C   s:  t  }|d | |jd | |jd |d | |jd | |jd |d | |jd | |jd |d | |jd | |jd |d	 | |jd | |jd |d
 | |jd | |jd |d	 | |jd | |jd |d	 | |jd | |jd d S )NrR   rx   r   "a"re   rW   ra   rb   "l"Leftr$   r
   r.   rT   r6   r7   r^   r   r   r   test_motion_right  s2   







zTests.test_motion_rightc                 C   s   t  }|d |d |d | d|j |d | d|j |d | d|j |d	 | d|j | d
|j |d | d|j | d|j d S )Nr   rR   rc   r   r   r$   z"2l"ra   z"2d3l"Zabchiz"4dl"rb   rW   r   r^   r   r   r   test_motion_right_delete  r   zTests.test_motion_right_deletec                 C   s   t  }|d |d |d | d|j |d | d|j |d |d | d|j |d	 |d | d
|j | d|j |d |d | d|j | d|j d S )Nr   rR   rP   r   	BackSpacer   r   r   z"2d3"r$   r   z"4d"r   r   r   r^   r   r   r   test_backspace_motion  s$   









zTests.test_backspace_motionc                 C   st   t  }|d |d |d | d|j |d | d|j |d | d|j | d|j d S )	Nr   rR   rP   r   rY   r   r   z
abc def gir   r^   r   r   r   test_backspace_insert  s   




zTests.test_backspace_insertc                 C      t  }|d |d |d |d |d | |j | |jd |d |d |d |d | |jd	 d S )
Nr   rR   r   rY   "zz"zabc zzdef ghir   z"2iyy"zabc zzdef yyyyghir
   r   r.   r\   r]   rT   r6   r^   r   r   r   test_insert_lower_i(     








zTests.test_insert_lower_ic                 C   r  )
Nr   rR   r   z"I"r  zzzabc def ghir   z"2Iyy"zyyyyzzabc def ghir  r^   r   r   r   test_insert_upper_i7  r  zTests.test_insert_upper_ic                 C      t  }|d |d |d |d |d | |jd | |j |d |d |d |d | |jd	 d S )
Nr   rR   rc   r   r  zazzbc def ghir   z"2ayy"zazzbc dyyyyef ghir
   r   r.   rT   r6   r\   r]   r^   r   r   r   test_append_lower_aF     








zTests.test_append_lower_ac                 C   sX   t  }|d |d |d |d |d | |jd | |j  d S )Nrx   rR   z"2A"z"jj"Zjjjjr  r^   r   r   r   test_append_upper_a_simpleU     




z Tests.test_append_upper_a_simplec                 C   r  )
Nr   rR   rc   z"A"r  zabc def ghizzr   z"2Ayy"zabc def ghizzyyyyr  r^   r   r   r   test_append_upper_a_  r
  zTests.test_append_upper_ac                 C   s$  t  }|d |d |d |d | |jd |d | |jd | |jd |d | |jd	 | |jd
 |d | |jd | |jd |d | |jd | |jd |d | |jd | |jd |d | |jd | |jd d S )Nr   rR   r   rZ   zabc efz"4x"r   ra   rW   rb   abr$   rv   r   rx   r   r^   r   r   r   test_delete_lower_xn  s0   









zTests.test_delete_lower_xc                 C   s   t  }|d | |jd |d | |jd |d | |jd |d | |jd | |jd |d	 | |jd
 | |jd |d | |jd | |jd |d | |jd | |jd d S )Nr   r   rR   r   rP   z"X"zabc dfr|   z"4X"afr$   z"2X"fr   )r
   r   rT   r7   r.   r6   r^   r   r   r   test_delete_upper_x  s&   






zTests.test_delete_upper_xc                 C   s   t  }|d |d |d |d |d |d | |jd | |jd |d |d	 |d | |jd
 | |jd |d |d |d |d |d | |jd | |jd d S )Nr   rR   rc   z"s"z"qq"zqqbc defr$   z"3s"z"yyy"zqyyy defra   r   r   r  zqyyy zzr   r   r^   r   r   r   test_substitute_lower_s  s*   













zTests.test_substitute_lower_sc                 C   sn   t  }|d |d |d |d | |j |d | |jd |d | |j  d S )Nr   rR   r   "C""123"abc 123r  r^   r   r   r   test_change_to_end_of_line  s   





z Tests.test_change_to_end_of_linec                 C   s|   t  }|d |d |d |d | |j | |jd |d | |jd |d | |j  d S )Nr   rR   r   z"S"rx   r  Z123r  r^   r   r   r   test_change_whole_line  s   





zTests.test_change_whole_linec                 C   s   t  }|d |d |d | |j | |jd | |jd |d | |j  | |jd |d | |jd |d	 | |jd
 |d | |jd
 d S )Nr   rR   z"0cwzzz"zzz def ghira   rb   r   r   z"2cwyyy"zzzz yyyr
   r   r.   r\   r]   rT   r6   r7   r^   r   r   r   test_change_word_short  s    






zTests.test_change_word_shortc                 C   s   t  }|d |d |d | |jd | |j | |jd |d | |j  | |jd |d | |jd | |j  | |jd	 d S )
Nzabc.def ghi.jkl mno.pqrrR   z"0cWss"zss ghi.jkl mno.pqrrb   r$   "w2."zss ssr   )r
   r   r.   rT   r6   r\   r]   r7   r^   r   r   r   test_change_word_long  s   




zTests.test_change_word_longc                 C   s   t  }|d |d |d | |j | |jd | |jd |d | |j  | |jd |d | |jd d S )	Nr   rR   z"0cezzz"r  ra   rb   r  zzzz zzzr  r^   r   r   r   test_change_end_short     




zTests.test_change_end_shortc                 C      t  }|d |d |d | |j | |jd | |jd |d | |j  | |jd |d | |jd | |jd	 d S )
Nabc.def ghi jkl.mno pqr stu.vwxrR   z"02cEzz"zzz jkl.mno pqr stu.vwxrb   r$   r  zzz zz stu.vwxr|   r  r^   r   r   r   test_change_end_long     




zTests.test_change_end_longc                 C   r   )
Nr   rR   z"$cbzz"zabc def zzir   r   z"b2."Zzzzzirb   r  r^   r   r   r   test_change_back_short  r#  zTests.test_change_back_shortc                 C   s   t  }|d |d |d | |j | |jd | |jd |d | |j  | |jd |d | |jd | |jd	 | |j  d S )
Nr!  rR   z"$2cBzz"zabc.def ghi jkl.mno zzxr      z"5."Zzzzxrb   r  r^   r   r   r   test_change_back_long  s   




zTests.test_change_back_longc                 C   s   t  }|d |d |d | |j | |jd | |jd |d | |j  | |jd |d | |jd |d |d	 | |jd
 d S )Nzaa bb cc dd ee aa bb cc dd eerR   z"0cfbzz"zzzb cc dd ee aa bb cc dd eerb   r$   z"c2fcyy"zzyy dd ee aa bb cc dd ee"."z
zyyy dd eer  r^   r   r   r   test_change_find_lower+  s   






zTests.test_change_find_lowerc                 C   s   t  }|d |d |d | |j | |jd | |jd |d | |j  | |jd |d | |jd d S )Nzaa bb cc aa bb ccrR   z
"$2c2Fazz"Zzzcrb   r$   r'  r  r^   r   r   r   test_change_find_upper<  r  zTests.test_change_find_upperc                 C   s   t  }|d |d |d | |j | |jd | |jd |d | |jd | |jd |d | |j  | |jd	 d S )
Naa bb cc aa bb cc aa bb ccrR   z"02c2ta"aa bb ccr   z"zz "zzz aa bb ccra   rb   r  r^   r   r   r   test_change_to_lowerJ  r#  zTests.test_change_to_lowerc                 C   s   t  }|d |d |d | |j | |jd | |jd |d | |jd | |jd |d | |j  | |jd	 |d
 | |jd | |j  d S )Nr*  rR   z"$2c2Ta"zaa bb cc acr   r  zaa bb cc azzcr   r   "3."Zazzzcr  r^   r   r   r   test_change_to_upperY  s    





zTests.test_change_to_upperc                 C   s  |  dtd |  dtdd |  dtdd |  dtd |  dtdd |  dtdd |  dtdd |  dtdd	 |  dtd
d |  dtd
d |  dtdd |  dtdd |  dtdd |  dtd |  dtd |  dtdd |  dtd |  dtd |  dtdd |  dtd |  dtd |  dtdd d S )Nr   zaa (bb)ra   r   zaa (bb (cc))r   r   r   rz   zaa (bb (cc) dd)r   r   r    zaa ((bb (cc) dd)zaa (bb (cc) dd) ee)r   r   zaa <bb>zaa <bb <cc>>zaa {bb}zaa {bb {cc}}zaa [bb]zaa [bb [cc]])rT   Zvi_pos_matchingr   r   r   r   test_pos_matchingm  s,   zTests.test_pos_matchingc                 C   sX   t  }|d |d |d |d |d | |jd | |jd d S )Nabc (def (ghi)) jklrR   r   rL   "%"abc  jklr   r   r^   r   r   r   test_matching_paren_forward  r  z!Tests.test_matching_paren_forwardc                 C   sp   t  }|d |d |d |d | |jd |d |d | |jd | |jd d S )	Nr0  rR   r   r1  r   rL   r2  r   r   r^   r   r   r   test_matching_paren_backward  s   





z"Tests.test_matching_paren_backwardc                 C   s   t  }|d |d |d | |j  |d | |j  | |jd | |jd |d | |jd | |jd |d	 | |jd
 | |jd d S )Nr   rR   rc   z"yw"r   "P"abc abc defra   "p"zabc abc abc defr   r  r^   r   r   r   test_yank_and_put  s   





zTests.test_yank_and_putc                 C   s   t  }|d |d |d |d | |j  | |jd |d | |jd | |jd |d	 |d
 | |jd | |jd d S )NZ001122rR   rc   z"y3l"r   z"2P"Z001001001122r|   z"f2"z"3p"Z001001001120010010012r   )r
   r   r.   r\   r]   rT   r7   r6   r^   r   r   r   test_put_multiple  s   






zTests.test_put_multiplec                 C   ~   t  }|d |d |d | |jd |d | |jd |d | |jd |d | |jd d S )Nz	aaa b cccrR   z"0ywwp"zaaa baaa  cccrt   r5  zaaa aaa b cccr   r^   r   r   r   test_put_undo     





zTests.test_put_undoc                 C   6   t  }|d |d |d | |jd d S )NrW   rR   "0xp"Zbacr   r^   r   r   r   test_x_and_p  
   


zTests.test_x_and_pc                 C   f   t  }|d |d |d | |jd |d | |jd |d | |jd d S )	Nr   rR   z"0dwep"zdefabc r>  zedfabc r7  zeddfabc r   r^   r   r   r   test_delete_and_put  r   zTests.test_delete_and_putc                 C   rA  )	Nr   rR   "0x"bc defr'  zc defr-  Zefr   r^   r   r   r   test_dot_simple  r   zTests.test_dot_simplec                 C   s   t  }|d |d |d | |jd |d | |jd |d | |jd |d | |jd	 |d
 | |jd d S )Nr   rR   rC  rD  z"$."zbc dez"0."zc dezc dz"^."z dr   r^   r   r   r   "test_dot_movement_not_repeated_one  s   






z(Tests.test_dot_movement_not_repeated_onec                 C   s   t  }|d |d |d | |jd |d | |jd |d | |jd |d	 | |jd
 |d | |jd |d | |jd |d | |jd |d | |jd |d | |jd d S )Nzabc def ghi jkl mno pqrrR   rC  zbc def ghi jkl mno pqr"w."zbc ef ghi jkl mno pqrz"fg."zbc ef hi jkl mno pqrz"2b."zc ef hi jkl mno pqrz"3e."zc ef hi jk mno pqrz"Fh."zc ef i jk mno pqrz"tn."zc ef i jk no pqrz"3h."zc ef i k no pqrz"5l."zc ef i k no qrr   r^   r   r   r   "test_dot_movement_not_repeated_two  s*   










z(Tests.test_dot_movement_not_repeated_twoc                 C   sb   t  }|d |d |d |d |d | |jd |d | |jd d S )Nr   rR   rc   z"2izz "zz zz abc defz"2w."zzz zz abc zz zz defr   r^   r   r   r   test_dot_insert     





zTests.test_dot_insertc                 C   rA  )	Nz0 1 2 3 4 5 6 7 8 9rR   z"02dw"z2 3 4 5 6 7 8 9r'  z4 5 6 7 8 9"1."z	5 6 7 8 9r   r^   r   r   r   test_dot_delete_word  r   zTests.test_dot_delete_wordc                 C   s~   t  }|d |d |d | |jd |d | |jd |d | |jd |d | |jd	 d S )
Nz2ab ab ab ab  ab ab ab ab  ab ab ab ab  ab ab ab abrR   z"02d2fb"z'  ab ab ab ab  ab ab ab ab  ab ab ab abr'  z  ab ab ab ab  ab ab ab abr-  z ab  ab ab ab abz ab abr   r^   r   r   r   test_dot_override_multiplier"  r<  z"Tests.test_dot_override_multiplierc                 C   s~   t  }|d |d |d | |jd |d | |jd |d | |jd |d	 | |jd
 d S )Nr   rR   z"0ywP"r6  r'  zabcabc  abc defr7  zabcabc abc  abc def"2."zabcabc abc abc abc  abc defr   r^   r   r   r   test_dot_yank_and_put/  r<  zTests.test_dot_yank_and_putc                 C   p   t  }|d |d |d |d | |jd |d | |jd |d | |jd d S )	Nr   rR   z"Izz "z
zz abc defr'  rI  rO  zzz zz zz zz abc defr   r^   r   r   r   test_dot_insert_begin<     





zTests.test_dot_insert_beginc                 C   rQ  )	Nr   rR   z"A yy"z
abc def yyr'  zabc def yy yyrO  zabc def yy yy yy yyr   r^   r   r   r   test_dot_append_endH  rS  zTests.test_dot_append_endc                 C   X   t  }|d |d |d |d | |jd |d | |jd d S )Nr   rR   z"b2izz "abc zz zz defr-  zabc zz zzzz zz zz  defr   r^   r   r   r   test_dot_insert_lowerT  r   zTests.test_dot_insert_lowerc                 C   rU  )Nr   rR   z	"0e2a zz"rV  rL  zabc zz zz zz defr   r^   r   r   r   test_dot_append_lower^  r   zTests.test_dot_append_lowerc                 C   rU  )Nr   rR   z"03sqq"zqq defrO  Zqqqdefr   r^   r   r   r   test_dot_substitute_lowerh  r   zTests.test_dot_substitute_lowerc                 C   sj   t  }|d |d |d | |jd | |jd |d | |jd | |jd d S )Nr   rR   z"0wdw"zabc ghir   rt   r   r^   r   r   r   	test_undor  s   



zTests.test_undoc                 C   sX   t  }|d |d |d |d | |jd |d | |jd d S )Nrx   "abc def ghi"rR   "0dwdw"rk   "U"r   r^   r   r   r   test_undo_line}  r   zTests.test_undo_linec                 C   sb   t  }|d |d |d |d |d | |jd |d | |jd d S )Nr  rx   r[  rR   r\  rk   r]  r
   rm   r   r.   rT   r6   r^   r   r   r   test_undo_line_with_history  rK  z!Tests.test_undo_line_with_historyc                 C   s   t  }|d |d |d |d |d |d | |jd | |jd |d	 | |jd
 | |jd | |jjd |d | |jd | |jd d S )Nr  def 456ghi 789r   rR   "/"/r$   r  z/zzra   r   rf   r   )	r
   rm   r   r.   rT   r6   r7   r5   rn   r^   r   r   r   test_history_no_match  s    







zTests.test_history_no_matchc                 C   s   t  }|d |d |d |d |d |d | |jd | |jd |d	 | |jd
 | |jd |d | |jd | |jd d S )Nr  ra  rb  r   rR   rc  rd  r$   z"de"z/dera   rf   r   )r
   rm   r   r.   rT   r6   r7   r^   r   r   r   test_history_found_match  s   







zTests.test_history_found_matchc                 C   s   t  }|d |d |d |d |d |d |d | |jd |d | |jd |d | |jd | |jjd	 |d | |jd |d
 | |jd |d
 | |jd |d
 | |jd d S )Nxyz 123xyz 456xyz 789r   rR   "/xyz"rf   "n"r   "N"r
   rm   r   r.   rT   r6   r5   rn   r^   r   r   r   test_history_multi_match  s,   












zTests.test_history_multi_matchc                 C   s   t  }|d |d |d |d |d |d | |jd |d |d | |jd |d |d | |jd |d |d | |jd d S )	Nrg  rh  ri  rR   rc  rf   rx   z"/x"r
   rm   r.   rT   r6   r^   r   r   r    test_history_search_empty_string  s"   











z&Tests.test_history_search_empty_stringc                 C   s   t  }|d |d |d |d |d |d |d | |jd |d | |jd |d | |jd	 |d |d | |jd |d |d |d
 | |jd d S )Nrg  rh  ri  r   rR   rj  rf   rk  rx   rl  r_  r^   r   r   r   &test_history_search_again_after_return  s(   













z,Tests.test_history_search_again_after_returnc                 C   s   t  }|d |d |d |d |d |d |d | |jd |d | |jd	 |d | |jjd
 |d |d | |jd	 |d |d | |jd	 d S )Nrg  rh  ri  r   rR   rj  rf   r  rx   r   z"/abc"rk  rm  r^   r   r   r   -test_history_search_again_after_search_failed  s&   












z3Tests.test_history_search_again_after_search_failedc                 C   s   t  }|d |d |d |d |d | |jd |d | |jd |d	 | |jd |d |d
 |d |d | |jd |d | |jd |d | |jd d S )Naaars   rx   rR   z"/aaz"z/aazr   z/aarf   z"/z"rl   rg   r_  r^   r   r   r   !test_history_search_and_backspace  s(   












z'Tests.test_history_search_and_backspacec                 C   s  t  }|d |d |d |d | |jd | |j |d | |jd |d | |j  |d | |jd | |j |d | |jd |d |d	 | |jd | |j  |d
 | |jd |d | |jd | |j |d | |jd |d |d | |jd | |j  |d | |jd | |j d S )Nrs  rs   cccrp   "z"ZccczrR   Zbbbzrg   "iz"zaaarq   r[   Zbbbyrl   z"iy"Zyccc)r
   rm   r.   rT   r6   r\   r]   r^   r   r   r   test_history_insert_mode/  sD   















zTests.test_history_insert_modec                 C   s$  t  }| |jjd |d | |jjd |d | |jjd | |jd |d | |jjd | |jd |d | |jjd | |jd |d | |jjd | |jd |d | |jjd | |jd |d | |jjd | |jd d S )	Nr   rs  r$   rs   rb   rx   rp   rq   )r
   rT   Z_historyZhistory_cursorrm   r6   r.   r^   r   r   r   test_history_cursor_arrowS  s,   






zTests.test_history_cursor_arrowc                 C   sh  t  }|d |d | |jd |d | |jd | |jd | |j |d | |jd | |jd | |j |d | |jd | |jd | |j |d | |jd | |jd | |j |d | |jd | |jd | |j |d	 | |jd | |jd | |j  |d | |jd | |jd | |j  |d | |jd | |jd | |j  |d | |jd | |jd | |j  |d
 |d | |jd | |jd | |j  |d | |jd | |jd | |j  d S )Naars   rx   z	Control-pra   rb   z	Control-nr   rR   "/a"rf   )r
   rm   rT   r6   r.   r7   r\   r]   r^   r   r   r   test_history_control_n_and_pk  sb   













z"Tests.test_history_control_n_and_pc                 C   sX   t  }|d |d |d | |jd |d |d | |jd d S )Nrs  rR   z"kiz"rx  rl   rx   ro  r^   r   r   r   test_history_cursor_j_and_k     




z!Tests.test_history_cursor_j_and_kc                 C   r=  )Nrs  rR   z"kAjk"Zaaajkro  r^   r   r   r   test_history_input_j_and_k  r@  z Tests.test_history_input_j_and_kc                 C   s   t  }|d |d |d |d | |jd |d | |jd | |jjd |d |d | |jd d S )	Nrs  rR   r|  rf   rw  rx  r   rl   )r
   rm   r.   rT   r6   r5   rn   r^   r   r   r   test_history_cursor_search  s   






z Tests.test_history_cursor_searchc                 C   sv   t  }|d |d |d |d |d |d |d | |jd |d | |jd d S )Nrs  rR   rg   z"A b"z"A c"zaaa b cr]  ro  r^   r   r   r   test_history_undo  s   







zTests.test_history_undoc                 C   sX   t  }|d |d |d | |jd |d |d | |jd d S )Nrs  rp   z" zz"zaaa zzrR   rt   ro  r^   r   r   r   test_history_arrow_undo  r  zTests.test_history_arrow_undoc                 C   sR   t d}| |jj | |jd | |jj | |jd | |jd d S )Nzqwerty beforezvim.exe temp.pyr>   r9   )	r8   r\   r:   closedrT   rI   r;   rG   result)r   Zveer   r   r   test_editor  s   zTests.test_editorc                 C   sF   t  }g d|_|d |d | |jd | |jjd d S )N)ZaabZaacZaadz"aa"Tabr{  z
aab 
aac 
aad 
)r
   r   r.   rT   r6   r5   r   r^   r   r   r   test_completer  s   


zTests.test_completerc                 C   s   t  }g d|_|d |d | |j  |d | |jd | |jd | |j | |jj	d |d |d | |jd	 | |jd |d
 | |jd | |jd d S )N)ZbbcZbbdZbbez"aa bb"rR   z"*"zaa bbc bbd bbe r   rx   z" "zaa bbc bbd bbe  r'  zaa bbc bbd bbe bbc bbd bbe r   )
r
   r   r.   r\   r]   rT   r6   r7   r5   r   r^   r   r   r   test_completer_star  s"   






zTests.test_completer_starc                 C   s  t  }|d | |jd | |jd |d | |jd | |jd |d | |jd | |jd |d |d |d | |jd	 | |jd
 |d | |jd | |jd |d | |jd | |jd d S )Nr  z    r   ZSpacez     r|   z        rz   z           r   z            r   z                r   r   r^   r   r   r    test_completer_beginning_of_line2  s*   







z&Tests.test_completer_beginning_of_linec                 C   s\  t  }|d |d |d | |jd | |jd | |j  |d | |jd | |jd | |j |d | |jd | |jd	 | |j |d | |jd | |jd | |j  |d
 |d | |jd | |jd | |j  |d | |jd | |jd | |j  d S )Naaa bbb cccrR   z"0ry"zyaa bbb cccr   rY   rZ   zxyaa bbb cccr$   z"ll"z"2rz"zxyzz bbb cccra   z"w7."zxyzz zzzzzzzr   r
   r   r.   rT   r6   r7   r\   r]   r^   r   r   r   test_replace_lowerI  s8   








zTests.test_replace_lowerc                 C   r:  )Nrs  rR   z"0rz"zaart   rO  Zzzar   r^   r   r   r   test_replace_lower_undog  s   





zTests.test_replace_lower_undoc                 C   s~   t  }|d |d |d | |jd |d | |jd |d | |jd |d | |jd d S )Nrs  rR   z"0r"z"r"rv  r  r   r^   r   r   r   test_replace_lower_escapeu  r<  zTests.test_replace_lower_escapec                 C   s   t  }|d |d |d |d | |jd |d |d | |jd |d | |jd |d | |jd |d | |jd d S )	Nr+  rR   z"0cwdd"zdd bb ccz"wr"r'  zdd dd ccrt   r   r^   r   r   r   test_replace_lower_escape_undo  s   








z$Tests.test_replace_lower_escape_undoc                 C   s   t  }|d |d |d | |jd | |jd | |j  |d | |jd | |jd | |j  d S )Nr  rR   z"0rzl"Zzbr$   z"r."zz.r  r^   r   r   r   test_replace_dot  s   



zTests.test_replace_dotc                 C   s   t  }|d |d |d | |jd | |jd | |j |d | |jd | |jd | |j |d | |jd	 | |jd
 | |j |d | |jd | |j  d S )Naaa bbbrR   z"0wR"r   rv  zaaa zbbr|   z"zzz"zaaa zzzzrz   r   r  r^   r   r   r   test_replace_upper  s$   





zTests.test_replace_upperc                 C   s   t  }|d |d |d |d | |jd | |jd | |j  |d | |jd | |jd | |j  |d	 | |jd
 | |jd | |j  d S )Nzaaa bbb ccc dddrR   z"02Rz"zzza bbb ccc dddr$   rG  zzza zzb ccc dddr|   z"w6."zzza zzb zzzzzzd   r  r^   r   r   r   test_replace_upper_dot  s    





zTests.test_replace_upper_dotc                 C   s   t  }|d |d |d |d | |jd |d | |jd |d | |jd |d | |jd d S )Nr  rR   z"0Rzz"zzza bbb cccz"w3."zzza zzzzzzcrt   r   r^   r   r   r   test_replace_upper_undo  s   






zTests.test_replace_upper_undoc                 C   s.  t  }|d |d |d | |jd | |jd | |j |d | |jd | |jd |d | |jd	 | |jd
 |d | |jd | |jd | |j |d | |jd | |jd | |j |d | |jd | |jd | |j |d | |jd | |jd | |j |d | |jd | |jd | |j |d | |jd | |jd | |j  |d | |jd | |jd | |j  |d |d | |jd | |j  d S )Naa bbrR   z"0wRc"zaa cbr   r   zaa ccr|   zaa cccr   r   ra   rb   rL   Zaadbbrt   z"hh"r'  zda bbr  r^   r   r   r   test_replace_backspace_and_dot  sZ   













z$Tests.test_replace_backspace_and_dotc                 C   s   t  }|d |d |d | |jd | |j  |d | |jd | |j  |d | |jd | |j  d S )Nr  rR   z"0wY"r5  z
aa aa bbbbrt   r  r^   r   r   r   test_yank_line  s   




zTests.test_yank_linec                 C   s   t  }|d |d |d | |jd | |jd |d | |jd | |jd |d | |jd | |jd	 |d
 | |jd | |jd |d | |jd | |jd d S )Nr  rR   z"099|"r   z"4|"ra   z"d1|"z bbbr   rt   z"d7|"Zaaabr   r^   r   r   r   test_column  s$   






zTests.test_columnc                 C   s   t  }|d |d |d | |jd | |jd | |j  |d | |jd | |jd | |j  |d | |jd | |jd	 | |j  |d
 | |jd | |jd | |j  d S )Nzaaa B7B cccrR   z"0~"zAaa B7B cccr$   z"h."z"9~"zaAA b7b CCcr   rt   r  r^   r   r   r   test_change_case%  s&   





zTests.test_change_casec                 C   sV  t  }|d |d |d | |jd |d |d | |jd |d |d |d | |jd |d	 | |jd |d
 | |jd |d	 | |jd |d	 | |jd |d	 | |jd |d	 | |jd |d
 | |jd |d
 | |jd |d
 | |jd |d
 | |jd |d	 | |jd |d |d | |jd |d	 | |jd |d
 | |jd |d | |jd |d
 | |jd |d
 | |jd |d
 | |jd |d
 | |jd d S )Nrx   rR   z"Saaa"rs  z"Sbbb"rs   z"Sccc"ru  rt   z	Control-rz"Szzz"zzzr]  r   r^   r   r   r   	test_redo:  sf   



























zTests.test_redoN)r*   r2   r3   rV   r`   rd   rj   ro   rr   ru   rw   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r	  r  r  r  r  r  r  r  r  r  r  r"  r$  r&  r(  r)  r,  r.  r/  r3  r4  r8  r9  r;  r?  rB  rE  rF  rH  rJ  rM  rN  rP  rR  rT  rW  rX  rY  rZ  r^  r`  re  rf  rn  rp  rq  rr  rt  ry  rz  r}  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   rK   f   s    




		





$3
C/rK   __main__z Tested functions <   -
c                 C   s   g | ]}|j |fqS r   )r*   r!   r   r   r   r   r#   }  s    r#   c                 C   s   g | ]}|t vr|qS r   )testedr  r   r   r   r#     s    z Not tested functions )(
__future__r   r   r   sysZunittestior   Zpyreadline3.loggerloggerZpyreadline3r   Zpyreadline3.lineeditorr   r   Zpyreadline3.modes.viZpyreadline3.test.commonpathinsertr   r
   r<   r8   ZTestCaserK   r*   ZTestersortedr)   keysr  printcenterjoindictlistr&   valuesZ	all_funcsZ
not_testedr   r   r   r   <module>   sX   1                