o
    1&i                     @   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                   @   (   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   *   t dd }dD ]
}| ||| qd S )Nc                 S   *   t t}t| D ]}|| q	t|S Nr   new_listr   rangeappendlennli r   FC:\wamp64\www\opt\env\Lib\site-packages\numba/tests/test_listobject.pyfoo      
z4TestCreateAppendLength.test_list_create.<locals>.foor         d   r   assertEqualselfr   r   r   r   r   test_list_create   
   
z'TestCreateAppendLength.test_list_createc              	   C   s   t dd1 t  tt}| t|t W d    n1 s!w   Y  W d    d S W d    d S 1 s9w   Y  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: t  tg d}| t|t | |g d W d    n1 s*w   Y  W d    d S W d    d S 1 sBw   Y  d S )Nr*   Tr!   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.   r1   r   r   r   r   r      s
    r   c                   @      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   r   r   )r   r   r   r   r   boolr   r   r   r   r   ;   r   z$TestBool.test_list_bool.<locals>.foor    r   r$   r&   r   r   r   test_list_bool:   s
   
zTestBool.test_list_boolN)r2   r3   r4   r5   r9   r   r   r   r   r7   7       r7   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   r<   r=   r   r   r   
foo_posargQ      z7TestAllocation.test_list_allocation.<locals>.foo_posargr   r   r%   )r'   r>   r   r@   r   r   r   test_list_allocationH   s   

z#TestAllocation.test_list_allocationc                 C   sZ   t dd }| t}| | d W d    n1 sw   Y  | dt|j d S )Nc                  S   s   t td} |  S Nr<   r   r   r   r   r   Y   rA   z9TestAllocation.test_list_allocation_negative.<locals>.foorE   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)r2   r3   r4   rC   rN   r   r   r   r   r;   F   s    r;   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      

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"   r0                  	   )r   Z_from_meminfo)mir   Zlsttyper   r   unboxerv   s   @z<TestToFromMeminfo.test_list_to_from_meminfo.<locals>.unboxerr!   rQ   rR   N)r   r   ZListTyper   r%   refcountr,   r   )r'   rT   r^   r\   Zreceivedexpectedr   r]   r   test_list_to_from_meminfoh   s   

z+TestToFromMeminfo.test_list_to_from_meminfoN)r2   r3   r4   ra   r   r   r   r   rO   f   s    rO   c                   @   X   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       t dd }| |dd d S )Nc                 S      t t}||  |d S Nr   r   r   r   r   r=   r   r   r   r         

z4TestGetitem.test_list_getitem_singleton.<locals>.foor   r$   r'   r   r   r   r   test_list_getitem_singleton      
z'TestGetitem.test_list_getitem_singletonc                 C   rd   )Nc                 S   re   rD   rg   r=   r   r   r   r      rh   zBTestGetitem.test_list_getitem_singleton_negtive_index.<locals>.foor   r$   ri   r   r   r   )test_list_getitem_singleton_negtive_index   rk   z5TestGetitem.test_list_getitem_singleton_negtive_indexc                 C   .   t dd }dD ]\}}| ||| qd S )Nc                 S   ,   t t}tddD ]}|| q
||  S rP   r   r   r   r   r   r   r   jr   r   r   r         
z3TestGetitem.test_list_getitem_multiple.<locals>.foor   rQ   )r[      )rV      )   )rE   ru   )rQ   r$   r'   r   r   rq   r   r   r   test_list_getitem_multiple   
   
z&TestGetitem.test_list_getitem_multiplec              	   C   f   |    tdd }dD ]$}| t}|| W d    n1 s"w   Y  | dt|j qd S )Nc                 S      t t}||  S r   r   r   r   r   r   r   r   r   r         
z<TestGetitem.test_list_getitem_empty_index_error.<locals>.foo)r!   r   rE   list index out of rangedisable_leak_checkr   rG   
IndexErrorrI   rJ   rK   r'   r   r   rM   r   r   r   #test_list_getitem_empty_index_error      

z/TestGetitem.test_list_getitem_empty_index_errorc              	   C   r}   )Nc                 S   rn   rP   ro   rp   r   r   r   r      rr   z?TestGetitem.test_list_getitem_multiple_index_error.<locals>.foo)rQ   r   r   r   r   r   r   &test_list_getitem_multiple_index_error      

z2TestGetitem.test_list_getitem_multiple_index_errorc              	   C   r}   )Nc                 S   r~   r   r   r   r   r   r   r      r   z=TestGetitem.test_list_getitem_empty_typing_error.<locals>.fooxyzg      ?y              ?'list indices must be integers or slicesr   r   rG   r   rI   rJ   rK   r   r   r   r   $test_list_getitem_empty_typing_error   r   z0TestGetitem.test_list_getitem_empty_typing_errorc                 C   0   t dd }tjD ]}| ||dd q	d S )Nc                 S   s   t t}|d ||  S rf   rg   r   r   r   r   r      rh   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   
   

z4TestGetitem.test_list_getitem_integer_types_as_indexc                    .   t jD ] t fdd}| | d qd S )Nc                     s    t t} | d |  d S )NrY   r   rg   rF   tyr   r   r         

zETestGetitem.test_list_getitem_different_sized_uint_index.<locals>.foorY   )r   Zunsigned_domainr   r%   ri   r   r   r   ,test_list_getitem_different_sized_uint_index   
   
z8TestGetitem.test_list_getitem_different_sized_uint_indexc                    r   )Nc                     s,   t t} | d |  d |  d fS )NrY   r   rE   rg   rF   r   r   r   r      s   

zDTestGetitem.test_list_getitem_different_sized_int_index.<locals>.foo)rY   rY   )r   r   r   r%   ri   r   r   r   +test_list_getitem_different_sized_int_index   r   z7TestGetitem.test_list_getitem_different_sized_int_indexN)r2   r3   r4   r5   rj   rl   r{   r   r   r   r   r   r   r   r   r   r   rc      s    		rc   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      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$   ri   r   r   r   &test_list_getitem_empty_slice_defaults     
z7TestGetitemSlice.test_list_getitem_empty_slice_defaultsc                 C   r   )Nc                  S   s(   t t} | d | d d  }t|S rf   r   r   r   r   r   r   r   r   r   r        

zHTestGetitemSlice.test_list_getitem_singleton_slice_defaults.<locals>.foor!   r$   ri   r   r   r   *test_list_getitem_singleton_slice_defaults     
z;TestGetitemSlice.test_list_getitem_singleton_slice_defaultsc                 C   rm   )Nc                 S   s8   t t}tddD ]}|| q
|d d  }||  S rP   ro   )r   r   rq   r   r   r   r   r     
   
zGTestGetitemSlice.test_list_getitem_multiple_slice_defaults.<locals>.foors   r$   rz   r   r   r   )test_list_getitem_multiple_slice_defaults  s
   
z:TestGetitemSlice.test_list_getitem_multiple_slice_defaultsc                 C   2   t dd }| \}}| |d | |d d S )Nc                  S   Z   t t} tddD ]}| | q
| dd  }t||d |d |d |d |d ffS 	NrQ   rR   rW   r   r!   r"   r0   rV   r   r   rq   r   r   r   r   r   "  
   
*zHTestGetitemSlice.test_list_getitem_multiple_slice_pos_start.<locals>.foorW   rx   r?         ru   r$   r'   r   lengthitemsr   r   r   *test_list_getitem_multiple_slice_pos_start!  
   

z;TestGetitemSlice.test_list_getitem_multiple_slice_pos_startc                 C   r   )Nc                  S   Z   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   /  r   zGTestGetitemSlice.test_list_getitem_multiple_slice_pos_stop.<locals>.foorW   rQ            rv   r$   r   r   r   r   )test_list_getitem_multiple_slice_pos_stop.  r   z:TestGetitemSlice.test_list_getitem_multiple_slice_pos_stopc                 C   r   )Nc                  S   sZ   t t} tddD ]}| | q
| dd }t||d |d |d |d |d ffS )	NrQ   rR   r"   rY   r   r!   r0   rV   r   r   r   r   r   r   <  r   zQTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_pos_stop.<locals>.foorW   )r   r   rv   rx   r?   r$   r   r   r   r   3test_list_getitem_multiple_slice_pos_start_pos_stop;  r   zDTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_pos_stopc                 C   r   )Nc                  S   sV   t t} tddD ]}| | q
| ddd }t||d |d |d |d ffS )NrQ   rR   r!   r[   r"   r   r0   r   r   r   r   r   r   I  s
   
$zZTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_pos_stop_pos_step.<locals>.foorV   )r   r   rx   r   r$   r   r   r   r   <test_list_getitem_multiple_slice_pos_start_pos_stop_pos_stepH  r   zMTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_pos_stop_pos_stepc                 C   r   )Nc                  S   r   	NrQ   rR   rw   r   r!   r"   r0   rV   r   r   r   r   r   r   V  r   zHTestGetitemSlice.test_list_getitem_multiple_slice_neg_start.<locals>.foorW   r   r$   r   r   r   r   *test_list_getitem_multiple_slice_neg_startU  r   z;TestGetitemSlice.test_list_getitem_multiple_slice_neg_startc                 C   r   )Nc                  S   r   r   r   r   r   r   r   r   c  r   zGTestGetitemSlice.test_list_getitem_multiple_slice_neg_stop.<locals>.foorW   r   r$   r   r   r   r   )test_list_getitem_multiple_slice_neg_stopb  r   z:TestGetitemSlice.test_list_getitem_multiple_slice_neg_stopc                 C   r   )Nc                  S   s\   t t} tddD ]}| | q
| d d d }t||d |d |d |d |d ffS )	NrQ   rR   r   r!   r"   r0   rV   r   r   r   r   r   r   p  
   
*zGTestGetitemSlice.test_list_getitem_multiple_slice_neg_step.<locals>.foorW   )ru   r   rx   r   r   r$   r   r   r   r   )test_list_getitem_multiple_slice_neg_stepo  r   z:TestGetitemSlice.test_list_getitem_multiple_slice_neg_stepc                 C   r   )Nc                  S   s\   t t} tddD ]}| | q
| dd d }t||d |d |d |d |d ffS 	NrQ   rR   rV   rE   r   r!   r"   r0   r   r   r   r   r   r   }  r   zQTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_neg_step.<locals>.foorW   rv   r   r   r   rQ   r$   r   r   r   r   3test_list_getitem_multiple_slice_pos_start_neg_step|  r   zDTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_neg_stepc                 C   r   )Nc                  S   s\   t t} tddD ]}| | q
| dd d }t||d |d |d |d |d	 ffS 
NrQ   rR   irE   r   r!   r"   r0   rV   r   r   r   r   r   r     r   zQTestGetitemSlice.test_list_getitem_multiple_slice_neg_start_neg_step.<locals>.foorW   r   r$   r   r   r   r   3test_list_getitem_multiple_slice_neg_start_neg_step  r   zDTestGetitemSlice.test_list_getitem_multiple_slice_neg_start_neg_stepc                 C   r   )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     r   zPTestGetitemSlice.test_list_getitem_multiple_slice_pos_stop_neg_step.<locals>.foorW   ru   r   r   r?   rx   r$   r   r   r   r   2test_list_getitem_multiple_slice_pos_stop_neg_step  r   zCTestGetitemSlice.test_list_getitem_multiple_slice_pos_stop_neg_stepc                 C   r   )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     r   zPTestGetitemSlice.test_list_getitem_multiple_slice_neg_stop_neg_step.<locals>.foorW   r   r$   r   r   r   r   2test_list_getitem_multiple_slice_neg_stop_neg_step  r   zCTestGetitemSlice.test_list_getitem_multiple_slice_neg_stop_neg_stepc                 C   r   )Nc                  S   s\   t t} tddD ]}| | q
| ddd }t||d |d |d |d |d	 ffS )
NrQ   rR   rZ   r0   rE   r   r!   r"   rV   r   r   r   r   r   r     r   zZTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_pos_stop_neg_step.<locals>.foorW   r   r   r?   rx   rv   r$   r   r   r   r   <test_list_getitem_multiple_slice_pos_start_pos_stop_neg_step  r   zMTestGetitemSlice.test_list_getitem_multiple_slice_pos_start_pos_stop_neg_stepc                 C   r   )Nc                  S   s\   t t} tddD ]}| | q
| ddd }t||d |d |d |d	 |d
 ffS )NrQ   rR   r   irE   r   r!   r"   r0   rV   r   r   r   r   r   r     r   zZTestGetitemSlice.test_list_getitem_multiple_slice_neg_start_neg_stop_neg_step.<locals>.foorW   r   r$   r   r   r   r   <test_list_getitem_multiple_slice_neg_start_neg_stop_neg_step  r   zMTestGetitemSlice.test_list_getitem_multiple_slice_neg_start_neg_stop_neg_stepc                 C   r   )Nc                  S   s8   t t} tddD ]}| | q
| dd  }t|S rP   r   r   r   r   r   r     r   zQTestGetitemSlice.test_list_getitem_multiple_slice_start_out_of_range.<locals>.foor   r$   ri   r   r   r   3test_list_getitem_multiple_slice_start_out_of_range     
zDTestGetitemSlice.test_list_getitem_multiple_slice_start_out_of_rangec                 C   r   )Nc                  S   s8   t t} tddD ]}| | q
| d d }t|S NrQ   rR   r   r   r   r   r   r   r     r   zHTestGetitemSlice.test_list_getitem_multiple_slice_stop_zero.<locals>.foor   r$   ri   r   r   r   *test_list_getitem_multiple_slice_stop_zero  r   z;TestGetitemSlice.test_list_getitem_multiple_slice_stop_zeroc                 C   Z   |    tdd }| t}|  W d    n1 sw   Y  | dt|j d S )Nc                  S   s6   t t} tddD ]}| | q
| d d d  d S r   ro   r   rq   r   r   r   r     s   
zTTestGetitemSlice.test_list_getitem_multiple_slice_zero_step_index_error.<locals>.foozslice step cannot be zeror   r   rG   
ValueErrorrI   rJ   rK   rL   r   r   r   6test_list_getitem_multiple_slice_zero_step_index_error     
zGTestGetitemSlice.test_list_getitem_multiple_slice_zero_step_index_errorN)r2   r3   r4   r5   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   r   )Nc                 S   s$   t t}|d | |d< |d S rf   rg   r=   r   r   r   r        

z4TestSetitem.test_list_setitem_singleton.<locals>.foor    r$   r&   r   r   r   test_list_setitem_singleton  r)   z'TestSetitem.test_list_setitem_singletonc                 C   r   )Nc                 S   s$   t t}|d | |d< |d S )Nr   rE   rg   r=   r   r   r   r     r   zCTestSetitem.test_list_setitem_singleton_negative_index.<locals>.foor    r$   r&   r   r   r   *test_list_setitem_singleton_negative_index   r)   z6TestSetitem.test_list_setitem_singleton_negative_indexc                 C   ~   |    tdd }| t |d W d    n1 sw   Y  | t |d W d    d S 1 s8w   Y  d S )Nc                 S       t t}|d d|| < d S Nr   r!   rg   r   r   r   r   r     r   z@TestSetitem.test_list_setitem_singleton_index_error.<locals>.foor!   r   r   r   rG   r   ri   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 rP   ro   )r   r   r   rq   r   r   r   r     s
   
z3TestSetitem.test_list_setitem_multiple.<locals>.foor   rQ   rR      r   zipr   r%   r'   r   r   r   r   r   r   test_list_setitem_multiple  s
   
z&TestSetitem.test_list_setitem_multiplec                 C   r   )Nc                 S   s0   t t}tddD ]}|| q
d|| < d S r   ro   rp   r   r   r   r   *     
z?TestSetitem.test_list_setitem_multiple_index_error.<locals>.foorQ   r   r   ri   r   r   r   &test_list_setitem_multiple_index_error'  s   


"z2TestSetitem.test_list_setitem_multiple_index_errorc              	   C   r}   )Nc                 S   r   r   rg   r   r   r   r   r   :  s   

zJTestSetitem.test_list_setitem_singleton_typing_error_on_index.<locals>.foor   r   r   r   r   r   r   1test_list_setitem_singleton_typing_error_on_index7  r   z=TestSetitem.test_list_setitem_singleton_typing_error_on_indexc                 C   r   )Nc                  S   s$   t t} | d d| d d < d S r   rg   rF   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/setitemr   rL   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   rg   r   r   r   r   r   ]  r   zATestSetitem.test_list_setitem_integer_types_as_index.<locals>.foor   r!   r   r   r   r   r   (test_list_setitem_integer_types_as_index[  s
   

z4TestSetitem.test_list_setitem_integer_types_as_indexN)r2   r3   r4   r5   r   r   r   r   r   r   r   r   r   r   r   r   r     s    r   c                   @   rb   )TestPopzTest list pop. c                 C   r   )Nc                  S   s$   t t} | d |  t| fS rf   r   r   r   r   popr   rF   r   r   r   r   n     

z,TestPop.test_list_pop_singleton.<locals>.foor   r   r$   ri   r   r   r   test_list_pop_singletonm  r   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 rf   r   r   r   r   r   r   w  s   

z2TestPop.test_list_pop_singleton_index.<locals>.foor   r   rE   r$   ri   r   r   r   test_list_pop_singleton_indexv     
z%TestPop.test_list_pop_singleton_indexc                 C   r   )Nc                  S   s.   t t} dD ]}| | q|  t| fS NrQ   r   r   r   r   r   r   r   r     s   
z+TestPop.test_list_pop_multiple.<locals>.foo)r   r"   r$   ri   r   r   r   test_list_pop_multiple  r   zTestPop.test_list_pop_multiplec                 C   sT   t dd }dD ]\}}| |||df qdD ]\}}| |||df qd S )Nc                 S   s0   t t}dD ]}|| q|| t|fS r   r   rp   r   r   r   r     s   
z1TestPop.test_list_pop_multiple_index.<locals>.foo)rt   )r!   r   )r"   r   r"   ))rQ   )r   r   )rE   r   r$   r   r   r   r   test_list_pop_multiple_index  s   
z$TestPop.test_list_pop_multiple_indexc                 C   r   )Nc                 S      t t}|d || S rf   r   r   r   r   r   r   r   r   r   r        


z9TestPop.test_list_pop_integer_types_as_index.<locals>.foor   r   r   r   r   r   $test_list_pop_integer_types_as_index  r   z,TestPop.test_list_pop_integer_types_as_indexc                 C   r   )Nc                  S   s   t t} |   d S r   r   r   r   r   rF   r   r   r   r     s   
z=TestPop.test_list_pop_empty_index_error_no_index.<locals>.foopop from empty listr   rL   r   r   r   (test_list_pop_empty_index_error_no_index     
z0TestPop.test_list_pop_empty_index_error_no_indexc                 C   s   |    tdd }| t}|d W d    n1 sw   Y  | dt|j | t}|d W d    n1 s@w   Y  | dt|j | t}|d W d    n1 sbw   Y  | dt|j d S )Nc                 S   s   t t}||  d S r   r   r   r   r   r   r        
z?TestPop.test_list_pop_empty_index_error_with_index.<locals>.foorE   r   r   r!   r   rL   r   r   r   *test_list_pop_empty_index_error_with_index  s0   



z2TestPop.test_list_pop_empty_index_error_with_indexc                 C   s   |    tdd }| t}|d W d    n1 sw   Y  | dt|j | t}|d W d    n1 s@w   Y  | dt|j d S )Nc                 S   s,   t t}dD ]}|| q||  d S r   r   rp   r   r   r   r     s   
zATestPop.test_list_pop_mutiple_index_error_with_index.<locals>.foor   r0   r   rL   r   r   r   ,test_list_pop_mutiple_index_error_with_index  s"   


z4TestPop.test_list_pop_mutiple_index_error_with_indexc              	   C   r}   )Nc                 S   r   rf   r   r   r   r   r   r     s   


zBTestPop.test_list_pop_singleton_typing_error_on_index.<locals>.foor   z#argument for pop must be an integerr   r   r   r   r   -test_list_pop_singleton_typing_error_on_index  r   z5TestPop.test_list_pop_singleton_typing_error_on_indexN)r2   r3   r4   r5   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   r   )Nc                  S   s"   t t} | d | d= t| S rf   r   rF   r   r   r   r     s   

zDTestListObjectDelitem.test_list_singleton_delitem_index.<locals>.foor   r$   ri   r   r   r   !test_list_singleton_delitem_index      
z7TestListObjectDelitem.test_list_singleton_delitem_indexc                 C   r   )Nc                  S   s&   t t} | d | d d = t| S rf   r   rF   r   r   r   r        


zMTestListObjectDelitem.test_list_singleton_delitem_slice_defaults.<locals>.foor   r$   ri   r   r   r   *test_list_singleton_delitem_slice_defaults
  r	  z@TestListObjectDelitem.test_list_singleton_delitem_slice_defaultsc                 C   r   )Nc                  S   s&   t t} | d | dd = t| S rf   r   rF   r   r   r   r     r
  zJTestListObjectDelitem.test_list_singleton_delitem_slice_start.<locals>.foor   r$   ri   r   r   r   'test_list_singleton_delitem_slice_start  r	  z=TestListObjectDelitem.test_list_singleton_delitem_slice_startc                 C   r   )Nc                  S   s&   t t} | d | d d= t| S r   r   rF   r   r   r   r      r
  zITestListObjectDelitem.test_list_singleton_delitem_slice_stop.<locals>.foor   r$   ri   r   r   r   &test_list_singleton_delitem_slice_stop  r	  z<TestListObjectDelitem.test_list_singleton_delitem_slice_stopc                 C   r   )Nc                  S   s&   t t} | d | dd= t| S r   r   rF   r   r   r   r   *  r
  zOTestListObjectDelitem.test_list_singleton_delitem_slice_start_stop.<locals>.foor   r$   ri   r   r   r   ,test_list_singleton_delitem_slice_start_stop(  r	  zBTestListObjectDelitem.test_list_singleton_delitem_slice_start_stopc                 C   r   )Nc                  S   s(   t t} | d | dd d= t| S r   r   rF   r   r   r   r   4  r   zOTestListObjectDelitem.test_list_singleton_delitem_slice_start_step.<locals>.foor   r$   ri   r   r   r   ,test_list_singleton_delitem_slice_start_step2  r	  zBTestListObjectDelitem.test_list_singleton_delitem_slice_start_stepc                 C   r   )Nc                  S   s(   t t} | d | ddd= t| S r   r   rF   r   r   r   r   >  r   zTTestListObjectDelitem.test_list_singleton_delitem_slice_start_stop_step.<locals>.foor   r$   ri   r   r   r   1test_list_singleton_delitem_slice_start_stop_step<  r	  zGTestListObjectDelitem.test_list_singleton_delitem_slice_start_stop_stepc                 C   r   )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$   ri   r   r   r   test_list_multiple_delitemF     
z0TestListObjectDelitem.test_list_multiple_delitemc                 C   r   )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$   ri   r   r   r    test_list_multiple_delitem_sliceQ  r  z6TestListObjectDelitem.test_list_multiple_delitem_slicec                 C      t dd }| |  d S )Nc                  S   sZ   t t} tddD ]}| | q
t t}tddD ]}|| q| dd= || kS )NrQ   rR   iiro   )r   rq   kr   r   r   r   _  s   


zHTestListObjectDelitem.test_list_multiple_delitem_off_by_one.<locals>.foor   
assertTrueri   r   r   r   %test_list_multiple_delitem_off_by_one\  s   

z;TestListObjectDelitem.test_list_multiple_delitem_off_by_oneN)r2   r3   r4   r5   r  r  r  r  r  r  r  r  r  r  r   r   r   r   r    s    






r  c                   @   r   )	TestContainszTest list contains. c                 C   s,   t dd }| |d | |d d S )Nc                 S   s   t t}| |v S r   r   r   r   r   r   r   q  r   z2TestContains.test_list_contains_empty.<locals>.foor   r!   r   assertFalseri   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 | |v S rf   rg   r   r   r   r   r   z  rh   z6TestContains.test_list_contains_singleton.<locals>.foor   r!   )r   r  r  ri   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 ]	}| || qd S )Nc                 S   s,   t t}tddD ]}|| q
| |v S rP   ro   rp   r   r   r   r     rr   z5TestContains.test_list_contains_multiple.<locals>.foorQ   rR   r   )r   r   r  r  r&   r   r   r   test_list_contains_multiple  s   
z(TestContains.test_list_contains_multipleN)r2   r3   r4   r5   r  r  r  r   r   r   r   r  m  
    	
r  c                   @   r   )		TestCountzTest list count. c                 C   s    t dd }| |dd d S )Nc                 S   s   t t}|| S r   )r   r   r   countr   r   r   r   r     s   

z,TestCount.test_list_count_empty.<locals>.foorQ   r   r$   ri   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   r   NrQ   r   r   r   r   r!  r   r   r   r   r     r   z0TestCount.test_list_count_singleton.<locals>.foor!   r   rQ   r$   ri   r   r   r   test_list_count_singleton  r   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$  rp   r   r   r   r     s   

z.TestCount.test_list_count_mutiple.<locals>.foorQ   r   r   r!   r   r"   r   r0   r$   ri   r   r   r   test_list_count_mutiple  s   
z!TestCount.test_list_count_mutipleN)r2   r3   r4   r5   r"  r%  r&  r   r   r   r   r     s
    
r   c                   @       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     rh   z.TestExtend.test_list_extend_empty.<locals>.foo)r!   r!   )r!   r"   r"   r/   r0   r$   ri   r   r   r   test_list_extend_empty  s
   
z!TestExtend.test_list_extend_emptyc                 C   r   )Nc                  S      t t} | d d S Nr!   r   r   r   r)  rF   r   r   r   r     r  zBTestExtend.test_list_extend_typing_error_non_iterable.<locals>.fooz extend argument must be iterabler   rL   r   r   r   *test_list_extend_typing_error_non_iterable  r  z5TestExtend.test_list_extend_typing_error_non_iterableN)r2   r3   r4   r5   r*  r.  r   r   r   r   r(    s    r(  c                   @   @   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   *   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   r   r   r   r   r     s   
z.TestInsert.test_list_insert_empty.<locals>.foo)ry   rw   rE   r   r!   rV   r[   )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   r3  r   r   r   r   r   r     s   

z2TestInsert.test_list_insert_singleton.<locals>.foo)ry   r   r   rE   r   )r"   r!   r   )r!   r"   r0   rQ   )r"   r   r!   r$   r&   r   r   r   test_list_insert_singleton  s   
z%TestInsert.test_list_insert_singletonc                 C   r1  )Nc                 S   s>   t t}tdD ]}|d q	|| d t|||  fS NrQ   r   r!   r   r   r   r   r   r3  r   rp   r   r   r   r     
   
z1TestInsert.test_list_insert_multiple.<locals>.foo)r   rV   r[   r   r!   r$   r&   r   r   r   test_list_insert_multiple  
   
z$TestInsert.test_list_insert_multiplec                 C   r1  )Nc                 S   s>   t t}tdD ]}|d q	|| d t||d fS r6  r7  rp   r   r   r   r     r8  z8TestInsert.test_list_insert_multiple_before.<locals>.foo)ir   ry   r   r9  r$   r&   r   r   r    test_list_insert_multiple_before  r;  z+TestInsert.test_list_insert_multiple_beforec                 C   r1  )Nc                 S   s>   t t}tdD ]}|d q	|| d t||d fS r6  r7  rp   r   r   r   r   	  r8  z7TestInsert.test_list_insert_multiple_after.<locals>.foor   r9  r$   r&   r   r   r   test_list_insert_multiple_after  r;  z*TestInsert.test_list_insert_multiple_afterc                 C   r   )Nc                  S   s   t t} | dd d S )Nar   )r   r   r   r3  rF   r   r   r   r     s   
z5TestInsert.test_list_insert_typing_error.<locals>.fooz$list insert indices must be integersr   rL   r   r   r   test_list_insert_typing_error  r  z(TestInsert.test_list_insert_typing_errorN)
r2   r3   r4   r5   r4  r5  r:  r<  r=  r?  r   r   r   r   r0    s    
r0  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   J   |    tdd }| t |  W d    d S 1 sw   Y  d S )Nc                  S   r+  rf   )r   r   r   removerF   r   r   r   r   *  r  z.TestRemove.test_list_remove_empty.<locals>.foor   r   rG   r   ri   r   r   r   test_list_remove_empty'  s   
"z!TestRemove.test_list_remove_emptyc                 C   r   )Nc                  S   s&   t t} | d | d t| S rf   )r   r   r   r   rB  r   rF   r   r   r   r   3  r
  z2TestRemove.test_list_remove_singleton.<locals>.foor   r$   ri   r   r   r   test_list_remove_singleton2  r   z%TestRemove.test_list_remove_singletonc                 C   rA  )Nc                  S   s"   t t} | d | d d S r2  )r   r   r   r   rB  rF   r   r   r   r   ?     

z>TestRemove.test_list_remove_singleton_value_error.<locals>.foorC  ri   r   r   r   &test_list_remove_singleton_value_error<  s   
"z1TestRemove.test_list_remove_singleton_value_errorc                 C   r   )Nc                  S   s@   t t} tddD ]}| | q
| d | d t| S )NrQ   rR   r   ru   )r   r   r   r   r   rB  r   r   r   r   r   r   I  s   


z1TestRemove.test_list_remove_multiple.<locals>.foorZ   r$   ri   r   r   r   test_list_remove_multipleH     
z$TestRemove.test_list_remove_multiplec                 C   rA  )Nc                  S   s2   t t} tddD ]}| | q
| d d S NrQ   rR      )r   r   r   r   r   rB  r   r   r   r   r   W     
z=TestRemove.test_list_remove_multiple_value_error.<locals>.foorC  ri   r   r   r   %test_list_remove_multiple_value_errorT  s   
"z0TestRemove.test_list_remove_multiple_value_errorN)	r2   r3   r4   r5   rD  rE  rG  rH  rM  r   r   r   r   r@  $  s    
r@  c                   @   r   )		TestClearzTest list clear. c                 C   r   )Nc                  S      t t} |   t| S r   )r   r   r   clearr   rF   r   r   r   r   f     
z,TestClear.test_list_clear_empty.<locals>.foor   r$   ri   r   r   r   test_list_clear_emptye  r   zTestClear.test_list_clear_emptyc                 C   r   )Nc                  S   s$   t t} | d |   t| S rf   )r   r   r   r   rP  r   rF   r   r   r   r   o  r   z0TestClear.test_list_clear_singleton.<locals>.foor   r$   ri   r   r   r   test_list_clear_singletonn  r   z#TestClear.test_list_clear_singletonc                 C   r   )Nc                  S   s2   t t} tdD ]}| d q	|   t| S )NrQ   r   )r   r   r   r   r   rP  r   r   r   r   r   r   y  s
   
z/TestClear.test_list_clear_multiple.<locals>.foor   r$   ri   r   r   r   test_list_clear_multiplex  r   z"TestClear.test_list_clear_multipleN)r2   r3   r4   r5   rR  rS  rT  r   r   r   r   rN  b  r  rN  c                   @   r   )	TestReversezTest list reverse. c                 C   r   )Nc                  S   rO  r   )r   r   r   reverser   rF   r   r   r   r     rQ  z0TestReverse.test_list_reverse_empty.<locals>.foor   r$   ri   r   r   r   test_list_reverse_empty  r   z#TestReverse.test_list_reverse_emptyc                 C   r   )Nc                  S   s,   t t} | d |   t| | d fS rf   )r   r   r   r   rV  r   rF   r   r   r   r     s   

z4TestReverse.test_list_reverse_singleton.<locals>.foo)r!   r   r$   ri   r   r   r   test_list_reverse_singleton  r   z'TestReverse.test_list_reverse_singletonc                 C   r   )Nc                  S   sH   t t} tddD ]}| | q
|   t| | d | d | d fS NrQ   r   r   r!   r"   )r   r   r   r   r   rV  r   r   r   r   r   r     s
   
z3TestReverse.test_list_reverse_multiple.<locals>.foo)r0   r   r   rQ   r$   ri   r   r   r   test_list_reverse_multiple  r   z&TestReverse.test_list_reverse_multipleN)r2   r3   r4   r5   rW  rX  rZ  r   r   r   r   rU    r  rU  c                   @   r   )	TestCopyzTest list copy. c                 C   r   )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$   ri   r   r   r   test_list_copy_empty  r   zTestCopy.test_list_copy_emptyc                 C   r   )Nc                  S   s8   t t} | d |  }t| t|| d |d fS rf   )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$   ri   r   r   r   test_list_copy_singleton  r   z!TestCopy.test_list_copy_singletonc                 C   r   )Nc               	   S   s`   t t} tddD ]}| | q
|  }t| t|| d | d | d | d | d | d fS rY  )r   r   r   r   r   r\  r   r   r   r   r   r     s
   
4z-TestCopy.test_list_copy_multiple.<locals>.foo)r0   r0   rQ   r   r   rQ   r   r   r$   ri   r   r   r   test_list_copy_multiple  r   z TestCopy.test_list_copy_multipleN)r2   r3   r4   r5   r]  r^  r_  r   r   r   r   r[    r  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   r   )Nc                  S   s   t t} | d | dS r,  r   r   r   r   indexrF   r   r   r   r     r   z+TestIndex.test_index_singleton.<locals>.foor   r$   ri   r   r   r   test_index_singleton  r   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 rP   r   r   r   r   r   rb  rp   r   r   r   r     rU   z*TestIndex.test_index_multiple.<locals>.foorQ   rR   r   )r'   r   r   vr   r   r   test_index_multiple  s
   
zTestIndex.test_index_multiplec                 C   r   )Nc                  S   s.   t t} tddD ]}| d q
| dS NrQ   rR   r!   rd  )r   _r   r   r   r     rU   z+TestIndex.test_index_duplicate.<locals>.foor   r$   ri   r   r   r   test_index_duplicate  r   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 rg  rd  )startr   rh  r   r   r   r     r   z6TestIndex.test_index_duplicate_with_start.<locals>.foorQ   rB   r&   r   r   r   test_index_duplicate_with_start  r|   z)TestIndex.test_index_duplicate_with_startc                 C   r   )Nc                  S   s   t t} | d | dS r   ra  rF   r   r   r   r     r   z7TestIndex.test_index_singleton_value_error.<locals>.fooitem not in listr   rL   r   r   r    test_index_singleton_value_error     
z*TestIndex.test_index_singleton_value_errorc                 C   r   )Nc                  S   s.   t t} tddD ]}| | q
| dS rJ  rd  r   r   r   r   r     rU   z6TestIndex.test_index_multiple_value_error.<locals>.foorl  r   rL   r   r   r   test_index_multiple_value_error  r   z)TestIndex.test_index_multiple_value_errorc              	   C   s|   |    tdd }| |dd tddD ]$}| t}|| W d    n1 s-w   Y  | dt|j qd S )Nc                 S   s0   t t}tddD ]}|| q
|d| S rP   rd  )rj  r   rq   r   r   r   r     r   z<TestIndex.test_index_multiple_value_error_start.<locals>.foor   r!   rQ   rl  	r   r   r%   r   rG   r   rI   rJ   rK   r   r   r   r   %test_index_multiple_value_error_start     

z/TestIndex.test_index_multiple_value_error_startc              	   C   s|   |    tdd }| |dd tddD ]$}| t}|| W d    n1 s-w   Y  | dt|j qd S )Nc                 S   s2   t t}tddD ]}|| q
|dd| S )NrQ   rR   ru   r   rd  )endr   rq   r   r   r   r   (  rL  z:TestIndex.test_index_multiple_value_error_end.<locals>.foorQ   r[   r   rl  rp  r   r   r   r   #test_index_multiple_value_error_end%  rr  z-TestIndex.test_index_multiple_value_error_endc                 C   r   )Nc                  S   "   t t} | d | jdddS )Nr   r>  )rj  ra  rF   r   r   r   r   ;  rF  z4TestIndex.test_index_typing_error_start.<locals>.fooz+start argument for index must be an integerr   rL   r   r   r   test_index_typing_error_start8  rn  z'TestIndex.test_index_typing_error_startc                 C   r   )Nc                  S   ru  )Nr   r>  )rs  ra  rF   r   r   r   r   K  rF  z2TestIndex.test_index_typing_error_end.<locals>.fooz)end argument for index must be an integerr   rL   r   r   r   test_index_typing_error_endH  rn  z%TestIndex.test_index_typing_error_endN)r2   r3   r4   rc  rf  ri  rk  rm  ro  rq  rt  rv  rw  r   r   r   r   r`    s    	
r`  c                   @   r/  )TestEqualNotEqualzTest list equal and not equal. c                 C   r   )Nc                  S   s$   t t} t t}| |k| |kfS r   r   r   or   r   r   r   ]  r   z4TestEqualNotEqual.test_list_empty_equal.<locals>.fooTFr$   ri   r   r   r   test_list_empty_equal\  r   z'TestEqualNotEqual.test_list_empty_equalc                 C   r   )Nc                  S   s8   t t} | d t t}|d | |k| |kfS rf   rg   ry  r   r   r   r   f  
   



z8TestEqualNotEqual.test_list_singleton_equal.<locals>.foor{  r$   ri   r   r   r   test_list_singleton_equale  r   z+TestEqualNotEqual.test_list_singleton_equalc                 C   r   )Nc                  S   s8   t t} | d t t}|d | |k| |kfS r   rg   ry  r   r   r   r   q  r}  z<TestEqualNotEqual.test_list_singleton_not_equal.<locals>.fooFTr$   ri   r   r   r   test_list_singleton_not_equalp  r   z/TestEqualNotEqual.test_list_singleton_not_equalc                 C   r   )Nc                  S   s.   t t} | d t t}| |k| |kfS rf   rg   ry  r   r   r   r   |  s   


z8TestEqualNotEqual.test_list_length_mismatch.<locals>.foor  r$   ri   r   r   r   test_list_length_mismatch{  r   z+TestEqualNotEqual.test_list_length_mismatchc                 C   r   )Nc                  S   sF   t t} t t}tdD ]}| | || q| |k| |kfS r#  ro   r   rz  r   r   r   r   r     s   


z7TestEqualNotEqual.test_list_multiple_equal.<locals>.foor{  r$   ri   r   r   r   test_list_multiple_equal  rI  z*TestEqualNotEqual.test_list_multiple_equalc                 C   r   )Nc                  S   sN   t t} t t}tdD ]}| | || qd|d< | |k| |kfS )NrQ   *   rE   ro   r  r   r   r   r     s   


z;TestEqualNotEqual.test_list_multiple_not_equal.<locals>.foor  r$   ri   r   r   r   test_list_multiple_not_equal  s   
	z.TestEqualNotEqual.test_list_multiple_not_equalN)
r2   r3   r4   r5   r|  r~  r  r  r  r  r   r   r   r   rx  Y  s    	
rx  c                   @   r'  )TestIterzTest list iter. c                 C   s(   t dd }d}| ||t| d S )Nc                 S   s.   t t}||  d}|D ]}||7 }q|S rf   r-  )r   r   rrq   r   r   r   r     s   


z$TestIter.test_list_iter.<locals>.foor!   r"   r0   rV   )r   r%   sumr'   r   r   r   r   r   test_list_iter  s   
	zTestIter.test_list_iterc                 C   sh   |    tdd }| t}|  W d    n1 sw   Y  | djdi t t|j d S )Nc                  S   s,   t t} | d | D ]}| | qd S )Nr  )r   r   r   r)  r   rS   r   r   r   r     s
   

z2TestIter.test_list_iter_self_mutation.<locals>.fooz!list was mutated during iterationr   )	r   r   rG   rH   rI   formatlocalsrJ   rK   rL   r   r   r   test_list_iter_self_mutation  s   
z%TestIter.test_list_iter_self_mutationN)r2   r3   r4   r5   r  r  r   r   r   r   r    s    r  c                   @   r6   )TestStringItemz%Test list can take strings as items. c                 C   s*   t dd }| }| g d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"   r0   )r   r   r   unicode_typer   rF   r   r   r   r     s   



z,TestStringItem.test_string_item.<locals>.foo)r>  r  r  r  )r   r%   r,   r  r   r   r   test_string_item  s   
zTestStringItem.test_string_itemN)r2   r3   r4   r5   r  r   r   r   r   r    r:   r  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 rf   )r   r   r   )fromtytotyr   r   r   r   r     s   
zTestItemCasting.fooc                 C   s   t || d S r   )r  r   )r'   r  r  r   r   r   
check_good  s   zTestItemCasting.check_goodc                 C   sZ   |  t}t|| W d    n1 sw   Y  | djdi t t|j d S )Nz%cannot safely cast {fromty} to {toty}r   )	rG   r   r  r   rI   r  r  rJ   rK   )r'   r  r  rM   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   )
r  r   r   float32float64
complex128Zint64r  	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   )r  r   r  r  r  r  r  r   r   r   test_cast_float_to     z"TestItemCasting.test_cast_float_toc                 C   s4   |  tjtj |  tjtj |  tjtj d S r   )r  r   booleanr   r  r  r  r   r   r   test_cast_bool_to  r  z!TestItemCasting.test_cast_bool_toc                 C   R   t dd }| t}|  W d    n1 sw   Y  | dt|j d S )Nc                  S   r+  )Nr   rg   rF   r   r   r   r     r  z7TestItemCasting.test_cast_fail_unicode_int.<locals>.fooz(cannot safely cast unicode_type to int32r   rG   r   rI   rJ   rK   rL   r   r   r   test_cast_fail_unicode_int     
z*TestItemCasting.test_cast_fail_unicode_intc                 C   r  )Nc                  S   s   t tj} | td d S rf   )r   r   r   r  r   r   rF   r   r   r   r     s   z7TestItemCasting.test_cast_fail_int_unicode.<locals>.fooz!Cannot cast int32 to unicode_typer  rL   r   r   r   test_cast_fail_int_unicode	  r  z*TestItemCasting.test_cast_fail_int_unicodeN)r2   r3   r4   r   r   r  r  r  r  r  r  r  r   r   r   r   r    s    
r  c                  C   s   t t} | td | S r,  rg   rF   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   r  )Nc                  S   s   t  } |  S r   )r  _is_mutablerF   r   r   r   r   "  s   z,TestImmutable.test_is_immutable.<locals>.foor  ri   r   r   r   test_is_immutable!  s   
zTestImmutable.test_is_immutablec                 C   r  )Nc                  S   s   t  } |   |  S r   r  _make_immutabler  rF   r   r   r   r   )  s   z;TestImmutable.test_make_immutable_is_immutable.<locals>.foor  ri   r   r   r    test_make_immutable_is_immutable(  s   
z.TestImmutable.test_make_immutable_is_immutablec                 C   0   t dd }| \}}| |d | | d S )Nc                  S   s   t  } |   t| |  fS r   )r  r  r   r  rF   r   r   r   r   1     zATestImmutable.test_length_still_works_when_immutable.<locals>.foor!   r   r%   r  )r'   r   r   mutabler   r   r   &test_length_still_works_when_immutable0  
   

z4TestImmutable.test_length_still_works_when_immutablec                 C   r  )Nc                  S   s   t  } |   | d |  fS rf   r  rF   r   r   r   r   ;  r  zBTestImmutable.test_getitem_still_works_when_immutable.<locals>.foor!   r  )r'   r   Z	test_itemr  r   r   r   'test_getitem_still_works_when_immutable:  r  z5TestImmutable.test_getitem_still_works_when_immutablec                 C   r   )Nc                  S   s    t  } |   | td d S r,  )r  r  r   r   rF   r   r   r   r   G  s   z,TestImmutable.test_append_fails.<locals>.foolist is immutabler   rL   r   r   r   test_append_failsD  r  zTestImmutable.test_append_failsc              	   C   sh   |    dd }dD ]'}||}| t}|  W d   n1 s#w   Y  | 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_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()Nr  )r   rG   r   rI   rJ   rK   )r'   r  r  r   rM   r   r   r   test_mutation_failsS  s   
z!TestImmutable.test_mutation_failsN)	r2   r3   r4   r  r  r  r  r  r  r   r   r   r   r    s    

r  N),r5   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   r7   r;   rO   rc   r   r   r   r  r  r   r(  r0  r@  rN  rU  r[  r`  rx  r  r  r  r  r  r   r   r   r   <module>   sJ     | tx q%#Q>!!" F'A
