o
    no™iU  ã                   @   sD   d dl mZ d dlmZ d dlZd dlmZmZ G dd„ deƒZ	dS )é    )ÚCounter)ÚdedentN)Údata_providerÚUnitTestc                   @   s&   e Zd Zedƒdeddfdd„ƒZdS )ÚDuplicateLeafNodeTest))z¾
                foo = 'toplevel'
                fn1(foo)
                fn2(foo)
                def fn_def():
                    foo = 'shadow'
                    fn3(foo)
            ÚcodeÚreturnNc                    s8   | ‰ G ‡ fdd„dt jƒ}t  t|ƒ¡}| |ƒ ¡ d S )Nc                       s.   e Zd Zddd„Zdejdef‡ fdd„ZdS )	z9DuplicateLeafNodeTest.test_tokenize.<locals>.CountVisitorr   Nc                 S   s   t ƒ | _i | _d S )N)r   ÚcountÚnodes)Úself© r   ú[/home/ubuntu/.local/lib/python3.10/site-packages/libcst/_parser/tests/test_node_identity.pyÚ__init__    s   
zBDuplicateLeafNodeTest.test_tokenize.<locals>.CountVisitor.__init__Únodec              
      sZ   | j t|ƒ  d7  < ˆ  | j t|ƒ dkd|› d| j t|ƒ¡› ¡ || jt|ƒ< dS )Né   z"Node duplication detected between z and T)r	   ÚidÚ
assertTruer
   Úget)r   r   ©Ú	test_caser   r   Úon_visit$   s   þzBDuplicateLeafNodeTest.test_tokenize.<locals>.CountVisitor.on_visit)r   N)Ú__name__Ú
__module__Ú__qualname__r   ÚcstÚCSTNodeÚboolr   r   r   r   r   ÚCountVisitor   s    
r   )r   Ú
CSTVisitorÚparse_moduler   Úvisit)r   r   r   Úmoduler   r   r   Útest_tokenize   s   z#DuplicateLeafNodeTest.test_tokenize)r   r   r   r   Ústrr"   r   r   r   r   r      s
    ÿr   )
Úcollectionsr   Útextwrapr   Úlibcstr   Úlibcst.testing.utilsr   r   r   r   r   r   r   Ú<module>   s
   