U
    {h                     @   s\   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	m
Z
mZmZ G dd deZdS )	    )
ModuleNode)ModuleScope)TransformTest)MethodDispatcherTransform)NormalizeTreeAnalyseDeclarationsTransformAnalyseExpressionsTransformInterpretCompilerDirectivesc                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )TestMethodDispatcherTransformNc                 C   sJ   | j d krDd }dd }|t|t|i t|t|g}| |d| _ | j S )Nc                 S   s"   t dd d }t| jd | |di dS )Ntest)docbodyscopeZfull_module_nameZdirective_comments)r   r   pos)noder    r   E/tmp/pip-unpacked-wheel-fhl22ezh/Cython/Compiler/Tests/TestVisitor.pyfake_module   s    
 z>TestMethodDispatcherTransform._build_tree.<locals>.fake_modulez
                cdef bytes s = b'asdfg'
                cdef dict d = {1:2}
                x = s * 3
                d.get('test')
            )_treer   r	   r   r   Zrun_pipeline)selfcontextr   Zpipeliner   r   r   _build_tree   s    
z)TestMethodDispatcherTransform._build_treec                    sB   dg G  fdddt }|  }|d | | d d  d S )Nr   c                       s   e Zd Z fddZdS )z?TestMethodDispatcherTransform.test_builtin_method.<locals>.Testc                    s    d  d7  < |S )Nr      r   r   r   funcargsunboundZcallsr   r   _handle_simple_method_dict_get(   s    z^TestMethodDispatcherTransform.test_builtin_method.<locals>.Test._handle_simple_method_dict_getN)__name__
__module____qualname__r   r   r   r   r   Test'   s   r"   r   r   r   assertEqualr   r"   treer   r   r   test_builtin_method%   s
    z1TestMethodDispatcherTransform.test_builtin_methodc                    sV   ddd G  fdddt }|  }|d | | d d  | d d  d S )Nr   )bytesobjectc                       s$   e Zd Z fddZ fddZdS )z=TestMethodDispatcherTransform.test_binop_method.<locals>.Testc                    s    d  d7  < |S )Nr(   r   r   r   r   r   r   #_handle_simple_method_bytes___mul__3   s    zaTestMethodDispatcherTransform.test_binop_method.<locals>.Test._handle_simple_method_bytes___mul__c                    s    d  d7  < |S )Nr)   r   r   r   r   r   r   $_handle_simple_method_object___mul__6   s    zbTestMethodDispatcherTransform.test_binop_method.<locals>.Test._handle_simple_method_object___mul__N)r   r    r!   r*   r+   r   r   r   r   r"   2   s   r"   r   r(   r)   r#   r%   r   r   r   test_binop_method0   s    
z/TestMethodDispatcherTransform.test_binop_method)r   r    r!   r   r   r'   r,   r   r   r   r   r
   
   s   r
   N)ZCython.Compiler.ModuleNoder   ZCython.Compiler.Symtabr   ZCython.TestUtilsr   ZCython.Compiler.Visitorr   Z#Cython.Compiler.ParseTreeTransformsr   r   r   r	   r
   r   r   r   r   <module>   s
   