o
    8ήcC                     @   sx   d dl mZ d dlmZ d dlZd dlmZmZ dd Zdd Z	G d	d
 d
eZ
G dd deZedkr:e  dS dS )    )njit)TypingErrorN)TestCaseforce_pyobj_flagsc                   C   s
   dddS )N      )r       r	   r	   r	   =/tmp/pip-target-vg8gfxp4/lib/python/numba/tests/test_dicts.py	build_map   s   
r   c                  C   s   t } d| | diS )Nr   r   )r   )xr	   r	   r
   build_map_from_local_vars
   s   r   c                   @   s$   e Zd ZefddZefddZdS )DictTestCasec                 C      | j t|d d S N)flags)run_nullary_funcr   selfr   r	   r	   r
   test_build_map      zDictTestCase.test_build_mapc                 C   r   r   )r   r   r   r	   r	   r
   test_build_map_from_local_vars   r   z+DictTestCase.test_build_map_from_local_varsN)__name__
__module____qualname__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d Zdd Zdd Zdd ZdS )TestCompiledDictzSTesting `dict()` and `{}` usage that are redirected to
    `numba.typed.Dict`.
    c                 C   &   t dd }| }| |ddi d S )Nc                  S   s   t  } d| d< | S Nr   r   dictdr	   r	   r
   foo   s   z+TestCompiledDict.test_use_dict.<locals>.foor   r   r   assertEqualr   r"   r!   r	   r	   r
   test_use_dict      
zTestCompiledDict.test_use_dictc                 C   s^   ddl m} tdd }| t}|  W d    n1 sw   Y  | |t|j d S )Nr   )_message_dict_supportc                  S   s   t  } d| d< t | S r   r   r    r	   r	   r
   r"   ,   s   z9TestCompiledDict.test_unsupported_dict_usage.<locals>.foo)numba.core.typing.dictdeclr(   r   assertRaisesr   assertInstr	exception)r   r(   r"   raisesr	   r	   r
   test_unsupported_dict_usage(   s   
z,TestCompiledDict.test_unsupported_dict_usagec                 C   r   )Nc                  S   s   i } d| d< | S r   r	   r    r	   r	   r
   r"   9   s   z2TestCompiledDict.test_use_curlybraces.<locals>.foor   r   r#   r%   r	   r	   r
   test_use_curlybraces7   r'   z%TestCompiledDict.test_use_curlybracesc                 C   r   )Nc                   S   s   ddiS )Nr   r   r	   r	   r	   r	   r
   r"   E   s   z=TestCompiledDict.test_use_curlybraces_with_init1.<locals>.foor   r   r#   r%   r	   r	   r
   test_use_curlybraces_with_init1C   s   
z0TestCompiledDict.test_use_curlybraces_with_init1c                 C   s*   t dd }| }| |dddd d S )Nc                   S      ddddS )N皙@皙@ffffff@r   r      r	   r	   r	   r	   r
   r"   N      z@TestCompiledDict.test_use_curlybraces_with_initmany.<locals>.foor3   r4   r5   r6   r#   r%   r	   r	   r
   "test_use_curlybraces_with_initmanyL   s   
z3TestCompiledDict.test_use_curlybraces_with_initmanyc                 C   "   t dd }| | |  d S )Nc                   S   r2   )Nr3         r6   r	   r	   r	   r	   r
   r"   W   r8   zATestCompiledDict.test_curlybraces_init_with_coercion.<locals>.foor   r$   py_funcr   r"   r	   r	   r
   #test_curlybraces_init_with_coercionU   s   
z4TestCompiledDict.test_curlybraces_init_with_coercionc                 C   s2   t dd }d\}}| |||||| d S )Nc                 S   s   | d|| | iS Nr   r	   )r   yr	   r	   r
   r"   _   s   z?TestCompiledDict.test_use_curlybraces_with_manyvar.<locals>.foo)
      r=   )r   r"   r   rB   r	   r	   r
   !test_use_curlybraces_with_manyvar]   s   
z2TestCompiledDict.test_use_curlybraces_with_manyvarc                 C   r:   )Nc                  S   s"   t  } ddi| d< ddi| d< | S )Nr   r   r;   r   r   kr	   r	   r
   r"   h   s   z=TestCompiledDict.test_mixed_curlybraces_and_dict.<locals>.foor=   r?   r	   r	   r
   test_mixed_curlybraces_and_dictf   s   
z0TestCompiledDict.test_mixed_curlybraces_and_dictc                 C   R   t dd }| t}|  W d    n1 sw   Y  | dt|j d S )Nc                  S   s   dd i} | S rA   r	   rF   r	   r	   r
   r"   s      z;TestCompiledDict.test_dict_use_with_none_value.<locals>.fooz&Dict.value_type cannot be of type noner   r*   r   r+   r,   r-   r   r"   r.   r	   r	   r
   test_dict_use_with_none_valueq      
z.TestCompiledDict.test_dict_use_with_none_valuec                 C   T   t dd }| t}|d W d    n1 sw   Y  | dt|j d S )Nc                 S   s   | rdnd }d|i}|S Ng      @r   r	   )choiceoptionalrG   r	   r	   r
   r"      s   z?TestCompiledDict.test_dict_use_with_optional_value.<locals>.fooTz7Dict.value_type cannot be of type OptionalType(float64)rK   rL   r	   r	   r
   !test_dict_use_with_optional_value   s   

z2TestCompiledDict.test_dict_use_with_optional_valuec                 C   rO   )Nc                 S   s   | rdnd di}|S rP   r	   )rQ   rG   r	   r	   r
   r"      s   z=TestCompiledDict.test_dict_use_with_optional_key.<locals>.fooTz5Dict.key_type cannot be of type OptionalType(float64)rK   rL   r	   r	   r
   test_dict_use_with_optional_key   s   

z0TestCompiledDict.test_dict_use_with_optional_keyc                 C   rI   )Nc                  S   s   d di} | S rA   r	   rF   r	   r	   r
   r"      rJ   z9TestCompiledDict.test_dict_use_with_none_key.<locals>.fooz$Dict.key_type cannot be of type nonerK   rL   r	   r	   r
   test_dict_use_with_none_key   rN   z,TestCompiledDict.test_dict_use_with_none_keyN)r   r   r   __doc__r&   r/   r0   r1   r9   r@   rE   rH   rM   rS   rT   rU   r	   r	   r	   r
   r      s    			r   __main__)numbar   numba.core.errorsr   unittestnumba.tests.supportr   r   r   r   r   r   r   mainr	   r	   r	   r
   <module>   s    	 