Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_lltrace.cpython-311.pyc
�

�Ke�����ddlZddlZddlZddlZddlmZmZddlmZd�Z	e
ed��Zejed��Gd�dej
����Zed	krej��dSdS)
�N)�	os_helper�verbose)�assert_python_okc��g}td��D]}|�|���d}d}t||��dS)N�zthis isz
an example)�range�append�print)�x�i�ys   �;/usr/local/apps/python3/lib/python3.11/test/test_lltrace.py�exampler	sH��
�A�
�1�X�X����	���������A��A�	�!�Q�K�K�K�K�K��gettotalrefcountzlltrace requires Py_DEBUGc�&�eZdZd�Zd�Zd�Zd�ZdS)�TestLLTracec��tj|�����}ttjdd���5}|�tjtj��|�|��ddd��n#1swxYwYttj��\}}}|�
|d��|�
|d��|�d��}trJtd��t|��td��t|��t��|S)N�wzutf-8)�encodingrrz

--- code ---z
--- stdout ---)�textwrap�dedent�strip�openr�TESTFN�
addCleanup�unlink�writer�assertEqual�decoderr
)�self�code�fd�status�stdout�stderr�results       r�run_codezTestLLTrace.run_codesP����t�$�$�*�*�,�,��
�)�"�C�'�
:�
:�
:�	�b��O�O�I�,�i�.>�?�?�?��H�H�T�N�N�N�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�"2�)�2B�!C�!C����������%�%�%������#�#�#����w�'�'���	��$�%�%�%��$�K�K�K��$�%�%�%��&�M�M�M��G�G�G��
s�AB�B�Bc��|�d��}|�d|��|�d|��|�d|��|�d|��|�d|��|�d|��|�d|��|�d	|��|�d
|��dS)Na�
            def dont_trace_1():
                a = "a"
                a = 10 * a
            def trace_me():
                for i in range(3):
                    +i
            def dont_trace_2():
                x = 42
                y = -x
            dont_trace_1()
            __lltrace__ = 1
            trace_me()
            del __lltrace__
            dont_trace_2()
        �GET_ITER�FOR_ITER�UNARY_POSITIVE�POP_TOP�	BINARY_OP�UNARY_NEGATIVEz'trace_me' in module '__main__'�dont_trace_1z'dont_trace_2' in module)r(�assertIn�assertNotIn�r!r%s  r�test_lltracezTestLLTrace.test_lltrace's������ �
�
�� 	
�
�
�j�&�)�)�)��
�
�j�&�)�)�)��
�
�&��/�/�/��
�
�i��(�(�(�����f�-�-�-����)�6�2�2�2��
�
�7��@�@�@������0�0�0����3�V�<�<�<�<�<rc��|�d��}|�d|��|�d|��|�d|��|�d|��d�tjt��D��}|���D]�}|�d��\}}}|s�t|��}|���}t|��dkr|\}}t|��}n|\}d}|�
||j|��|�
||j|����dS)	Nz
            from test import test_lltrace
            test_lltrace.__lltrace__ = 1
            test_lltrace.example()
        z''example' in module 'test.test_lltrace'�
LOAD_CONSTr+zthis is an examplec��i|]
}|j|��S�)�offset)�.0rs  r�
<dictcomp>z=TestLLTrace.test_lltrace_different_module.<locals>.<dictcomp>Os��H�H�H�Q�Q�X�q�H�H�Hr�:�)
r(r1�dis�get_instructionsr�
splitlines�	partition�int�split�lenr�opname�arg)	r!r%�	instr_map�liner9�colon�opname_opargrE�opargs	         r�test_lltrace_different_modulez)TestLLTrace.test_lltrace_different_moduleCsg����� �
�
��
	
�
�
�?��H�H�H��
�
�l�F�+�+�+��
�
�j�&�)�)�)��
�
�*�F�3�3�3�I�H�#�*>�w�*G�*G�H�H�H�	��%�%�'�'�
	;�
	;�D�*.�.�.��*=�*=�'�F�E�<��
����[�[�F�'�-�-�/�/�L��<� � �A�%�%� ,�
����E�
�
���(�	�������Y�v�.�5�v�>�>�>����Y�v�.�2�E�:�:�:�:�
	;�
	;rc�\�|�d��}|�d|��dS)Nz�
            import code

            console = code.InteractiveConsole()
            console.push('__lltrace__ = 1')
            console.push('a = [1, 2, 3]')
            console.push('a[0] = 1')
            print('unreachable if bug exists')
        zunreachable if bug exists)r(r1r3s  r�1test_lltrace_does_not_crash_on_subscript_operatorz=TestLLTrace.test_lltrace_does_not_crash_on_subscript_operator_s9��
��� �
�
��	
�
�
�1�6�:�:�:�:�:rN)�__name__�
__module__�__qualname__r(r4rLrNr8rrrrsP���������"=�=�=�8;�;�;�8;�;�;�;�;rr�__main__)r>�sysr�unittest�test.supportrr�test.support.script_helperrr�hasattr�Py_DEBUG�
skipUnless�TestCaserrO�mainr8rr�<module>r\s���
�
�
�
�
�
�
�
���������+�+�+�+�+�+�+�+�7�7�7�7�7�7�����7�3�*�+�+�����X�:�;�;�Y;�Y;�Y;�Y;�Y;�(�#�Y;�Y;�<�;�Y;�v�z����H�M�O�O�O�O�O��r