U
    9%e                     @   s   d 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 dd	lmZmZ G d
d deeZG dd deeZG dd deeZG dd deeZG dd deeZG dd deeZG dd deeZG dd deeZG dd deeZG dd deeZG dd deeZG d d! d!eeZG d"d# d#eeZ G d$d% d%eeZ!G d&d' d'eeZ"G d(d) d)eeZ#G d*d+ d+eeZ$G d,d- d-eeZ%G d.d/ d/eeZ&G d0d1 d1eeZ'G d2d3 d3eeZ(G d4d5 d5eZ)ed6d7 Z*G d8d9 d9eeZ+d:S );ae   Tests for the compiler components of the Numba typed-list.

The tests here should exercise everything within an `@njit` context.
Importantly, the tests should not return a typed list from within such a
context as this would require code from numba/typed/typedlist.py (this is
tested separately).  Tests in this file build on each other in the order of
writing. For example, the first test, tests the creation, append and len of the
list. These are the barebones to do anything useful with a list. The subsequent
test for getitem assumes makes use of these three operations and therefore
assumes that they work.

    )dedent)njit)int32)register_jitable)types)TypingError)TestCaseMemoryLeakMixinoverride_configforbid_codegen)
listobjectListc                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	TestCreateAppendLengthz$Test list creation, append and len. c                 C   s*   t dd }dD ]}| ||| qd S )Nc                 S   s*   t t}t| D ]}|| qt|S Nr   new_listr   rangeappendlennli r   Z/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/numba/tests/test_listobject.pyfoo   s    
z4TestCreateAppendLength.test_list_create.<locals>.foor         d   r   assertEqualselfr   r   r   r   r   test_list_create   s    
z'TestCreateAppendLength.test_list_createc              
   C   sF   t dd2 t   tt}| t|t W 5 Q R X W 5 Q R X d S )NDISABLE_JITT)r
   r   r   r   r   r!   typelistr#   r   r   r   r   test_list_create_no_jit(   s    
z.TestCreateAppendLength.test_list_create_no_jitc              
   C   s\   t ddH t 6 tdddg}| t|t | |dddg W 5 Q R X W 5 Q R X d S )Nr%   Tr   r      )r
   r   r   r!   r&   r'   r(   r   r   r    test_nonempty_list_create_no_jit.   s
    z7TestCreateAppendLength.test_nonempty_list_create_no_jitN)__name__
__module____qualname____doc__r$   r)   r+   r   r   r   r   r      s   r   c                   @   s   e Zd ZdZdd ZdS )TestBoolzTest list bool.c                 C   s.   t dd }dD ]}| |||dk qd S )Nc                 S   s*   t t}t| D ]}|| qt|S r   )r   r   r   r   r   boolr   r   r   r   r   ;   s    
z$TestBool.test_list_bool.<locals>.foor   r   r    r"   r   r   r   test_list_bool:   s    
zTestBool.test_list_boolN)r,   r-   r.   r/   r2   r   r   r   r   r0   7   s   r0   c                   @   s   e Zd Zdd Zdd ZdS )TestAllocationc                 C   sX   t dd }tdD ]}| ||| qt dd }tdD ]}| ||| q>d S )Nc                 S   s   t jt| d}| S )N)Z	allocatedr   r   r   Z
_allocatedr   r   r   r   r   	foo_kwargI   s    z6TestAllocation.test_list_allocation.<locals>.foo_kwarg   c                 S   s   t t| }| S r   r4   r5   r   r   r   
foo_posargQ   s    z7TestAllocation.test_list_allocation.<locals>.foo_posargr   r   r!   )r#   r6   r   r8   r   r   r   test_list_allocationH   s    

z#TestAllocation.test_list_allocationc              	   C   sF   t dd }| t}| | d W 5 Q R X | dt|j d S )Nc                  S   s   t td} |  S Nr4   r   r   r   r   r   Y   s    z9TestAllocation.test_list_allocation_negative.<locals>.foor<   z expecting *allocated* to be >= 0)r   assertRaisesRuntimeErrorr!   assertInstr	exceptionr#   r   raisesr   r   r   test_list_allocation_negativeX   s    
z,TestAllocation.test_list_allocation_negativeN)r,   r-   r.   r:   rE   r   r   r   r   r3   F   s   r3   c                   @   s   e Zd Zdd ZdS )TestToFromMeminfoc                    sd   t dd }tt t  fdd}| }| |jd t||}ttdd}| || dS )	zB
        Exercise listobject.{_as_meminfo, _from_meminfo}
        c                  S   s.   t t} tddD ]}| | qt | S N
      )r   r   r   r   r   Z_as_meminfor   r   r   r   r   boxerm   s    
z:TestToFromMeminfo.test_list_to_from_meminfo.<locals>.boxerc                    sL   t |  }|d |d |d |d |d |d |d |d |d	 |d
 f
S )Nr   r   r   r*                  	   )r   Z_from_meminfo)mir   Zlsttyper   r   unboxerv   s    z<TestToFromMeminfo.test_list_to_from_meminfo.<locals>.unboxerr   rH   rI   N)r   r   ZListTyper   r!   refcountr'   r   )r#   rK   rT   rR   Zreceivedexpectedr   rS   r   test_list_to_from_meminfoh   s    

z+TestToFromMeminfo.test_list_to_from_meminfoN)r,   r-   r.   rW   r   r   r   r   rF   f   s   rF   c                   @   sX   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd ZdS )TestGetitemzTest list getitem. c                 C   s    t dd }| |dd d S )Nc                 S   s   t t}||  |d S Nr   r   r   r   r   r5   r   r   r   r      s    

z4TestGetitem.test_list_getitem_singleton.<locals>.foor   r    r#   r   r   r   r   test_list_getitem_singleton   s    
z'TestGetitem.test_list_getitem_singletonc                 C   s    t dd }| |dd d S )Nc                 S   s   t t}||  |d S r;   rZ   r5   r   r   r   r      s    

zBTestGetitem.test_list_getitem_singleton_negtive_index.<locals>.foor   r    r[   r   r   r   )test_list_getitem_singleton_negtive_index   s    
z5TestGetitem.test_list_getitem_singleton_negtive_indexc                 C   s.   t dd }dD ]\}}| ||| qd S )Nc                 S   s,   t t}tddD ]}|| q||  S rG   r   r   r   r   r   r   r   jr   r   r   r      s    
z3TestGetitem.test_list_getitem_multiple.<locals>.foor   rH   )rQ      )rL      )   )r<   rc   )rH   r    r#   r   r   r`   r   r   r   test_list_getitem_multiple   s    
z&TestGetitem.test_list_getitem_multiplec              
   C   sR   |    tdd }dD ]4}| t}|| W 5 Q R X | dt|j qd S )Nc                 S   s   t t}||  S r   r   r   r   r   r   r   r   r   r      s    
z<TestGetitem.test_list_getitem_empty_index_error.<locals>.foo)r   r   r<   list index out of rangedisable_leak_checkr   r>   
IndexErrorr@   rA   rB   r#   r   r   rD   r   r   r   #test_list_getitem_empty_index_error   s    
z/TestGetitem.test_list_getitem_empty_index_errorc              
   C   sR   |    tdd }dD ]4}| t}|| W 5 Q R X | dt|j qd S )Nc                 S   s,   t t}tddD ]}|| q||  S rG   r^   r_   r   r   r   r      s    
z?TestGetitem.test_list_getitem_multiple_index_error.<locals>.foo)rH   rl   rm   rp   r   r   r   &test_list_getitem_multiple_index_error   s    
z2TestGetitem.test_list_getitem_multiple_index_errorc              
   C   sR   |    tdd }dD ]4}| t}|| W 5 Q R X | dt|j qd S )Nc                 S   s   t t}||  S r   rj   rk   r   r   r   r      s    
z=TestGetitem.test_list_getitem_empty_typing_error.<locals>.fooxyzg      ?y              ?'list indices must be integers or slicesrn   r   r>   r   r@   rA   rB   rp   r   r   r   $test_list_getitem_empty_typing_error   s    
z0TestGetitem.test_list_getitem_empty_typing_errorc                 C   s0   t dd }tjD ]}| ||dd qd S )Nc                 S   s   t t}|d ||  S rY   rZ   rk   r   r   r   r      s    

zATestGetitem.test_list_getitem_integer_types_as_index.<locals>.foor   r   r   signed_domainr!   r#   r   tr   r   r   (test_list_getitem_integer_types_as_index   s    

z4TestGetitem.test_list_getitem_integer_types_as_indexc                    s.   t jD ]" t fdd}| | d qd S )Nc                     s    t t} | d |  d S )NrO   r   rZ   r=   tyr   r   r      s    

zETestGetitem.test_list_getitem_different_sized_uint_index.<locals>.foorO   )r   Zunsigned_domainr   r!   r[   r   r~   r   ,test_list_getitem_different_sized_uint_index   s    
z8TestGetitem.test_list_getitem_different_sized_uint_indexc                    s.   t jD ]" t fdd}| | d qd S )Nc                     s,   t t} | d |  d |  d fS )NrO   r   r<   rZ   r=   r~   r   r   r      s    

zDTestGetitem.test_list_getitem_different_sized_int_index.<locals>.foo)rO   rO   )r   rz   r   r!   r[   r   r~   r   +test_list_getitem_different_sized_int_index   s    
z7TestGetitem.test_list_getitem_different_sized_int_indexN)r,   r-   r.   r/   r\   r]   ri   rq   rs   rx   r}   r   r   r   r   r   r   rX      s   		rX   c                   @   s   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(S ))TestGetitemSlicez-Test list getitem when indexing with slices. c                 C   s   t dd }| | d d S )Nc                  S   s   t t} | d d  }t|S r   )r   r   r   r   r   r   r   r   r   r     s    
zDTestGetitemSlice.test_list_getitem_empty_slice_defaults.<locals>.foor   r    r[   r   r   r   &test_list_getitem_empty_slice_defaults  s    
z7TestGetitemSlice.test_list_getitem_empty_slice_defaultsc                 C   s   t dd }| | d d S )Nc                  S   s(   t t} | d | d d  }t|S rY   r   r   r   r   r   r   r   r   r   r     s    

zHTestGetitemSlice.test_list_getitem_singleton_slice_defaults.<locals>.foor   r    r[   r   r   r   *test_list_getitem_singleton_slice_defaults  s    
z;TestGetitemSlice.test_list_getitem_singleton_slice_defaultsc                 C   s.   t dd }dD ]\}}| ||| qd S )Nc                 S   s8   t t}tddD ]}|| q|d d  }||  S rG   r^   )r   r   r`   r   r   r   r   r     s
    
zGTestGetitemSlice.test_list_getitem_multiple_slice_defaults.<locals>.foora   r    rh   r   r   r   )test_list_getitem_multiple_slice_defaults  s    
z:TestGetitemSlice.test_list_getitem_multiple_slice_defaultsc                 C   s2   t dd }| \}}| |d | |d d S )Nc                  S   sZ   t t} tddD ]}| | q| dd  }t||d |d |d |d |d ffS 	NrH   rI   rM   r   r   r   r*   rL   r   r   r`   r   r   r   r   r   "  s
    
zHTestGetitemSlice.test_list_getitem_multiple_slice_pos_start.<locals>.foorM   rf   r7         rc   r    r#   r   lengthitemsr   r   r   *test_list_getitem_multiple_slice_pos_start!  s
    

z;TestGetitemSlice.test_list_getitem_multiple_slice_pos_startc                 C   s2   t dd }| \}}| |d | |d d S )Nc                  S   sZ   t t} tddD ]}| | q| d d }t||d |d |d |d |d ffS r   r   r   r   r   r   r   /  s
    
zGTestGetitemSlice.test_list_getitem_multiple_slice_pos_stop.<locals>.foorM   rH            rd   r    r   r   r   r   )test_list_getitem_multiple_slice_pos_stop.  s
    

z:TestGetitemSlice.test_list_getitem_multiple_slice_pos_stopc                 C   s2   t dd }| \}}| |d | |d d S )Nc                  S   sZ   t t} tddD ]}| | q| dd }t||d |d |d |d |d ffS )	NrH   rI   r   rO   r   r   r*   rL   r   r   r   r   r   r   <  s
    
zQTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_pos_stop.<locals>.foorM   )r   r   rd   rf   r7   r    r   r   r   r   3test_list_getitem_multiple_slice_pos_start_pos_stop;  s
    

zDTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_pos_stopc                 C   s2   t dd }| \}}| |d | |d d S )Nc                  S   sV   t t} tddD ]}| | q| ddd }t||d |d |d |d ffS )NrH   rI   r   rQ   r   r   r*   r   r   r   r   r   r   I  s
    
zZTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_pos_stop_pos_step.<locals>.foorL   )r   r   rf   r   r    r   r   r   r   <test_list_getitem_multiple_slice_pos_start_pos_stop_pos_stepH  s
    

zMTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_pos_stop_pos_stepc                 C   s2   t dd }| \}}| |d | |d d S )Nc                  S   sZ   t t} tddD ]}| | q| dd  }t||d |d |d |d |d ffS 	NrH   rI   re   r   r   r   r*   rL   r   r   r   r   r   r   V  s
    
zHTestGetitemSlice.test_list_getitem_multiple_slice_neg_start.<locals>.foorM   r   r    r   r   r   r   *test_list_getitem_multiple_slice_neg_startU  s
    

z;TestGetitemSlice.test_list_getitem_multiple_slice_neg_startc                 C   s2   t dd }| \}}| |d | |d d S )Nc                  S   sZ   t t} tddD ]}| | q| d d }t||d |d |d |d |d ffS r   r   r   r   r   r   r   c  s
    
zGTestGetitemSlice.test_list_getitem_multiple_slice_neg_stop.<locals>.foorM   r   r    r   r   r   r   )test_list_getitem_multiple_slice_neg_stopb  s
    

z:TestGetitemSlice.test_list_getitem_multiple_slice_neg_stopc                 C   s2   t dd }| \}}| |d | |d d S )Nc                  S   s\   t t} tddD ]}| | q| d d d }t||d |d |d |d |d ffS )	NrH   rI   r   r   r   r*   rL   r   r   r   r   r   r   p  s
    
zGTestGetitemSlice.test_list_getitem_multiple_slice_neg_step.<locals>.foorM   )rc   r   rf   r   r   r    r   r   r   r   )test_list_getitem_multiple_slice_neg_stepo  s
    

z:TestGetitemSlice.test_list_getitem_multiple_slice_neg_stepc                 C   s2   t dd }| \}}| |d | |d d S )Nc                  S   s\   t t} tddD ]}| | q| dd d }t||d |d |d |d |d ffS 	NrH   rI   rL   r<   r   r   r   r*   r   r   r   r   r   r   }  s
    
zQTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_neg_step.<locals>.foorM   rd   r   r   r   rH   r    r   r   r   r   3test_list_getitem_multiple_slice_pos_start_neg_step|  s
    

zDTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_neg_stepc                 C   s2   t dd }| \}}| |d | |d d S )Nc                  S   s\   t t} tddD ]}| | q| dd d }t||d |d |d |d |d	 ffS 
NrH   rI   ir<   r   r   r   r*   rL   r   r   r   r   r   r     s
    
zQTestGetitemSlice.test_list_getitem_multiple_slice_neg_start_neg_step.<locals>.foorM   r   r    r   r   r   r   3test_list_getitem_multiple_slice_neg_start_neg_step  s
    

zDTestGetitemSlice.test_list_getitem_multiple_slice_neg_start_neg_stepc                 C   s2   t dd }| \}}| |d | |d d S )Nc                  S   s\   t t} tddD ]}| | q| d dd }t||d |d |d |d |d ffS r   r   r   r   r   r   r     s
    
zPTestGetitemSlice.test_list_getitem_multiple_slice_pos_stop_neg_step.<locals>.foorM   rc   r   r   r7   rf   r    r   r   r   r   2test_list_getitem_multiple_slice_pos_stop_neg_step  s
    

zCTestGetitemSlice.test_list_getitem_multiple_slice_pos_stop_neg_stepc                 C   s2   t dd }| \}}| |d | |d d S )Nc                  S   s\   t t} tddD ]}| | q| d dd }t||d |d |d |d |d	 ffS r   r   r   r   r   r   r     s
    
zPTestGetitemSlice.test_list_getitem_multiple_slice_neg_stop_neg_step.<locals>.foorM   r   r    r   r   r   r   2test_list_getitem_multiple_slice_neg_stop_neg_step  s
    

zCTestGetitemSlice.test_list_getitem_multiple_slice_neg_stop_neg_stepc                 C   s2   t dd }| \}}| |d | |d d S )Nc                  S   s\   t t} tddD ]}| | q| ddd }t||d |d |d |d |d	 ffS )
NrH   rI   rP   r*   r<   r   r   r   rL   r   r   r   r   r   r     s
    
zZTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_pos_stop_neg_step.<locals>.foorM   r   r   r7   rf   rd   r    r   r   r   r   <test_list_getitem_multiple_slice_pos_start_pos_stop_neg_step  s
    

zMTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_pos_stop_neg_stepc                 C   s2   t dd }| \}}| |d | |d d S )Nc                  S   s\   t t} tddD ]}| | q| ddd }t||d |d |d |d	 |d
 ffS )NrH   rI   r   ir<   r   r   r   r*   rL   r   r   r   r   r   r     s
    
zZTestGetitemSlice.test_list_getitem_multiple_slice_neg_start_neg_stop_neg_step.<locals>.foorM   r   r    r   r   r   r   <test_list_getitem_multiple_slice_neg_start_neg_stop_neg_step  s
    

zMTestGetitemSlice.test_list_getitem_multiple_slice_neg_start_neg_stop_neg_stepc                 C   s   t dd }| | d d S )Nc                  S   s8   t t} tddD ]}| | q| dd  }t|S rG   r   r   r   r   r   r     s
    
zQTestGetitemSlice.test_list_getitem_multiple_slice_start_out_of_range.<locals>.foor   r    r[   r   r   r   3test_list_getitem_multiple_slice_start_out_of_range  s    
zDTestGetitemSlice.test_list_getitem_multiple_slice_start_out_of_rangec                 C   s   t dd }| | d d S )Nc                  S   s8   t t} tddD ]}| | q| d d }t|S NrH   rI   r   r   r   r   r   r   r     s
    
zHTestGetitemSlice.test_list_getitem_multiple_slice_stop_zero.<locals>.foor   r    r[   r   r   r   *test_list_getitem_multiple_slice_stop_zero  s    
z;TestGetitemSlice.test_list_getitem_multiple_slice_stop_zeroc              	   C   sF   |    tdd }| t}|  W 5 Q R X | dt|j d S )Nc                  S   s6   t t} tddD ]}| | q| d d d  d S r   r^   r   r`   r   r   r   r     s    
zTTestGetitemSlice.test_list_getitem_multiple_slice_zero_step_index_error.<locals>.foozslice step cannot be zerorn   r   r>   
ValueErrorr@   rA   rB   rC   r   r   r   6test_list_getitem_multiple_slice_zero_step_index_error  s    
zGTestGetitemSlice.test_list_getitem_multiple_slice_zero_step_index_errorN)r,   r-   r.   r/   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s(   	
r   c                   @   sP   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd ZdS )TestSetitemzTest list setitem. c                 C   s*   t dd }dD ]}| ||| qd S )Nc                 S   s$   t t}|d | |d< |d S rY   rZ   r5   r   r   r   r     s    

z4TestSetitem.test_list_setitem_singleton.<locals>.foor   r    r"   r   r   r   test_list_setitem_singleton  s    
z'TestSetitem.test_list_setitem_singletonc                 C   s*   t dd }dD ]}| ||| qd S )Nc                 S   s$   t t}|d | |d< |d S )Nr   r<   rZ   r5   r   r   r   r     s    

zCTestSetitem.test_list_setitem_singleton_negative_index.<locals>.foor   r    r"   r   r   r   *test_list_setitem_singleton_negative_index   s    
z6TestSetitem.test_list_setitem_singleton_negative_indexc              	   C   sT   |    tdd }| t |d W 5 Q R X | t |d W 5 Q R X d S )Nc                 S   s    t t}|d d|| < d S Nr   r   rZ   rk   r   r   r   r     s    

z@TestSetitem.test_list_setitem_singleton_index_error.<locals>.foor   r   rn   r   r>   ro   r[   r   r   r   'test_list_setitem_singleton_index_error  s    
z3TestSetitem.test_list_setitem_singleton_index_errorc                 C   sB   t dd }ttddtddD ]\}}| |||| q"d S )Nc                 S   s4   t t}tddD ]}|| q||| < ||  S rG   r^   )r   r   r   r`   r   r   r   r     s
    
z3TestSetitem.test_list_setitem_multiple.<locals>.foor   rH   rI      r   zipr   r!   r#   r   r   r   r   r   r   test_list_setitem_multiple  s    
z&TestSetitem.test_list_setitem_multiplec              	   C   sT   |    tdd }| t |d W 5 Q R X | t |d W 5 Q R X d S )Nc                 S   s0   t t}tddD ]}|| qd|| < d S r   r^   r_   r   r   r   r   *  s    
z?TestSetitem.test_list_setitem_multiple_index_error.<locals>.foorH   rr   r   r[   r   r   r   &test_list_setitem_multiple_index_error'  s    
z2TestSetitem.test_list_setitem_multiple_index_errorc              
   C   sR   |    tdd }dD ]4}| t}|| W 5 Q R X | dt|j qd S )Nc                 S   s    t t}|d d|| < d S r   rZ   rk   r   r   r   r   :  s    

zJTestSetitem.test_list_setitem_singleton_typing_error_on_index.<locals>.foort   rv   rw   rp   r   r   r   1test_list_setitem_singleton_typing_error_on_index7  s    
z=TestSetitem.test_list_setitem_singleton_typing_error_on_indexc              	   C   sF   |    tdd }| t}|  W 5 Q R X | dt|j d S )Nc                  S   s$   t t} | d d| d d < d S r   rZ   r=   r   r   r   r   L  s    

zITestSetitem.test_list_setitem_singleton_typing_error_on_item.<locals>.foozFcan only assign an iterable when using a slice with assignment/setitemrw   rC   r   r   r   0test_list_setitem_singleton_typing_error_on_itemI  s    
z<TestSetitem.test_list_setitem_singleton_typing_error_on_itemc                 C   s0   t dd }tjD ]}| ||dd qd S )Nc                 S   s$   t t}|d d|| < ||  S r   rZ   rk   r   r   r   r   ]  s    

zATestSetitem.test_list_setitem_integer_types_as_index.<locals>.foor   r   ry   r{   r   r   r   (test_list_setitem_integer_types_as_index[  s    

z4TestSetitem.test_list_setitem_integer_types_as_indexN)r,   r-   r.   r/   r   r   r   r   r   r   r   r   r   r   r   r   r     s   r   c                   @   sX   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd ZdS )TestPopzTest list pop. c                 C   s   t dd }| | d d S )Nc                  S   s$   t t} | d |  t| fS rY   r   r   r   r   popr   r=   r   r   r   r   n  s    

z,TestPop.test_list_pop_singleton.<locals>.foor   r   r    r[   r   r   r   test_list_pop_singletonm  s    
zTestPop.test_list_pop_singletonc                 C   s0   t dd }| |dd | |dd d S )Nc                 S   s&   t t}|d || t|fS rY   r   rk   r   r   r   r   w  s    

z2TestPop.test_list_pop_singleton_index.<locals>.foor   r   r<   r    r[   r   r   r   test_list_pop_singleton_indexv  s    
z%TestPop.test_list_pop_singleton_indexc                 C   s   t dd }| | d d S )Nc                  S   s.   t t} dD ]}| | q|  t| fS NrH   r   r   r   r   r   r   r   r     s    
z+TestPop.test_list_pop_multiple.<locals>.foo)r   r   r    r[   r   r   r   test_list_pop_multiple  s    
zTestPop.test_list_pop_multiplec                 C   sT   t dd }dD ]\}}| |||df qdD ]\}}| |||df q2d S )Nc                 S   s0   t t}dD ]}|| q|| t|fS r   r   r_   r   r   r   r     s    
z1TestPop.test_list_pop_multiple_index.<locals>.foo)rb   )r   r   )r   r   r   ))rH   )r   r   )r<   r   r    r   r   r   r   test_list_pop_multiple_index  s    
z$TestPop.test_list_pop_multiple_indexc                 C   s0   t dd }tjD ]}| ||dd qd S )Nc                 S   s   t t}|d || S rY   r   r   r   r   r   rk   r   r   r   r     s    

z9TestPop.test_list_pop_integer_types_as_index.<locals>.foor   ry   r{   r   r   r   $test_list_pop_integer_types_as_index  s    

z,TestPop.test_list_pop_integer_types_as_indexc              	   C   sF   |    tdd }| t}|  W 5 Q R X | dt|j d S )Nc                  S   s   t t} |   d S r   r   r   r   r   r=   r   r   r   r     s    
z=TestPop.test_list_pop_empty_index_error_no_index.<locals>.foopop from empty listrm   rC   r   r   r   (test_list_pop_empty_index_error_no_index  s    
z0TestPop.test_list_pop_empty_index_error_no_indexc              	   C   s   |    tdd }| t}|d W 5 Q R X | dt|j | t}|d W 5 Q R X | dt|j | t}|d W 5 Q R X | dt|j d S )Nc                 S   s   t t}||  d S r   r   rk   r   r   r   r     s    
z?TestPop.test_list_pop_empty_index_error_with_index.<locals>.foor<   r   r   r   rm   rC   r   r   r   *test_list_pop_empty_index_error_with_index  s*    
z2TestPop.test_list_pop_empty_index_error_with_indexc              	   C   sx   |    tdd }| t}|d W 5 Q R X | dt|j | t}|d W 5 Q R X | dt|j d S )Nc                 S   s,   t t}dD ]}|| q||  d S r   r   r_   r   r   r   r     s    
zATestPop.test_list_pop_mutiple_index_error_with_index.<locals>.foorl   r*   rm   rC   r   r   r   ,test_list_pop_mutiple_index_error_with_index  s    
z4TestPop.test_list_pop_mutiple_index_error_with_indexc              
   C   sR   |    tdd }dD ]4}| t}|| W 5 Q R X | dt|j qd S )Nc                 S   s   t t}|d || S rY   r   rk   r   r   r   r     s    

zBTestPop.test_list_pop_singleton_typing_error_on_index.<locals>.foort   z#argument for pop must be an integerrw   rp   r   r   r   -test_list_pop_singleton_typing_error_on_index  s    
z5TestPop.test_list_pop_singleton_typing_error_on_indexN)r,   r-   r.   r/   r   r   r   r   r   r   r   r   r   r   r   r   r   r   j  s   	

r   c                   @   s`   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd ZdS )TestListObjectDelitemzTest list delitem.
    c                 C   s   t dd }| | d d S )Nc                  S   s"   t t} | d | d= t| S rY   r   r=   r   r   r   r     s    

zDTestListObjectDelitem.test_list_singleton_delitem_index.<locals>.foor   r    r[   r   r   r   !test_list_singleton_delitem_index   s    
z7TestListObjectDelitem.test_list_singleton_delitem_indexc                 C   s   t dd }| | d d S )Nc                  S   s&   t t} | d | d d = t| S rY   r   r=   r   r   r   r     s    


zMTestListObjectDelitem.test_list_singleton_delitem_slice_defaults.<locals>.foor   r    r[   r   r   r   *test_list_singleton_delitem_slice_defaults
  s    
z@TestListObjectDelitem.test_list_singleton_delitem_slice_defaultsc                 C   s   t dd }| | d d S )Nc                  S   s&   t t} | d | dd = t| S rY   r   r=   r   r   r   r     s    


zJTestListObjectDelitem.test_list_singleton_delitem_slice_start.<locals>.foor   r    r[   r   r   r   'test_list_singleton_delitem_slice_start  s    
z=TestListObjectDelitem.test_list_singleton_delitem_slice_startc                 C   s   t dd }| | d d S )Nc                  S   s&   t t} | d | d d= t| S r   r   r=   r   r   r   r      s    


zITestListObjectDelitem.test_list_singleton_delitem_slice_stop.<locals>.foor   r    r[   r   r   r   &test_list_singleton_delitem_slice_stop  s    
z<TestListObjectDelitem.test_list_singleton_delitem_slice_stopc                 C   s   t dd }| | d d S )Nc                  S   s&   t t} | d | dd= t| S r   r   r=   r   r   r   r   *  s    


zOTestListObjectDelitem.test_list_singleton_delitem_slice_start_stop.<locals>.foor   r    r[   r   r   r   ,test_list_singleton_delitem_slice_start_stop(  s    
zBTestListObjectDelitem.test_list_singleton_delitem_slice_start_stopc                 C   s   t dd }| | d d S )Nc                  S   s(   t t} | d | dd d= t| S r   r   r=   r   r   r   r   4  s    

zOTestListObjectDelitem.test_list_singleton_delitem_slice_start_step.<locals>.foor   r    r[   r   r   r   ,test_list_singleton_delitem_slice_start_step2  s    
zBTestListObjectDelitem.test_list_singleton_delitem_slice_start_stepc                 C   s   t dd }| | d d S )Nc                  S   s(   t t} | d | ddd= t| S r   r   r=   r   r   r   r   >  s    

zTTestListObjectDelitem.test_list_singleton_delitem_slice_start_stop_step.<locals>.foor   r    r[   r   r   r   1test_list_singleton_delitem_slice_start_stop_step<  s    
zGTestListObjectDelitem.test_list_singleton_delitem_slice_start_stop_stepc                 C   s   t dd }| | d d S )Nc                  S   s:   t t} dD ]}| | q| d= t| | d | d fS )Nr   r   r   r   r   r   r   r   r   H  s
    
z=TestListObjectDelitem.test_list_multiple_delitem.<locals>.foo)r   r   r   r    r[   r   r   r   test_list_multiple_delitemF  s    
z0TestListObjectDelitem.test_list_multiple_delitemc                 C   s   t dd }| | d d S )Nc                  S   s0   t t} dD ]}| | q| d d = t| S r   r   r   r   r   r   r   S  s
    

zCTestListObjectDelitem.test_list_multiple_delitem_slice.<locals>.foor   r    r[   r   r   r    test_list_multiple_delitem_sliceQ  s    
z6TestListObjectDelitem.test_list_multiple_delitem_slicec                 C   s   t dd }| |  d S )Nc                  S   sZ   t t} tddD ]}| | qt t}tddD ]}|| q8| dd= || kS )NrH   rI   iir^   )r   r`   kr   r   r   r   _  s    


zHTestListObjectDelitem.test_list_multiple_delitem_off_by_one.<locals>.foor   
assertTruer[   r   r   r   %test_list_multiple_delitem_off_by_one\  s    

z;TestListObjectDelitem.test_list_multiple_delitem_off_by_oneN)r,   r-   r.   r/   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r     s   






r   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	TestContainszTest list contains. c                 C   s,   t dd }| |d | |d d S )Nc                 S   s   t t}| |kS r   rj   rk   r   r   r   r   q  s    
z2TestContains.test_list_contains_empty.<locals>.foor   r   r   assertFalser[   r   r   r   test_list_contains_emptyp  s    
z%TestContains.test_list_contains_emptyc                 C   s,   t dd }| |d | |d d S )Nc                 S   s   t t}|d | |kS rY   rZ   rk   r   r   r   r   z  s    

z6TestContains.test_list_contains_singleton.<locals>.foor   r   )r   r   r   r[   r   r   r   test_list_contains_singletony  s    
z)TestContains.test_list_contains_singletonc                 C   sL   t dd }tddD ]}| || qtddD ]}| || q4d S )Nc                 S   s,   t t}tddD ]}|| q| |kS rG   r^   r_   r   r   r   r     s    
z5TestContains.test_list_contains_multiple.<locals>.foorH   rI   r   )r   r   r   r   r"   r   r   r   test_list_contains_multiple  s    
z(TestContains.test_list_contains_multipleN)r,   r-   r.   r/   r   r   r   r   r   r   r   r   m  s   	
r   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )		TestCountzTest list count. c                 C   s    t dd }| |dd d S )Nc                 S   s   t t}|| S r   )r   r   r   countrk   r   r   r   r     s    
z,TestCount.test_list_count_empty.<locals>.foorH   r   r    r[   r   r   r   test_list_count_empty  s    
zTestCount.test_list_count_emptyc                 C   s0   t dd }| |dd | |dd d S )Nc                 S   s   t t}|d || S NrH   r   r   r   r   r   rk   r   r   r   r     s    

z0TestCount.test_list_count_singleton.<locals>.foor   r   rH   r    r[   r   r   r   test_list_count_singleton  s    
z#TestCount.test_list_count_singletonc                 C   sP   t dd }| |dd | |dd | |dd | |d	d
 d S )Nc                 S   s(   t t}dD ]}|| q|| S )N)r   r   r   r   r   r   r   r_   r   r   r   r     s    
z.TestCount.test_list_count_mutiple.<locals>.foorH   r   r   r   r   r   r   r*   r    r[   r   r   r   test_list_count_mutiple  s    
z!TestCount.test_list_count_mutipleN)r,   r-   r.   r/   r   r   r   r   r   r   r   r     s   
r   c                   @   s    e Zd ZdZdd Zdd ZdS )
TestExtendzTest list extend. c                 C   s@   t dd }| |dd | |dd | |dd d S )	Nc                 S   s   t t}||  t|S r   )r   r   r   extendr   )r   r   r   r   r   r     s    

z.TestExtend.test_list_extend_empty.<locals>.foo)r   r   )r   r   r   )r   r   r*   r*   r    r[   r   r   r   test_list_extend_empty  s
    
z!TestExtend.test_list_extend_emptyc              	   C   sF   |    tdd }| t}|  W 5 Q R X | dt|j d S )Nc                  S   s   t t} | d d S Nr   r   r   r   r   r=   r   r   r   r     s    
zBTestExtend.test_list_extend_typing_error_non_iterable.<locals>.fooz extend argument must be iterablerw   rC   r   r   r   *test_list_extend_typing_error_non_iterable  s    
z5TestExtend.test_list_extend_typing_error_non_iterableN)r,   r-   r.   r/   r   r   r   r   r   r   r     s   r   c                   @   s@   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dS )
TestInsertzTest list insert. c                 C   s*   t dd }dD ]}| ||d qd S )Nc                 S   s&   t t}|| d t||d fS Nr   r   )r   r   r   insertr   rk   r   r   r   r     s    
z.TestInsert.test_list_insert_empty.<locals>.foo)rg   re   r<   r   r   rL   rQ   )r   r   r    r"   r   r   r   test_list_insert_empty  s    
z!TestInsert.test_list_insert_emptyc                 C   sD   t dd }dD ]}| ||d qdD ]}| ||d q*d S )Nc                 S   s6   t t}|d || d t||d |d fS r   )r   r   r   r   r   r   rk   r   r   r   r     s    

z2TestInsert.test_list_insert_singleton.<locals>.foo)rg   r   r   r<   r   )r   r   r   )r   r   r*   rH   )r   r   r   r    r"   r   r   r   test_list_insert_singleton  s    
z%TestInsert.test_list_insert_singletonc                 C   s*   t dd }dD ]}| ||d qd S )Nc                 S   s>   t t}tdD ]}|d q|| d t|||  fS NrH   r   r   r   r   r   r   r   r   r   r_   r   r   r   r     s
    
z1TestInsert.test_list_insert_multiple.<locals>.foo)r   rL   rQ   r   r   r    r"   r   r   r   test_list_insert_multiple  s    
z$TestInsert.test_list_insert_multiplec                 C   s*   t dd }dD ]}| ||d qd S )Nc                 S   s>   t t}tdD ]}|d q|| d t||d fS r   r   r_   r   r   r   r     s
    
z8TestInsert.test_list_insert_multiple_before.<locals>.foo)irr   rg   r   r   r    r"   r   r   r    test_list_insert_multiple_before  s    
z+TestInsert.test_list_insert_multiple_beforec                 C   s*   t dd }dD ]}| ||d qd S )Nc                 S   s>   t t}tdD ]}|d q|| d t||d fS r   r   r_   r   r   r   r   	  s
    
z7TestInsert.test_list_insert_multiple_after.<locals>.foor   r   r    r"   r   r   r   test_list_insert_multiple_after  s    
z*TestInsert.test_list_insert_multiple_afterc              	   C   sF   |    tdd }| t}|  W 5 Q R X | dt|j d S )Nc                  S   s   t t} | dd d S )Nar   )r   r   r   r   r=   r   r   r   r     s    
z5TestInsert.test_list_insert_typing_error.<locals>.fooz$list insert indices must be integersrw   rC   r   r   r   test_list_insert_typing_error  s    
z(TestInsert.test_list_insert_typing_errorN)
r,   r-   r.   r/   r   r   r   r   r   r   r   r   r   r   r     s   
r   c                   @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )
TestRemovezTest list remove. c              	   C   s4   |    tdd }| t |  W 5 Q R X d S )Nc                  S   s   t t} | d d S rY   )r   r   r   remover=   r   r   r   r   *  s    
z.TestRemove.test_list_remove_empty.<locals>.foorn   r   r>   r   r[   r   r   r   test_list_remove_empty'  s
    
z!TestRemove.test_list_remove_emptyc                 C   s   t dd }| | d d S )Nc                  S   s&   t t} | d | d t| S rY   )r   r   r   r   r  r   r=   r   r   r   r   3  s    


z2TestRemove.test_list_remove_singleton.<locals>.foor   r    r[   r   r   r   test_list_remove_singleton2  s    
z%TestRemove.test_list_remove_singletonc              	   C   s4   |    tdd }| t |  W 5 Q R X d S )Nc                  S   s"   t t} | d | d d S r   )r   r   r   r   r  r=   r   r   r   r   ?  s    

z>TestRemove.test_list_remove_singleton_value_error.<locals>.foor  r[   r   r   r   &test_list_remove_singleton_value_error<  s
    
z1TestRemove.test_list_remove_singleton_value_errorc                 C   s   t dd }| | d d S )Nc                  S   s@   t t} tddD ]}| | q| d | d t| S )NrH   rI   r   rc   )r   r   r   r   r   r  r   r   r   r   r   r   I  s    


z1TestRemove.test_list_remove_multiple.<locals>.foorP   r    r[   r   r   r   test_list_remove_multipleH  s    
z$TestRemove.test_list_remove_multiplec              	   C   s4   |    tdd }| t |  W 5 Q R X d S )Nc                  S   s2   t t} tddD ]}| | q| d d S NrH   rI      )r   r   r   r   r   r  r   r   r   r   r   W  s    
z=TestRemove.test_list_remove_multiple_value_error.<locals>.foor  r[   r   r   r   %test_list_remove_multiple_value_errorT  s
    
z0TestRemove.test_list_remove_multiple_value_errorN)	r,   r-   r.   r/   r  r  r  r  r	  r   r   r   r   r   $  s   
r   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )		TestClearzTest list clear. c                 C   s   t dd }| | d d S )Nc                  S   s   t t} |   t| S r   )r   r   r   clearr   r=   r   r   r   r   f  s    
z,TestClear.test_list_clear_empty.<locals>.foor   r    r[   r   r   r   test_list_clear_emptye  s    
zTestClear.test_list_clear_emptyc                 C   s   t dd }| | d d S )Nc                  S   s$   t t} | d |   t| S rY   )r   r   r   r   r  r   r=   r   r   r   r   o  s    

z0TestClear.test_list_clear_singleton.<locals>.foor   r    r[   r   r   r   test_list_clear_singletonn  s    
z#TestClear.test_list_clear_singletonc                 C   s   t dd }| | d d S )Nc                  S   s2   t t} tdD ]}| d q|   t| S )NrH   r   )r   r   r   r   r   r  r   r   r   r   r   r   y  s
    
z/TestClear.test_list_clear_multiple.<locals>.foor   r    r[   r   r   r   test_list_clear_multiplex  s    
z"TestClear.test_list_clear_multipleN)r,   r-   r.   r/   r  r  r  r   r   r   r   r
  b  s   	
r
  c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	TestReversezTest list reverse. c                 C   s   t dd }| | d d S )Nc                  S   s   t t} |   t| S r   )r   r   r   reverser   r=   r   r   r   r     s    
z0TestReverse.test_list_reverse_empty.<locals>.foor   r    r[   r   r   r   test_list_reverse_empty  s    
z#TestReverse.test_list_reverse_emptyc                 C   s   t dd }| | d d S )Nc                  S   s,   t t} | d |   t| | d fS rY   )r   r   r   r   r  r   r=   r   r   r   r     s    

z4TestReverse.test_list_reverse_singleton.<locals>.foo)r   r   r    r[   r   r   r   test_list_reverse_singleton  s    
z'TestReverse.test_list_reverse_singletonc                 C   s   t dd }| | d d S )Nc                  S   sH   t t} tddD ]}| | q|   t| | d | d | d fS NrH   r   r   r   r   )r   r   r   r   r   r  r   r   r   r   r   r     s
    
z3TestReverse.test_list_reverse_multiple.<locals>.foo)r*   r   r   rH   r    r[   r   r   r   test_list_reverse_multiple  s    
z&TestReverse.test_list_reverse_multipleN)r,   r-   r.   r/   r  r  r  r   r   r   r   r    s   	
r  c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	TestCopyzTest list copy. c                 C   s   t dd }| | d d S )Nc                  S   s"   t t} |  }t| t|fS r   )r   r   r   copyr   r   r   r   r   r     s    
z*TestCopy.test_list_copy_empty.<locals>.foor   r    r[   r   r   r   test_list_copy_empty  s    
zTestCopy.test_list_copy_emptyc                 C   s   t dd }| | d d S )Nc                  S   s8   t t} | d |  }t| t|| d |d fS rY   )r   r   r   r   r  r   r   r   r   r   r     s    

z.TestCopy.test_list_copy_singleton.<locals>.foo)r   r   r   r   r    r[   r   r   r   test_list_copy_singleton  s    
z!TestCopy.test_list_copy_singletonc                 C   s   t dd }| | d d S )Nc               	   S   s`   t t} tddD ]}| | q|  }t| t|| d | d | d | d | d | d fS r  )r   r   r   r   r   r  r   r   r   r   r   r     s
    
z-TestCopy.test_list_copy_multiple.<locals>.foo)r*   r*   rH   r   r   rH   r   r   r    r[   r   r   r   test_list_copy_multiple  s    
z TestCopy.test_list_copy_multipleN)r,   r-   r.   r/   r  r  r  r   r   r   r   r    s   	
r  c                   @   s\   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd ZdS )	TestIndexc                 C   s   t dd }| | d d S )Nc                  S   s   t t} | d | dS r   r   r   r   r   indexr=   r   r   r   r     s    

z+TestIndex.test_index_singleton.<locals>.foor   r    r[   r   r   r   test_index_singleton  s    
zTestIndex.test_index_singletonc                 C   s>   t dd }ttdtddD ]\}}| ||| q d S )Nc                 S   s.   t t}tddD ]}|| q|| S rG   r   r   r   r   r   r  r_   r   r   r   r     s    
z*TestIndex.test_index_multiple.<locals>.foorH   rI   r   )r#   r   r   vr   r   r   test_index_multiple  s    
zTestIndex.test_index_multiplec                 C   s   t dd }| | d d S )Nc                  S   s.   t t} tddD ]}| d q| dS NrH   rI   r   r  )r   _r   r   r   r     s    
z+TestIndex.test_index_duplicate.<locals>.foor   r    r[   r   r   r   test_index_duplicate  s    
zTestIndex.test_index_duplicatec                 C   s.   t dd }tdD ]}| ||| qd S )Nc                 S   s0   t t}tddD ]}|d q|d| S r!  r  )startr   r"  r   r   r   r     s    
z6TestIndex.test_index_duplicate_with_start.<locals>.foorH   r9   r"   r   r   r   test_index_duplicate_with_start  s    
z)TestIndex.test_index_duplicate_with_startc              	   C   sF   |    tdd }| t}|  W 5 Q R X | dt|j d S )Nc                  S   s   t t} | d | dS r   r  r=   r   r   r   r     s    

z7TestIndex.test_index_singleton_value_error.<locals>.fooitem not in listr   rC   r   r   r    test_index_singleton_value_error  s    
z*TestIndex.test_index_singleton_value_errorc              	   C   sF   |    tdd }| t}|  W 5 Q R X | dt|j d S )Nc                  S   s.   t t} tddD ]}| | q| dS r  r  r   r   r   r   r     s    
z6TestIndex.test_index_multiple_value_error.<locals>.foor&  r   rC   r   r   r   test_index_multiple_value_error  s    
z)TestIndex.test_index_multiple_value_errorc              
   C   sh   |    tdd }| |dd tddD ]4}| t}|| W 5 Q R X | dt|j q.d S )Nc                 S   s0   t t}tddD ]}|| q|d| S rG   r  )r$  r   r`   r   r   r   r     s    
z<TestIndex.test_index_multiple_value_error_start.<locals>.foor   r   rH   r&  	rn   r   r!   r   r>   r   r@   rA   rB   rp   r   r   r   %test_index_multiple_value_error_start  s    
z/TestIndex.test_index_multiple_value_error_startc              
   C   sh   |    tdd }| |dd tddD ]4}| t}|| W 5 Q R X | dt|j q.d S )Nc                 S   s2   t t}tddD ]}|| q|dd| S )NrH   rI   rc   r   r  )endr   r`   r   r   r   r   (  s    
z:TestIndex.test_index_multiple_value_error_end.<locals>.foorH   rQ   r   r&  r)  rp   r   r   r   #test_index_multiple_value_error_end%  s    
z-TestIndex.test_index_multiple_value_error_endc              	   C   sF   |    tdd }| t}|  W 5 Q R X | dt|j d S )Nc                  S   s"   t t} | d | jdddS )Nr   r   )r$  r  r=   r   r   r   r   ;  s    

z4TestIndex.test_index_typing_error_start.<locals>.fooz+start argument for index must be an integerrw   rC   r   r   r   test_index_typing_error_start8  s    
z'TestIndex.test_index_typing_error_startc              	   C   sF   |    tdd }| t}|  W 5 Q R X | dt|j d S )Nc                  S   s"   t t} | d | jdddS )Nr   r   )r+  r  r=   r   r   r   r   K  s    

z2TestIndex.test_index_typing_error_end.<locals>.fooz)end argument for index must be an integerrw   rC   r   r   r   test_index_typing_error_endH  s    
z%TestIndex.test_index_typing_error_endN)r,   r-   r.   r  r   r#  r%  r'  r(  r*  r,  r-  r.  r   r   r   r   r    s   	
r  c                   @   s@   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dS )TestEqualNotEqualzTest list equal and not equal. c                 C   s   t dd }| | d d S )Nc                  S   s$   t t} t t}| |k| |kfS r   rj   r|   or   r   r   r   ]  s    

z4TestEqualNotEqual.test_list_empty_equal.<locals>.fooTFr    r[   r   r   r   test_list_empty_equal\  s    
z'TestEqualNotEqual.test_list_empty_equalc                 C   s   t dd }| | d d S )Nc                  S   s8   t t} | d t t}|d | |k| |kfS rY   rZ   r0  r   r   r   r   f  s
    



z8TestEqualNotEqual.test_list_singleton_equal.<locals>.foor2  r    r[   r   r   r   test_list_singleton_equale  s    
z+TestEqualNotEqual.test_list_singleton_equalc                 C   s   t dd }| | d d S )Nc                  S   s8   t t} | d t t}|d | |k| |kfS r   rZ   r0  r   r   r   r   q  s
    



z<TestEqualNotEqual.test_list_singleton_not_equal.<locals>.fooFTr    r[   r   r   r   test_list_singleton_not_equalp  s    
z/TestEqualNotEqual.test_list_singleton_not_equalc                 C   s   t dd }| | d d S )Nc                  S   s.   t t} | d t t}| |k| |kfS rY   rZ   r0  r   r   r   r   |  s    


z8TestEqualNotEqual.test_list_length_mismatch.<locals>.foor5  r    r[   r   r   r   test_list_length_mismatch{  s    
z+TestEqualNotEqual.test_list_length_mismatchc                 C   s   t dd }| | d d S )Nc                  S   sF   t t} t t}tdD ]}| | || q| |k| |kfS r   r^   r|   r1  r   r   r   r   r     s    


z7TestEqualNotEqual.test_list_multiple_equal.<locals>.foor2  r    r[   r   r   r   test_list_multiple_equal  s    
z*TestEqualNotEqual.test_list_multiple_equalc                 C   s   t dd }| | d d S )Nc                  S   sN   t t} t t}tdD ]}| | || qd|d< | |k| |kfS )NrH   *   r<   r^   r8  r   r   r   r     s    


z;TestEqualNotEqual.test_list_multiple_not_equal.<locals>.foor5  r    r[   r   r   r   test_list_multiple_not_equal  s    
	z.TestEqualNotEqual.test_list_multiple_not_equalN)
r,   r-   r.   r/   r3  r4  r6  r7  r9  r;  r   r   r   r   r/  Y  s   	
r/  c                   @   s    e Zd ZdZdd Zdd ZdS )TestIterzTest list iter. c                 C   s(   t dd }d}| ||t| d S )Nc                 S   s.   t t}||  d}|D ]}||7 }q|S rY   r   )r   r   rr`   r   r   r   r     s    


z$TestIter.test_list_iter.<locals>.foor   r   r*   rL   )r   r!   sumr#   r   r   r   r   r   test_list_iter  s    
	zTestIter.test_list_iterc              	   C   sP   |    tdd }| t}|  W 5 Q R X | djf t t|j d S )Nc                  S   s,   t t} | d | D ]}| | qd S )Nr>  )r   r   r   r   r   rJ   r   r   r   r     s    

z2TestIter.test_list_iter_self_mutation.<locals>.fooz!list was mutated during iteration)	rn   r   r>   r?   r@   formatlocalsrA   rB   rC   r   r   r   test_list_iter_self_mutation  s    
z%TestIter.test_list_iter_self_mutationN)r,   r-   r.   r/   rA  rD  r   r   r   r   r<    s   r<  c                   @   s   e Zd ZdZdd ZdS )TestStringItemz%Test list can take strings as items. c                 C   s.   t dd }| }| ddddgt| d S )Nc                  S   sP   t tj} | d | d | d | d | d | d | d | d fS )	Nr   bcdr   r   r   r*   )r   r   r   unicode_typer   r=   r   r   r   r     s    



z,TestStringItem.test_string_item.<locals>.foor   rF  rG  rH  )r   r!   r'   r@  r   r   r   test_string_item  s    
zTestStringItem.test_string_itemN)r,   r-   r.   r/   rJ  r   r   r   r   rE    s   rE  c                   @   sP   e Zd Zedd Zdd Zdd Zdd Zd	d
 Zdd Z	dd Z
dd ZdS )TestItemCastingc                 C   s   t |}|| d d S rY   )r   r   r   )fromtytotyr   r   r   r   r     s    
zTestItemCasting.fooc                 C   s   t || d S r   )rK  r   )r#   rL  rM  r   r   r   
check_good  s    zTestItemCasting.check_goodc              	   C   sB   |  t}t|| W 5 Q R X | djf t t|j d S )Nz%cannot safely cast {fromty} to {toty})	r>   r   rK  r   r@   rB  rC  rA   rB   )r#   rL  rM  rD   r   r   r   	check_bad  s    zTestItemCasting.check_badc                 C   sd   |  tjtj |  tjtj |  tjtj |  tjtj | tjtj |  tj	tj d S r   )
rN  r   r   float32float64
complex128Zint64rO  	complex64Zint8r#   r   r   r   test_cast_int_to  s    z TestItemCasting.test_cast_int_toc                 C   s4   |  tjtj |  tjtj |  tjtj d S r   )rN  r   rP  rQ  rS  rR  rT  r   r   r   test_cast_float_to  s    z"TestItemCasting.test_cast_float_toc                 C   s4   |  tjtj |  tjtj |  tjtj d S r   )rN  r   booleanr   rQ  rR  rT  r   r   r   test_cast_bool_to  s    z!TestItemCasting.test_cast_bool_toc              	   C   s>   t dd }| t}|  W 5 Q R X | dt|j d S )Nc                  S   s   t t} | d d S )Nru   rZ   r=   r   r   r   r     s    
z7TestItemCasting.test_cast_fail_unicode_int.<locals>.fooz(cannot safely cast unicode_type to int32r   r>   r   r@   rA   rB   rC   r   r   r   test_cast_fail_unicode_int  s    
z*TestItemCasting.test_cast_fail_unicode_intc              	   C   s>   t dd }| t}|  W 5 Q R X | dt|j d S )Nc                  S   s   t tj} | td d S rY   )r   r   r   rI  r   r   r=   r   r   r   r     s    z7TestItemCasting.test_cast_fail_int_unicode.<locals>.fooz!Cannot cast int32 to unicode_typerY  rC   r   r   r   test_cast_fail_int_unicode	  s    
z*TestItemCasting.test_cast_fail_int_unicodeN)r,   r-   r.   r   r   rN  rO  rU  rV  rX  rZ  r[  r   r   r   r   rK    s   
rK  c                  C   s   t t} | td | S r   rZ   r=   r   r   r   make_test_list  s    
r\  c                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )TestImmutablec                 C   s   t dd }| |  d S )Nc                  S   s   t  } |  S r   )r\  _is_mutabler=   r   r   r   r   "  s    z,TestImmutable.test_is_immutable.<locals>.foor   r[   r   r   r   test_is_immutable!  s    
zTestImmutable.test_is_immutablec                 C   s   t dd }| |  d S )Nc                  S   s   t  } |   |  S r   r\  _make_immutabler^  r=   r   r   r   r   )  s    z;TestImmutable.test_make_immutable_is_immutable.<locals>.foor   r[   r   r   r    test_make_immutable_is_immutable(  s    
z.TestImmutable.test_make_immutable_is_immutablec                 C   s0   t dd }| \}}| |d | | d S )Nc                  S   s   t  } |   t| |  fS r   )r\  ra  r   r^  r=   r   r   r   r   1  s    zATestImmutable.test_length_still_works_when_immutable.<locals>.foor   r   r!   r   )r#   r   r   mutabler   r   r   &test_length_still_works_when_immutable0  s
    

z4TestImmutable.test_length_still_works_when_immutablec                 C   s0   t dd }| \}}| |d | | d S )Nc                  S   s   t  } |   | d |  fS rY   r`  r=   r   r   r   r   ;  s    zBTestImmutable.test_getitem_still_works_when_immutable.<locals>.foor   rc  )r#   r   Z	test_itemrd  r   r   r   'test_getitem_still_works_when_immutable:  s
    

z5TestImmutable.test_getitem_still_works_when_immutablec              	   C   sF   |    tdd }| t}|  W 5 Q R X | dt|j d S )Nc                  S   s    t  } |   | td d S r   )r\  ra  r   r   r=   r   r   r   r   G  s    z,TestImmutable.test_append_fails.<locals>.foolist is immutabler   rC   r   r   r   test_append_failsD  s    
zTestImmutable.test_append_failsc              
   C   sT   |    dd }dD ]:}||}| t}|  W 5 Q R X | dt|j qdS )z@ Test that any attempt to mutate an immutable typed list fails. c                 S   s$   i }t td| | t|d S )NaJ  
                from numba.typed import listobject
                from numba import int32
                def bar():
                    lst = listobject.new_list(int32)
                    lst.append(int32(1))
                    lst._make_immutable()
                    zero = int32(0)
                    {}
                bar)execr   rB  r   )linecontextr   r   r   generate_functionW  s    		
z<TestImmutable.test_mutation_fails.<locals>.generate_function)	zlst.append(zero)zlst[0] = zeroz	lst.pop()z
del lst[0]zlst.extend((zero,))zlst.insert(0, zero)zlst.clear()zlst.reverse()z
lst.sort()rg  N)rn   r>   r   r@   rA   rB   )r#   rm  rk  r   rD   r   r   r   test_mutation_failsS  s    
z!TestImmutable.test_mutation_failsN)	r,   r-   r.   r_  rb  re  rf  rh  rn  r   r   r   r   r]    s   

r]  N),r/   textwrapr   Znumbar   r   Znumba.extendingr   Z
numba.corer   Znumba.core.errorsr   Znumba.tests.supportr   r	   r
   r   Znumba.typedr   r   r   r0   r3   rF   rX   r   r   r   r   r   r   r   r   r   r
  r  r  r  r/  r<  rE  rK  r\  r]  r   r   r   r   <module>   sH    | tx q%#Q>!!" F'A
