o
    Ni                     @   sX   d dl Z d dlmZ ddlmZ ddlmZmZmZ G dd deZ	G dd	 d	eZ
dS )
    N)TestCase   )Naming)_indent_chunkUtilityCodeprocess_utility_ccodec                   @   sD   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S )
TestIndentc              	   C   s   t dD ]A}t|d| }| D ]}| |dkp| t| q| j|d t||d}| 	|| W d    n1 s@w   Y  qd S )N     )indentation)indentation_length)
rangetextwrapindent
splitlines
assertTruestripreprsubTestr   assertEqual)selfchunkexpectedr   expected_indentedlineresult r   R/home/ubuntu/.local/lib/python3.10/site-packages/Cython/Compiler/Tests/TestCode.py_test_indentations   s   zTestIndent._test_indentationsc                 C      |  dd d S )Nr   r   r   r   r   r   test_indent_empty      zTestIndent.test_indent_emptyc                 C   s@   |  dd |  dd |  dd |  dd |  dd d S )N


z


z 
 
z
  
 
    
z



r!   r"   r   r   r   test_indent_empty_lines   s
   z"TestIndent.test_indent_empty_linesc                 C   r    )Nabcr!   r"   r   r   r   test_indent_one_line   r$   zTestIndent.test_indent_one_linec                 C      d}d}|  || d S )Nz
            x = 1
            if x == 2:
                print("False")
            else:
                print("True")
        z=
x = 1
if x == 2:
    print("False")
else:
    print("True")
r!   r   r   r   r   r   r   test_indent_chunk    s   zTestIndent.test_indent_chunkc                 C   r*   )N
            x = 1

            if x == 2:
                print("False")
            else:
                print("True")
        >
x = 1

if x == 2:
    print("False")
else:
    print("True")
r!   r+   r   r   r   test_indent_empty_line1   s   z!TestIndent.test_indent_empty_linec                 C   s2   dj dd}d|d< d|}d}| || d S )Nr-   T)keependsz            
r   r   r.   )r   joinr   )r   linesr   r   r   r   r   test_indent_empty_line_uncleanD   s   
z)TestIndent.test_indent_empty_line_uncleanN)
__name__
__module____qualname__r   r#   r'   r)   r,   r/   r3   r   r   r   r   r      s    r   c                   @   s@   e Zd Zdd ZddedefddZdd	 Zd
d Zdd ZdS )TestUtilityCodeProcessingc                 C   s$   t  }t|d |\}}| | |S )N)r   r   assertFalse)r   codeutility_codeformatted_codeis_module_specificr   r   r   _process[   s   
z"TestUtilityCodeProcessing._processFr9   r   c                 C   s4   |rt |}| d }| |}| || d S )Nr&   )r   dedentr   r=   r   )r   r9   r   r>   	formattedr   r   r   assert_formatted_codea   s
   

z/TestUtilityCodeProcessing.assert_formatted_codec                 C   s   | j dddd d S )Nz
        Some Text and a CSTRING("""
        spanning "multiple" 'lines'.
        Really.
        """);   # end of C string
        z
        Some Text and a "\n"
        "        spanning \042multiple\042 'lines'.\n"
        "        Really.\n"
        "        \n"
        ;   # end of C string
        T)r   r>   )r@   r"   r   r   r   test_format_cstringh   s   
z-TestUtilityCodeProcessing.test_format_cstringc              	   C   s,   | j ddtj dtj dtj dd d S )NzB
        CGLOBAL(name)
        NAMED_CGLOBAL(empty_tuple)
        	
        z->name
        ->r   )r@   r   modulestateglobal_cnameempty_tupler"   r   r   r   test_cglobalx   s   
z&TestUtilityCodeProcessing.test_cglobalc                 C   s   | j ddtj dtj tj dtj dtj dtj dtj dtj dtj dtj dtj dtj dtj dtj dd d S )Nz
        EMPTY(tuple)EMPTY(bytes)
        EMPTY(tuple);EMPTY(bytes)
        EMPTY(unicode)
        EMPTY(bytes)
        EMPTY(tuple)
        rB   rC   ;rD   )r@   r   rE   rF   empty_bytesempty_unicoder"   r   r   r   test_empty_builtin   s>   
z,TestUtilityCodeProcessing.test_empty_builtinN)F)	r4   r5   r6   r=   strr@   rA   rG   rK   r   r   r   r   r7   Z   s    
r7   )r   unittestr   r   r   Coder   r   r   r   r7   r   r   r   r   <module>   s    S