o
    HXh                     @   sb   d Z ddlZddlmZ ddlmZ ddlmZ ddlZG dd dejZ	e
dkr/e  dS dS )	z/test script for a few new invalid token catches    N)support)	os_helper)script_helperc                   @   sL   e Zd Zdd Zdd Zdd Zdd Zd	d
 Ze	e
j ddd ZdS )EOFTestCasec                 C   sj   d}dD ].}zt | d W tj ty2 } z| t|| | |jd W Y d }~qd }~ww d S )NzCunterminated string literal (detected at line 1) (<string>, line 1))'"zthis is a test                   evalSyntaxErrorassertEqualstroffsetr   
TestFailed)selfexpectquotemsg r   7/opt/python-3.10.19/usr/lib/python3.10/test/test_eof.pytest_EOF_single_quote
   s   z!EOFTestCase.test_EOF_single_quotec              
   C   sZ   d}zt d W tj ty, } z| t|| | |jd W Y d }~d S d }~ww )NzQunterminated triple-quoted string literal (detected at line 1) (<string>, line 1)z'''this is a testr   r	   r   r   r   r   r   r   	test_EOFS   s   
zEOFTestCase.test_EOFSc                 C   sZ   d}t  }t|dd}t|\}}}W d    n1 s w   Y  | d| d S )Nz(<string>, line 1)fooz'''this is 
a 
tests>   unterminated triple-quoted string literal (detected at line 3)r   temp_dirr   Zmake_scriptZassert_python_failureZassertIn)r   r   r   	file_namercouterrr   r   r   test_EOFS_with_file    s   
zEOFTestCase.test_EOFS_with_filec              
   C   sT   d}zt ddddd W tj ty) } z| t|| W Y d }~d S d }~ww )N/unexpected EOF while parsing (<string>, line 1)z"\xhh" \z<string>execT)dont_inherit)compiler   r   r   r   r   r   r   r   r   test_eof_with_line_continuation'   s   z+EOFTestCase.test_eof_with_line_continuationc                 C   s   d}|  t}td W d   n1 sw   Y  | t|j| |  t}td W d   n1 s8w   Y  | t|j| dS )z=A continuation at the end of input must be an error; bpo2180.r!   zx = 5\N\)ZassertRaisesr   r"   r   r   	exception)r   r   excinfor   r   r   test_line_continuation_EOF0   s   

z&EOFTestCase.test_line_continuation_EOFzsys.executable requiredc                 C   s   t  K}t|dd}t|\}}}| d| | d| | d| t|dd}t|\}}}| d| | d| | d| W d   dS 1 sRw   Y  dS )	z9Ensure tok_nextc() does not add too many ending newlines.r   r&   s   unexpected EOF while parsings   line 1   \zy = 6\s   y = 6\Nr   )r   r   r   r   r   r   r   r   r   ,test_line_continuation_EOF_from_file_bpo2180:   s   
"z8EOFTestCase.test_line_continuation_EOF_from_file_bpo2180N)__name__
__module____qualname__r   r   r    r%   r)   unittestZskipIfsys
executabler+   r   r   r   r   r   	   s    
	
r   __main__)__doc__r0   testr   Ztest.supportr   r   r/   ZTestCaser   r,   mainr   r   r   r   <module>   s    A