o
    p.aå  ã                   @   sX   d Z ddlZddlZddlZG dd„ dejƒZG dd„ dejƒZedkr*e 	¡  dS dS )z"Unit tests for the common.py file.é    Nc                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚTestTopologicallySortedc                    sD   ddgg dgdgdœ‰ ‡ fdd„}|   tj ˆ  ¡ |¡g d¢¡ dS )	zATest that sorting works on a valid graph with one possible order.ÚbÚcÚd©Úar   r   r   c                    ó   t ˆ |  ƒS ©N©Útuple©Únode©Úgraph© ú1/usr/lib/python3/dist-packages/gyp/common_test.pyÚGetEdge   ó   z3TestTopologicallySorted.test_Valid.<locals>.GetEdge)r   r   r   r   N)ÚassertEqualÚgypÚcommonÚTopologicallySortedÚkeys©Úselfr   r   r   r   Ú
test_Valid   s   üþz"TestTopologicallySorted.test_Validc                    sB   dgdgdgdgdœ‰ ‡ fdd„}|   tjjtjjˆ  ¡ |¡ dS )	z3Test that an exception is thrown on a cyclic graph.r   r   r   r   r   c                    r   r	   r
   r   r   r   r   r   %   r   z3TestTopologicallySorted.test_Cycle.<locals>.GetEdgeN)ÚassertRaisesr   r   Ú
CycleErrorr   r   r   r   r   r   Ú
test_Cycle   s   üþz"TestTopologicallySorted.test_CycleN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r      s    r   c                   @   s<   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dS )ÚTestGetFlavorz0Test that gyp.common.GetFlavor works as intendedÚ c                 C   s   t j| _d S r	   )ÚsysÚplatformÚoriginal_platform©r   r   r   r   ÚsetUp0   r   zTestGetFlavor.setUpc                 C   s   | j t_d S r	   )r&   r$   r%   r'   r   r   r   ÚtearDown3   r   zTestGetFlavor.tearDownc                 C   s   |t _|  |tj |¡¡ d S r	   )r$   r%   r   r   r   Ú	GetFlavor)r   ÚexpectedÚargumentÚparamr   r   r   ÚassertFlavor6   s   zTestGetFlavor.assertFlavorc                 C   st   |   ddi ¡ |   ddi ¡ |   ddi ¡ |   ddi ¡ |   ddi ¡ |   d	d
i ¡ |   d	di ¡ |   d	d	i ¡ d S )NÚfreebsdÚfreebsd9Ú	freebsd10ÚopenbsdÚopenbsd5ÚsolarisÚsunos5ÚsunosÚlinuxÚlinux2Úlinux3©r.   r'   r   r   r   Útest_platform_default:   s   z#TestGetFlavor.test_platform_defaultc                 C   s   |   ddddi¡ d S )NÚfoobarr8   Úflavorr:   r'   r   r   r   Ú
test_paramD   s   zTestGetFlavor.test_paramN)
r   r    r!   Ú__doc__r&   r(   r)   r.   r;   r>   r   r   r   r   r"   ,   s    
r"   Ú__main__)
r?   Ú
gyp.commonr   Úunittestr$   ÚTestCaser   r"   r   Úmainr   r   r   r   Ú<module>   s   ÿ