o
    ?n0j˜  ã                   @   s¨   d 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mZ G d	d
„ d
ejƒZG dd„ dejƒZdd„ Zdd„ ZedkrRe ¡  dS dS )zTests for yapf.logical_line.é    N)Úpytree)Útoken)Úsplit_penalty)Úformat_token)Úlogical_line)Úyapf_test_helperc                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚLogicalLineBasicTestc                 C   sV   t tjddftjddfgƒ}t d|¡}|  d|j¡ |  ddgdd„ |jD ƒ¡ d S )NÚ.ÚDOTú|ÚVBARé   c                 S   ó   g | ]}|j ‘qS © ©Úname©Ú.0Útokr   r   úb/home/wildlama/miniconda3/envs/lam_a2e/lib/python3.10/site-packages/yapftests/logical_line_test.pyÚ
<listcomp>$   ó    z9LogicalLineBasicTest.testConstruction.<locals>.<listcomp>)	Ú_MakeFormatTokenListr   r
   r   r   ÚLogicalLineÚassertEqualÚdepthÚtokens©ÚselfÚtoksÚlliner   r   r   ÚtestConstruction   s   
ÿ z%LogicalLineBasicTest.testConstructionc                 C   sd   t tjddftjddftjddfgƒ}t d|¡}|  d|j¡ |  d|j	j
¡ |  d|jj
¡ d S )Nr	   r
   ú(ÚLPARr   r   r   )r   r   r
   r#   r   r   r   r   r   Úfirstr   Úlastr   r   r   r   ÚtestFirstLast&   s   

þz"LogicalLineBasicTest.testFirstLastc                 C   sF   t tjddftjddftjddfgƒ}t d|¡}|  d| ¡ ¡ d S )	Nr	   r
   r"   r#   r   r   é   z	    . ( |)	r   r   r
   r#   r   r   r   r   ZAsCoder   r   r   r   Ú
testAsCode/   s   

þzLogicalLineBasicTest.testAsCodec                 C   sR   t  d¡}| ttjddƒ¡ | ttjddƒ¡ |  ddgdd„ |jD ƒ¡ d S )Nr   r"   r#   ú)ÚRPARc                 S   r   r   r   r   r   r   r   r   :   r   z8LogicalLineBasicTest.testAppendToken.<locals>.<listcomp>)	r   r   ZAppendTokenÚ_MakeFormatTokenLeafr   r#   r*   r   r   )r   r    r   r   r   ÚtestAppendToken6   s   
 z$LogicalLineBasicTest.testAppendTokenN)Ú__name__Ú
__module__Ú__qualname__r!   r&   r(   r,   r   r   r   r   r      s
    	r   c                   @   s   e Zd Zdd„ ZdS )Ú$LogicalLineFormattingInformationTestc                 C   s„   t  d¡}t |¡}|d jd }|  |j¡ |  |j¡ |  |j	t	j
¡ |d jd }|  |j¡ |  |j¡ |  |j	t	j
¡ d S )Nz-
        def f(a, b):
          pass
        r   é   r'   )ÚtextwrapÚdedentr   ZParseAndUnwrapr   ZassertFalseZcan_break_beforeZmust_break_beforer   r   ZUNBREAKABLE)r   ÚcodeZllinesÚfZlparenr   r   r   ÚtestFuncDef?   s   

z0LogicalLineFormattingInformationTest.testFuncDefN)r-   r.   r/   r6   r   r   r   r   r0   =   s    r0   c                 C   s   t  t | |¡|¡S )N)r   ZFormatTokenr   ZLeaf)Ú
token_typeÚtoken_valuer   r   r   r   r+   Q   s   r+   c                 C   s   dd„ | D ƒS )Nc                 S   s   g | ]\}}}t |||ƒ‘qS r   )r+   )r   r7   r8   Z
token_namer   r   r   r   V   s    
ÿÿz(_MakeFormatTokenList.<locals>.<listcomp>r   )Ztoken_type_valuesr   r   r   r   U   s   þr   Ú__main__)Ú__doc__r2   ZunittestZyapf_third_party._ylib2to3r   Z yapf_third_party._ylib2to3.pgen2r   Zyapf.pytreer   Zyapf.yapflibr   r   Z	yapftestsr   ZTestCaser   ZYAPFTestr0   r+   r   r-   Úmainr   r   r   r   Ú<module>   s     ÿ