ó
ÓnäZc           @   s`   d  Z  d d l Z d d l Z d d l Z d e j f d „  ƒ  YZ e d k r\ e j ƒ  n  d S(   s!   Unit tests for the input.py file.iÿÿÿÿNt   TestFindCyclesc           B   sY   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   c         C   s7   i  |  _  x' d D] } t j j | ƒ |  j  | <q Wd  S(   Nt   at   bt   ct   dt   e(   R   R   R   R   R   (   t   nodest   gypt   inputt   DependencyGraphNode(   t   selft   x(    (    s2   /usr/lib/python2.7/dist-packages/gyp/input_test.pyt   setUp   s    	c         C   s$   | j  j | ƒ | j j | ƒ d  S(   N(   t   dependenciest   appendt
   dependents(   R
   t	   dependentt
   dependency(    (    s2   /usr/lib/python2.7/dist-packages/gyp/input_test.pyt   _create_dependency   s    c         C   s:   x3 |  j  j ƒ  D]" \ } } |  j g  | j ƒ  ƒ q Wd  S(   N(   R   t	   iteritemst   assertEqualst
   FindCycles(   R
   t   labelt   node(    (    s2   /usr/lib/python2.7/dist-packages/gyp/input_test.pyt   test_no_cycle_empty_graph   s    c         C   s”   |  j  |  j d |  j d ƒ |  j  |  j d |  j d ƒ |  j  |  j d |  j d ƒ x3 |  j j ƒ  D]" \ } } |  j g  | j ƒ  ƒ qj Wd  S(   NR   R   R   R   (   R   R   R   R   R   (   R
   R   R   (    (    s2   /usr/lib/python2.7/dist-packages/gyp/input_test.pyt   test_no_cycle_line   s
    c         C   s”   |  j  |  j d |  j d ƒ |  j  |  j d |  j d ƒ |  j  |  j d |  j d ƒ x3 |  j j ƒ  D]" \ } } |  j g  | j ƒ  ƒ qj Wd  S(   NR   R   R   (   R   R   R   R   R   (   R
   R   R   (    (    s2   /usr/lib/python2.7/dist-packages/gyp/input_test.pyt   test_no_cycle_dag$   s
    c         C   sV   |  j  |  j d |  j d ƒ |  j |  j d |  j d g g |  j d j ƒ  ƒ d  S(   NR   (   R   R   R   R   (   R
   (    (    s2   /usr/lib/python2.7/dist-packages/gyp/input_test.pyt   test_cycle_self_reference,   s     c         C   s¼   |  j  |  j d |  j d ƒ |  j  |  j d |  j d ƒ |  j |  j d |  j d |  j d g g |  j d j ƒ  ƒ |  j |  j d |  j d |  j d g g |  j d j ƒ  ƒ d  S(   NR   R   (   R   R   R   R   (   R
   (    (    s2   /usr/lib/python2.7/dist-packages/gyp/input_test.pyt   test_cycle_two_nodes2   s    **c         C   s  |  j  |  j d |  j d ƒ |  j  |  j d |  j d ƒ |  j  |  j d |  j d ƒ |  j  |  j d |  j d ƒ |  j d j ƒ  } |  j |  j d |  j d |  j d g | k ƒ |  j |  j d |  j d |  j d g | k ƒ |  j d t | ƒ ƒ d  S(   NR   R   R   i   (   R   R   R   t
   assertTrueR   t   len(   R
   t   cycles(    (    s2   /usr/lib/python2.7/dist-packages/gyp/input_test.pyt   test_two_cycles;   s    ++c         C   sö   |  j  |  j d |  j d ƒ |  j  |  j d |  j d ƒ |  j  |  j d |  j d ƒ |  j  |  j d |  j d ƒ |  j  |  j d |  j d ƒ |  j |  j d |  j d |  j d |  j d |  j d |  j d g g |  j d j ƒ  ƒ d  S(   NR   R   R   R   R   (   R   R   R   R   (   R
   (    (    s2   /usr/lib/python2.7/dist-packages/gyp/input_test.pyt   test_big_cycleI   s    



(   t   __name__t
   __module__R   R   R   R   R   R   R   R    R!   (    (    (    s2   /usr/lib/python2.7/dist-packages/gyp/input_test.pyR       s   									t   __main__(	   t   __doc__t	   gyp.inputR   t   unittestt   syst   TestCaseR    R"   t   main(    (    (    s2   /usr/lib/python2.7/dist-packages/gyp/input_test.pyt   <module>   s   K