o
    ¹eq  ã                   @   sæ   d dl mZmZmZ d dlZd dlZd dlm  mZ d dl	Z
d dlmZ d dlmZ d dl	mZ ej d¡ de
j_ejZG dd	„ d	ejƒZG d
d	„ d	ejƒZG dd„ dejƒZG dd„ dejƒZedkrqe ¡  e d¡ZdS dS )é    )Úabsolute_importÚprint_functionÚunicode_literalsN)Úlineobj)ÚLineHistory)Úlogz../..Fc                   @   ó(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚTest_prev_next_historyú	test textc                 C   ó(   t ƒ  | _}dD ]	}| t|ƒ¡ qd S ©N)ÚaaaaÚaabaÚaacaÚakcaÚbbbÚako©r   ÚqÚadd_historyÚRL©Úselfr   Úx© r   úMD:\Projects\ConvertPro\env\Lib\site-packages\pyreadline3/test/test_history.pyÚsetUp   ó   ÿúTest_prev_next_history.setUpc                 C   sÖ   | j }|jdks
J ‚tdƒ}| |¡ | ¡ dksJ ‚| |¡ | ¡ dks(J ‚| |¡ | ¡ dks5J ‚| |¡ | ¡ dksBJ ‚| |¡ | ¡ dksOJ ‚| |¡ | ¡ dks\J ‚| |¡ | ¡ dksiJ ‚d S )	Né   Ú r   r   r   r   r   r   )r   Úhistory_cursorr   Zprevious_historyÚget_line_text©r   ÚhistÚlr   r   r   Útest_previous_history#   s"   






z,Test_prev_next_history.test_previous_historyc                 C   sÄ   | j }| ¡  |jdksJ ‚tdƒ}| |¡ | ¡ dksJ ‚| |¡ | ¡ dks,J ‚| |¡ | ¡ dks9J ‚| |¡ | ¡ dksFJ ‚| |¡ | ¡ dksSJ ‚| |¡ | ¡ dks`J ‚d S )Nr   r    r   r   r   r   r   )r   Úbeginning_of_historyr!   r   Znext_historyr"   r#   r   r   r   Útest_next_history6   s    





z(Test_prev_next_history.test_next_historyN)Ú__name__Ú
__module__Ú__qualname__Útr   r&   r(   r   r   r   r   r	      s
    r	   c                   @   r   )	r	   r
   c                 C   r   r   r   r   r   r   r   r   L   r   r   c                 C   sR   t ƒ }dD ]	}| t|ƒ¡ qtddd}dD ]}| |¡}| ¡ |ks&J ‚qd S )N©r   r   r   z	    aacaxr   r   r   Úaaé   ©Úpoint)r   r   r   r   )r   r   r   Zhistory_search_backwardr"   ©r   r   r   ÚaÚresr   r   r   Útest_history_search_backwardQ   s   
þz3Test_prev_next_history.test_history_search_backwardc                 C   sZ   t ƒ }dD ]	}| t|ƒ¡ q| ¡  tddd}dD ]}| |¡}| ¡ |ks*J ‚qd S )Nr-   r.   r/   r0   )r   r   r   )r   r   r   r'   Zhistory_search_forwardr"   r2   r   r   r   Útest_history_search_forwardZ   s   
þz2Test_prev_next_history.test_history_search_forwardN)r)   r*   r+   r,   r   r5   r6   r   r   r   r   r	   I   s
    	c                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )Ú#Test_history_search_incr_fwd_backwdc                 C   r   r   r   r   r   r   r   r   f   r   z)Test_history_search_incr_fwd_backwd.setUpc                 C   s@   | j }|  | d¡d¡ |  | d¡d¡ |  | d¡d¡ d S )NÚbr   r   Zbb©r   ÚassertEqualZreverse_search_history©r   r   r   r   r   Útest_backward_1k   s   z3Test_history_search_incr_fwd_backwd.test_backward_1c                 C   sR   | j }|  | d¡d¡ |  | d¡d¡ |  | d¡d¡ |  | d¡d¡ d S )Nr3   r   r.   r   Úabr   r9   r;   r   r   r   Útest_backward_2q   s
   z3Test_history_search_incr_fwd_backwd.test_backward_2c                 C   ó   | j }|  | d¡d¡ d S )Nr3   r   ©r   r:   Úforward_search_historyr;   r   r   r   Útest_forward_1x   ó   z2Test_history_search_incr_fwd_backwd.test_forward_1c                 C   s|   | j }d|_|  | d¡d¡ |  | d¡d¡ |  | d¡d¡ |  | d¡d¡ |  | d¡d¡ |  | d¡d¡ d S )	Nr   r3   r   r   Zakr   Zaklr   )r   r!   r:   rA   r;   r   r   r   Útest_forward_2|   s   z2Test_history_search_incr_fwd_backwd.test_forward_2N)r)   r*   r+   r   r<   r>   rB   rD   r   r   r   r   r7   e   s    r7   c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )Ú)Test_empty_history_search_incr_fwd_backwdc                 C   s   t ƒ  | _}d S )N)r   r   r;   r   r   r   r   ˆ   s   z/Test_empty_history_search_incr_fwd_backwd.setUpc                 C   r?   )Nr8   r    r9   r;   r   r   r   r<   ‹   rC   z9Test_empty_history_search_incr_fwd_backwd.test_backward_1c                 C   r?   )Nr3   r    r@   r;   r   r   r   rB      rC   z8Test_empty_history_search_incr_fwd_backwd.test_forward_1N)r)   r*   r+   r   r<   rB   r   r   r   r   rE   ‡   s    rE   Ú__main__zFirst Second Third)Ú
__future__r   r   r   ÚsysZunittestZpyreadline3.lineeditor.historyZ
lineeditorÚhistoryZpyreadline3.loggerZpyreadline3Zpyreadline3.lineeditorr   r   r   ÚpathÚappendÚloggerZsock_silentZReadLineTextBufferr   ZTestCaser	   r7   rE   r)   Úmainr%   r   r   r   r   Ú<module>   s&   ."ý