U
    ,d                     @   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   ?/tmp/pip-unpacked-wheel-eu7e0c37/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                   @   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 )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   Z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 |  d fS )NrO   r   r<   rZ   r=   tyr   r   r      s    

zDTestGetitem.test_list_getitem_different_sized_int_index.<locals>.foo)rO   rO   )r   Zinteger_domainr   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   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   ;  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_step:  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   H  s
    
zHTestGetitemSlice.test_list_getitem_multiple_slice_neg_start.<locals>.foorM   r   r    r   r   r   r   *test_list_getitem_multiple_slice_neg_startG  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   U  s
    
zGTestGetitemSlice.test_list_getitem_multiple_slice_neg_stop.<locals>.foorM   r   r    r   r   r   r   )test_list_getitem_multiple_slice_neg_stopT  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   b  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_stepa  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   o  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_stepn  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_index)  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   >  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_item;  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   O  s    

zATestSetitem.test_list_setitem_integer_types_as_index.<locals>.foor   r   ry   rz   r   r   r   (test_list_setitem_integer_types_as_indexM  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   `  s    

z,TestPop.test_list_pop_singleton.<locals>.foor   r   r    r[   r   r   r   test_list_pop_singleton_  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   i  s    

z2TestPop.test_list_pop_singleton_index.<locals>.foor   r   r<   r    r[   r   r   r   test_list_pop_singleton_indexh  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  s    
z+TestPop.test_list_pop_multiple.<locals>.foo)r   r   r    r[   r   r   r   test_list_pop_multipler  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   rz   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   \  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   &  s    

zOTestListObjectDelitem.test_list_singleton_delitem_slice_start_step.<locals>.foor   r    r[   r   r   r   ,test_list_singleton_delitem_slice_start_step$  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   0  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   :  s
    
z=TestListObjectDelitem.test_list_multiple_delitem.<locals>.foo)r   r   r   r    r[   r   r   r   test_list_multiple_delitem8  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   E  s
    

zCTestListObjectDelitem.test_list_multiple_delitem_slice.<locals>.foor   r    r[   r   r   r    test_list_multiple_delitem_sliceC  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   Q  s    


zHTestListObjectDelitem.test_list_multiple_delitem_off_by_one.<locals>.foor   
assertTruer[   r   r   r   %test_list_multiple_delitem_off_by_oneN  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   c  s    
z2TestContains.test_list_contains_empty.<locals>.foor   r   r   assertFalser[   r   r   r   test_list_contains_emptyb  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   l  s    

z6TestContains.test_list_contains_singleton.<locals>.foor   r   )r   r   r   r[   r   r   r   test_list_contains_singletonk  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   v  s    
z5TestContains.test_list_contains_multiple.<locals>.foorH   rI   r   )r   r   r   r   r"   r   r   r   test_list_contains_multipleu  s    
z(TestContains.test_list_contains_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 )		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   %  s    


z2TestRemove.test_list_remove_singleton.<locals>.foor   r    r[   r   r   r   test_list_remove_singleton$  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   1  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   ;  s    


z1TestRemove.test_list_remove_multiple.<locals>.foorP   r    r[   r   r   r   test_list_remove_multiple:  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   I  s    
z=TestRemove.test_list_remove_multiple_value_error.<locals>.foor   r[   r   r   r   %test_list_remove_multiple_value_errorF  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   X  s    
z,TestClear.test_list_clear_empty.<locals>.foor   r    r[   r   r   r   test_list_clear_emptyW  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   a  s    

z0TestClear.test_list_clear_singleton.<locals>.foor   r    r[   r   r   r   test_list_clear_singleton`  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   k  s
    
z/TestClear.test_list_clear_multiple.<locals>.foor   r    r[   r   r   r   test_list_clear_multiplej  s    
z"TestClear.test_list_clear_multipleN)r,   r-   r.   r/   r
  r  r  r   r   r   r   r  T  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   y  s    
z0TestReverse.test_list_reverse_empty.<locals>.foor   r    r[   r   r   r   test_list_reverse_emptyx  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  u  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_start*  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   =  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_end:  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   O  s    

z4TestEqualNotEqual.test_list_empty_equal.<locals>.fooTFr    r[   r   r   r   test_list_empty_equalN  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   r.  r   r   r   r   X  s
    



z8TestEqualNotEqual.test_list_singleton_equal.<locals>.foor0  r    r[   r   r   r   test_list_singleton_equalW  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   r.  r   r   r   r   c  s
    



z<TestEqualNotEqual.test_list_singleton_not_equal.<locals>.fooFTr    r[   r   r   r   test_list_singleton_not_equalb  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   r.  r   r   r   r   n  s    


z8TestEqualNotEqual.test_list_length_mismatch.<locals>.foor3  r    r[   r   r   r   test_list_length_mismatchm  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{   r/  r   r   r   r   r   x  s    


z7TestEqualNotEqual.test_list_multiple_equal.<locals>.foor0  r    r[   r   r   r   test_list_multiple_equalw  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^   r6  r   r   r   r     s    


z;TestEqualNotEqual.test_list_multiple_not_equal.<locals>.foor3  r    r[   r   r   r   test_list_multiple_not_equal  s    
	z.TestEqualNotEqual.test_list_multiple_not_equalN)
r,   r-   r.   r/   r1  r2  r4  r5  r7  r9  r   r   r   r   r-  K  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/   r?  rB  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   rD  rE  rF  )r   r!   r'   r>  r   r   r   test_string_item  s    
zTestStringItem.test_string_itemN)r,   r-   r.   r/   rH  r   r   r   r   rC    s   rC  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   )rI  r   )r#   rJ  rK  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   rI  r   r@   r@  rA  rA   rB   )r#   rJ  rK  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   )
rL  r   r   float32float64
complex128Zint64rM  	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   )rL  r   rN  rO  rQ  rP  rR  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   )rL  r   booleanr   rO  rP  rR  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   rG  r   r   r=   r   r   r   r     s    z7TestItemCasting.test_cast_fail_int_unicode.<locals>.fooz!Cannot cast int32 to unicode_typerW  rC   r   r   r   test_cast_fail_int_unicode  s    
z*TestItemCasting.test_cast_fail_int_unicodeN)r,   r-   r.   r   r   rL  rM  rS  rT  rV  rX  rY  r   r   r   r   rI    s   
rI  c                  C   s   t t} | td | S r   rZ   r=   r   r   r   make_test_list
  s    
rZ  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   )rZ  _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   rZ  _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   )rZ  r_  r   r\  r=   r   r   r   r   #  s    zATestImmutable.test_length_still_works_when_immutable.<locals>.foor   r   r!   r   )r#   r   r   mutabler   r   r   &test_length_still_works_when_immutable"  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   ra  )r#   r   Z	test_itemrb  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   )rZ  r_  r   r   r=   r   r   r   r   9  s    z,TestImmutable.test_append_fails.<locals>.foolist is immutabler   rC   r   r   r   test_append_fails6  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   r@  r   )linecontextr   r   r   generate_functionI  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()re  N)rn   r>   r   r@   rA   rB   )r#   rk  ri  r   rD   r   r   r   test_mutation_failsE  s    
z!TestImmutable.test_mutation_failsN)	r,   r-   r.   r]  r`  rc  rd  rf  rl  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:  rC  rI  rZ  r[  r   r   r   r   <module>   sH    n tx q%#Q>!!" F'A
