a
    äzeº	  ã                   @   sR   d Z ddl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rNe 
¡  dS )z/test script for a few new invalid token catchesé    N)Úsupport)Úscript_helperc                   @   sD   e Z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   sP   d}zt dƒ W n4 tyD } z|  t|ƒ|¡ W Y d }~nd }~0 0 tj‚d S )Nz4EOL while scanning string literal (<string>, line 1)z'this is a test            ©ÚevalÚSyntaxErrorÚassertEqualÚstrr   Ú
TestFailed©ÚselfÚexpectÚmsg© r   ú#/usr/lib/python3.9/test/test_eof.pyÚ	test_EOFC	   s    &zEOFTestCase.test_EOFCc              
   C   sP   d}zt dƒ W n4 tyD } z|  t|ƒ|¡ W Y d }~nd }~0 0 tj‚d S )NzBEOF while scanning triple-quoted string literal (<string>, line 1)z'''this is a testr   r   r   r   r   Ú	test_EOFS   s    &zEOFTestCase.test_EOFSc              
   C   sX   d}zt ddddd W n4 tyL } z|  t|ƒ|¡ W Y d }~nd }~0 0 tj‚d S )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,0    Y  |  t|jƒ|¡ |   t¡}tdƒ W d  ƒ n1 sp0    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_EOF&   s    &&z&EOFTestCase.test_line_continuation_EOFzsys.executable requiredc                 C   s°   t  ¡ ”}t |dd¡}t |¡\}}}|  d|¡ |  d|¡ |  d|¡ t |dd¡}t |¡\}}}|  d|¡ |  d|¡ |  d|¡ W d  ƒ n1 s¢0    Y  dS )	z9Ensure tok_nextc() does not add too many ending newlines.Zfoor   s   unexpected EOF while parsings   line 2ó   \zy = 6\s   y = 6\N)r   Útemp_dirr   Zmake_scriptZassert_python_failureZassertIn)r   r   Ú	file_nameÚrcÚoutÚerrr   r   r   Ú,test_line_continuation_EOF_from_file_bpo21800   s    
z8EOFTestCase.test_line_continuation_EOF_from_file_bpo2180N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   ÚunittestZskipIfÚsysÚ
executabler"   r   r   r   r   r      s   

	
r   Ú__main__)Ú__doc__r'   Útestr   Ztest.supportr   r&   ZTestCaser   r#   Úmainr   r   r   r   Ú<module>   s   8