o
    2gU                     @  s   d Z ddlmZ ddlZddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZmZmZmZmZmZ ddlmZ ddlmZ ddlmZ ddgZG dd deZdS )z|Test runner for exception handling transform test cases.

The transform inserts exception handling branch operations to IR.
    )annotationsN)CompileError)test_temp_dir)DataDrivenTestCase)frequently_executed_blocks)TOP_LEVEL_NAME)format_func)ICODE_GEN_BUILTINSMypycDataSuiteassert_test_outputbuild_ir_for_single_fileremove_comment_linesuse_custom_builtins)insert_exception_handling)insert_ref_count_opcodes)insert_uninit_checkszexceptions.testzexceptions-freq.testc                   @  s   e Zd ZeZeZdddZdS )	TestExceptionTransformtestcaser   returnNonec                 C  s  t tj| jt|s t|j}zt|j	}W n t
y- } z	|j}W Y d}~nFd}~ww g }|D ]<}|jtkr@|jds@q2t| t| t| |t| |jdrnt|jd }|dtdd |D   q2t||d| W d   dS 1 sw   Y  dS )	z4Perform a runtime checking transformation test case.N	_toplevel_freqr   zhot blocks: %sc                 s  s    | ]}|j V  qd S )N)label).0b r   R/home/garg/my-data/venv/lib/python3.10/site-packages/mypyc/test/test_exceptions.py	<genexpr>6   s    z2TestExceptionTransform.run_case.<locals>.<genexpr>zInvalid source code output)r   ospathjoindata_prefixr	   r   outputr   inputr   messagesnamer   endswithr   r   r   extendr   r   blocksappendsortedr   )selfr   expected_outputireactualfncommonr   r   r   run_case#   s,   
"zTestExceptionTransform.run_caseN)r   r   r   r   )__name__
__module____qualname__filesr   	base_pathr2   r   r   r   r   r      s    r   ) __doc__
__future__r   os.pathr   mypy.errorsr   mypy.test.configr   mypy.test.datar   mypyc.analysis.blockfreqr   mypyc.commonr   mypyc.ir.pprintr   mypyc.test.testutilr	   r
   r   r   r   r   mypyc.transform.exceptionsr   mypyc.transform.refcountr   mypyc.transform.uninitr   r6   r   r   r   r   r   <module>   s     