
    `N`3                         d Z ddlZddlZddlmZ ddlmZ ddlmZ  G d dej                  Z	e
dk    r ej                     dS dS )	z(Style config tests for yapf.reformatter.    N)reformatter)style)yapf_test_helperc                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )TestsForStyleConfigc                 (    t           j        | _        d S )N)r   DEFAULT_STYLEcurrent_style)selfs    Glib/python3.11/site-packages/yapftests/reformatter_style_config_test.pysetUpzTestsForStyleConfig.setUp   s    ,D    c                    	 t          j        t          j                               t          j        d          }t          j        d          }t          j        |          }|                     |t          j	        |                     t          j        t          j
                               | j        t           _        n;# t          j        t          j
                               | j        t           _        w xY wt          j        d          }t          j        d          }t          j        |          }|                     |t          j	        |                     d S )Nz?          for i in range(5):
           print('bar')
          z@          for i in range(5):
            print('bar')
          z9        for i in range(5):
         print('bar')
        z<        for i in range(5):
            print('bar')
        )r   SetGlobalStyleCreateYapfStyletextwrapdedentr   ParseAndUnwrapassertCodeEqualr   ReformatCreatePEP8Styler
   r	   )r   unformatted_codeexpected_formatted_codeuwliness       r   testSetGlobalStylez&TestsForStyleConfig.testSetGlobalStyle   sV   /5022333! *   !) 1 ! ! !/0@AAg
2&/88: : : 5022333 .e 5022333 .e.... (   'o /   -.>??G0+2Fw2O2OPPPPPs   B	C 8C:c                 .   	 t          j                    }t          j        d          |d<   t          j        |           t	          j        d          }t	          j        d          }t          j        |          }|                     |t          j
        |                     t          j        t          j                               | j        t           _        d S # t          j        t          j                               | j        t           _        w xY w)Nz*,/*NO_SPACES_AROUND_SELECTED_BINARY_OPERATORSz>          a = 1+2 * 3 - 4 / 5
          b = '0' * 1
          z:          a = 1 + 2*3 - 4/5
          b = '0'*1
          )r   r   _StringSetConverterr   r   r   r   r   r   r   r   r
   r	   )r   sympy_styler   r   r   s        r   testOperatorNoSpaceStylez,TestsForStyleConfig.testOperatorNoSpaceStyle;   s   /)++k!%(( >?;'''! *   !) 1 ! !
 !/0@AAg
2&/88: : : 5022333 .e 5022333 .e....s   B"C 8Dc                 
   	 t          j                    }d|d<   t          j        |           t          j        d          }t          j        d          }t          j        |          }|                     |t          j	        |                     t          j        t          j                               | j
        t           _        d S # t          j        t          j                               | j
        t           _        w xY w)NT ARITHMETIC_PRECEDENCE_INDICATIONa            1+2
          (1 + 2) * (3 - (4 / 5))
          a = 1 * 2 + 3 / 4
          b = 1 / 2 - 3 * 4
          c = (1 + 2) * (3 - 4)
          d = (1 - 2) / (3 + 4)
          e = 1 * 2 - 3
          f = 1 + 2 + 3 + 4
          g = 1 * 2 * 3 * 4
          h = 1 + 2 - 3 + 4
          i = 1 * 2 / 3 * 4
          j = (1 * 2 - 3) + 4
          k = (1 * 2 * 3) + (4 * 5 * 6 * 7 * 8)
          af            1 + 2
          (1+2) * (3 - (4/5))
          a = 1*2 + 3/4
          b = 1/2 - 3*4
          c = (1+2) * (3-4)
          d = (1-2) / (3+4)
          e = 1*2 - 3
          f = 1 + 2 + 3 + 4
          g = 1 * 2 * 3 * 4
          h = 1 + 2 - 3 + 4
          i = 1 * 2 / 3 * 4
          j = (1*2 - 3) + 4
          k = (1*2*3) + (4*5*6*7*8)
          r   r   r   r   r   r   r   r   r   r   r
   r	   )r   pep8_with_precedencer   r   r   s        r   testOperatorPrecedenceStylez/TestsForStyleConfig.testOperatorPrecedenceStyleQ   s   (/"244AE=>/000! *   !) 1 ! !  !/0@AAg
2&/88: : : 5022333 .e 5022333 .e....s   BC
 
8Dc                    	 t          j                    }d|d<   d|d<   t          j        |           t          j        d          }t          j        |          }|                     |t          j	        |                     t          j        t          j                               | j
        t           _        d S # t          j        t          j                               | j
        t           _        w xY w)NFSPLIT_BEFORE_FIRST_ARGUMENTSPLIT_BEFORE_NAMED_ASSIGNSa            # Example from in-code MustSplit comments
          foo = outer_function_call(fitting_inner_function_call(inner_arg1, inner_arg2),
                                    outer_arg1, outer_arg2)

          foo = outer_function_call(
              not_fitting_inner_function_call(inner_arg1, inner_arg2), outer_arg1,
              outer_arg2)

          # Examples Issue#424
          a_super_long_version_of_print(argument1, argument2, argument3, argument4,
                                        argument5, argument6, argument7)

          CREDS_FILE = os.path.join(os.path.expanduser('~'),
                                    'apis/super-secret-admin-creds.json')

          # Examples Issue#556
          i_take_a_lot_of_params(arg1, param1=very_long_expression1(),
                                 param2=very_long_expression2(),
                                 param3=very_long_expression3(),
                                 param4=very_long_expression4())

          # Examples Issue#590
          plt.plot(numpy.linspace(0, 1, 10), numpy.linspace(0, 1, 10), marker="x",
                   color="r")

          plt.plot(veryverylongvariablename, veryverylongvariablename, marker="x",
                   color="r")
          r#   r   pep8_no_split_before_firstformatted_coder   s       r   $testNoSplitBeforeFirstArgumentStyle1z8TestsForStyleConfig.testNoSplitBeforeFirstArgumentStyle1|   s    &/#(#8#:#: BG !>?AF !=>5666 (  n: !/??g
>;+?+H+HIII5022333 .e 5022333 .e....   BB; ;8C3c                    	 t          j                    }d|d<   d|d<   t          j        |           t          j        d          }t          j        |          }|                     |t          j	        |                     t          j        t          j                               | j
        t           _        d S # t          j        t          j                               | j
        t           _        w xY w)NFr'   Tr(   a            # Examples Issue#556
          i_take_a_lot_of_params(arg1,
                                 param1=very_long_expression1(),
                                 param2=very_long_expression2(),
                                 param3=very_long_expression3(),
                                 param4=very_long_expression4())

          # Examples Issue#590
          plt.plot(numpy.linspace(0, 1, 10),
                   numpy.linspace(0, 1, 10),
                   marker="x",
                   color="r")

          plt.plot(veryverylongvariablename,
                   veryverylongvariablename,
                   marker="x",
                   color="r")
          r#   r)   s       r   $testNoSplitBeforeFirstArgumentStyle2z8TestsForStyleConfig.testNoSplitBeforeFirstArgumentStyle2   s    /#(#8#:#: BG !>?AE !=>5666 (  n& !/??g
>;+?+H+HIII5022333 .e 5022333 .e....r-   N)	__name__
__module____qualname__r   r   r    r%   r,   r/    r   r   r   r      ss        - - -Q Q Q:/ / /,)/ )/ )/V'/ '/ '/R/ / / / /r   r   __main__)__doc__r   unittestyapf.yapflibr   r   	yapftestsr   YAPFTestr   r0   mainr3   r   r   <module>r;      s    / .   $ $ $ $ $ $       & & & & & &i/ i/ i/ i/ i/*3 i/ i/ i/X z(-///// r   