
    1Vhs                         d Z ddlmZ ddlmZ ddlmZ ddlZddlZddlZddlm	Z	 ddl
mZ  G d d	ej                        Zd
 Zedk(  r ej                           yy)zTests for augment.inline.    )absolute_import)division)print_functionN)inline)
test_utilsc                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	
InlineTestc                     d}t        j                  |      }t        j                  |d       | j	                  |t        j                  d             y )Nzx = 1
a = x
xza = 1
astparser   inline_namecheckAstsEqualselfsrcts      I/home/dcms/DCMS/lib/python3.12/site-packages/pasta/augment/inline_test.pytest_inline_simplezInlineTest.test_inline_simple   s=    
C		#A
q#399Y/0    c                     d}t        j                  |      }t        j                  |d       | j	                  |t        j                  d             y )Nzx = y = z = 1
a = x + y
yzx = z = 1
a = x + 1
r   r   s      r   test_inline_multiple_targetsz'InlineTest.test_inline_multiple_targets%   s>    
&C		#A
q#399%=>?r   c                     t        j                  d      }t        j                  d      }t        j                  |      }t	        j
                  |d       | j                  |t        j                  |             y )Nz[        CONSTANT = "foo"
        def a(b=CONSTANT):
          return b == CONSTANT
        z<        def a(b="foo"):
          return b == "foo"
        CONSTANT)textwrapdedentr   r   r   r   r   )r   r   expectedr   s       r   test_inline_multiple_readsz%InlineTest.test_inline_multiple_reads+   sb    
//  C
    H 			#A
q*%399X./r   c                     t        j                  d      }t        j                  |      }| j	                  t
        j                  d      5  t        j                  |d       d d d        y # 1 sw Y   y xY w)NzG        NOT_A_CONSTANT = "foo"
        NOT_A_CONSTANT += "bar"
        z"'NOT_A_CONSTANT' is not a constantNOT_A_CONSTANT)r   r   r   r   assertRaisesRegexpr   InlineErrorr   r   s      r   test_inline_non_constant_failsz)InlineTest.test_inline_non_constant_fails9   sd    
//  C 			#A		 	 !3!3!G
I .,-. . .s   A++A4c                     d}t        j                  |      }| j                  t        j                  dt         j
                  z        5  t        j                  |d       d d d        y # 1 sw Y   y xY w)Nzdef func(): pass
func()
z('func' is not a constant; it has type %rfunc)r   r   r#   r   r$   FunctionDefr   r   s      r   test_inline_function_failsz%InlineTest.test_inline_function_failsC   s_    
&C		#A		 	 4sF
H $ F#$ $ $s   	A))A2c                     d}t        j                  |      }| j                  t        j                  d      5  t        j
                  |d       d d d        y # 1 sw Y   y xY w)Nzif define:
  x = 1
a = x
z'x' is not a top-level namer   r   r   r#   r   r$   r   r   s      r   test_inline_conditional_failsz(InlineTest.test_inline_conditional_failsL   sS    
(C		#A		 	 !3!3!@
B !C ! ! !   AA!c                     d}t        j                  |      }| j                  t        j                  d      5  t        j
                  |d       d d d        y # 1 sw Y   y xY w)NzCONSTANT1, CONSTANT2 = valuesz,'CONSTANT1' is not declared in an assignment	CONSTANT1r+   r   s      r   test_inline_non_assign_failsz'InlineTest.test_inline_non_assign_failsS   sT    
)C		#A		 	 L
N )K() ) )r-   N)
__name__
__module____qualname__r   r   r    r%   r)   r,   r0    r   r   r	   r	      s&    1@0.$!)r   r	   c                  ~    t        j                         } | j                  t        j                  t                     | S )N)unittest	TestSuiteaddTests	makeSuiter	   )results    r   suiter;   [   s,    &//($$Z01	-r   __main__)__doc__
__future__r   r   r   r   r   r6   pasta.augmentr   
pasta.baser   TestCaser	   r;   r1   mainr4   r   r   <module>rC      sT     '  % 
     !;)$$ ;)|
 z(--/ r   