o
    tVg\$                     @   sn   d dl Z d dlZdZdZdd ZG dd de jZG dd	 d	e jZG d
d de jZ	e
dkr5e   dS dS )    N)kUNKNOWN	BACKSPACETABCLEARRETURNPAUSEESCAPESPACECOMMAMINUSPERIODSLASH0123456789	SEMICOLONEQUALSLEFTBRACKET	BACKSLASHRIGHTBRACKETDELETEKP0KP1KP2KP3KP4KP5KP6KP7KP8KP9	KP_PERIOD	KP_DIVIDEKP_MULTIPLYKP_MINUSKP_PLUSKP_ENTER	KP_EQUALSUPDOWNRIGHTLEFTINSERTHOMEENDPAGEUPPAGEDOWNF1F2F3F4F5F6F7F8F9F10F11F12F13F14F15NUMLOCKCAPSLOCK	SCROLLOCKRSHIFTLSHIFTRCTRLLCTRLRALTLALTRMETALMETALSUPERRSUPERMODEHELPPRINTSYSREQBREAKMENUPOWEREUROKP_0KP_1KP_2KP_3KP_4KP_5KP_6KP_7KP_8KP_9NUMLOCKCLEAR
SCROLLLOCKRGUILGUIPRINTSCREENCURRENCYUNITCURRENCYSUBUNIT))r   r\   )r   r]   )r    r^   )r!   r_   )r"   r`   )r#   ra   )r$   rb   )r%   rc   )r&   rd   )r'   re   )rG   rf   )rI   rg   )rR   rQ   ri   )rS   rP   rh   )rV   rj   )rX   r   )r[   rk   c                 C   s`   i }| D ]}t tj|}||t | qt }| D ]}t|dkr-|t| q|S )zHelper function to find overlapping constant values/names.

    Returns a set of fronzensets:
        set(frozenset(names of overlapping constants), ...)
       )	getattrpygame	constants
setdefaultsetaddvalueslen	frozenset)constant_namesoverlap_dictnamevalueoverlapsoverlap_names r}   O/home/ubuntu/.local/lib/python3.10/site-packages/pygame/tests/constants_test.pycreate_overlap_set   s   r   c                   @   B   e Zd ZdZdZedd ee D Zdd Zdd Z	d	d
 Z
dS )KConstantsTestszTest K_* (key) constants.)-abcdefghijklmnopqrstuvwxyzQUOTE	BACKQUOTEEXCLAIMQUOTEDBLHASHDOLLAR	AMPERSAND	LEFTPAREN
RIGHTPARENASTERISKPLUSCOLONLESSGREATERQUESTIONATCARET
UNDERSCOREPERCENTc                 c       | ]}d | V  qdS K_Nr}   .0r   r}   r}   r~   	<genexpr>       zKConstantsTests.<genexpr>c                 C   *   | j D ]}| ttj|d|  qdS )zEnsures K constants exist.missing constant N)K_NAMES
assertTruehasattrro   rp   selfry   r}   r}   r~   test_k__existence      
z!KConstantsTests.test_k__existencec                 C   ,   | j D ]}ttj|}| t|t qdS )z)Ensures K constants are the correct type.N)r   rn   ro   rp   assertIstypeintr   ry   rz   r}   r}   r~   test_k__type      
zKConstantsTests.test_k__typec                 C   (   dd t D }t| j}| || dS )z0Ensures no unexpected K constant values overlap.c                 S      h | ]}t d d |D qS )c                 s   r   r   r}   r   r}   r}   r~   r      r   zBKConstantsTests.test_k__value_overlap.<locals>.<setcomp>.<genexpr>rv   r   itemr}   r}   r~   	<setcomp>   s    z8KConstantsTests.test_k__value_overlap.<locals>.<setcomp>N)K_AND_KSCAN_COMMON_OVERLAPSr   r   assertSetEqualr   EXPECTED_OVERLAPSr{   r}   r}   r~   test_k__value_overlap   s
   
z%KConstantsTests.test_k__value_overlapN)__name__
__module____qualname____doc__K_SPECIFIC_NAMEStupleK_AND_KSCAN_COMMON_NAMESr   r   r   r   r}   r}   r}   r~   r      s    1r   c                   @   r   )KscanConstantsTestsz"Test KSCAN_* (scancode) constants.)0ABCDEFGHIJKLMNOPQRSTUVWXYZ
APOSTROPHEGRAVEINTERNATIONAL1INTERNATIONAL2INTERNATIONAL3INTERNATIONAL4INTERNATIONAL5INTERNATIONAL6INTERNATIONAL7INTERNATIONAL8INTERNATIONAL9LANG1LANG2LANG3LANG4LANG5LANG6LANG7LANG8LANG9NONUSBACKSLASH	NONUSHASHc                 c   r   KSCAN_Nr}   r   r}   r}   r~   r   '  s    
zKscanConstantsTests.<genexpr>c                 C   r   )zEnsures KSCAN constants exist.r   N)KSCAN_NAMESr   r   ro   rp   r   r}   r}   r~   test_kscan__existence+  r   z)KscanConstantsTests.test_kscan__existencec                 C   r   )z-Ensures KSCAN constants are the correct type.N)r  rn   ro   rp   r   r   r   r   r}   r}   r~   test_kscan__type0  r   z$KscanConstantsTests.test_kscan__typec                 C   r   )z4Ensures no unexpected KSCAN constant values overlap.c                 S   r   )c                 s   r   r	  r}   r   r}   r}   r~   r   :  r   zJKscanConstantsTests.test_kscan__value_overlap.<locals>.<setcomp>.<genexpr>r   r   r}   r}   r~   r   9  s    z@KscanConstantsTests.test_kscan__value_overlap.<locals>.<setcomp>N)r   r   r  r   r   r}   r}   r~   test_kscan__value_overlap7  s
   
z-KscanConstantsTests.test_kscan__value_overlapN)r   r   r   r   KSCAN_SPECIFIC_NAMESr   r   r  r  r  r  r}   r}   r}   r~   r      s    4r   c                   @   s<   e Zd ZdZdZdd Zdd Zdd Zd	d
 Zdd Z	dS )KmodConstantsTestsz%Test KMOD_* (key modifier) constants.)	KMOD_NONEKMOD_LSHIFTKMOD_RSHIFT
KMOD_SHIFT
KMOD_LCTRL
KMOD_RCTRL	KMOD_CTRL	KMOD_LALT	KMOD_RALTKMOD_ALT
KMOD_LMETA
KMOD_RMETA	KMOD_METAKMOD_NUM	KMOD_CAPS	KMOD_MODE	KMOD_LGUI	KMOD_RGUIKMOD_GUIc                 C   r   )zEnsures KMOD constants exist.r   N)KMOD_CONSTANTSr   r   ro   rp   r   r}   r}   r~   test_kmod__existence]  r   z'KmodConstantsTests.test_kmod__existencec                 C   r   )z,Ensures KMOD constants are the correct type.N)r$  rn   ro   rp   r   r   r   r   r}   r}   r~   test_kmod__typeb  r   z"KmodConstantsTests.test_kmod__typec                 C   s<   t ddgt ddgt ddgh}t| j}| || dS )z3Ensures no unexpected KMOD constant values overlap.r!  r  r"  r  r#  r  N)rv   r   r$  r   r   r}   r}   r~   test_kmod__value_overlapi  s   



z+KmodConstantsTests.test_kmod__value_overlapc                 C   s8   d}d}|D ]}t tj|}| ||@  ||O }qdS )z8Ensures certain KMOD constants have no overlapping bits.)r  r  r  r  r  r  r  r  r  r  r  r   r   N)rn   ro   rp   assertFalse)r   NO_BITWISE_OVERLAPkmodsry   rz   r}   r}   r~   test_kmod__no_bitwise_overlapv  s   
z0KmodConstantsTests.test_kmod__no_bitwise_overlapc                 C   s\   dddddd}|  D ]\}}d}|D ]
}|ttj|O }qttj|}| || qdS )	z5Ensures certain KMOD constants have overlapping bits.)r  r  )r  r  )r  r  )r  r  )r!  r"  )r  r  r  r  r#  r   N)itemsrn   ro   rp   assertEqual)r   KMOD_COMPRISED_DICT	base_name	seq_namesexpected_valuery   rz   r}   r}   r~   test_kmod__bitwise_overlap  s   z-KmodConstantsTests.test_kmod__bitwise_overlapN)
r   r   r   r   r$  r%  r&  r'  r+  r2  r}   r}   r}   r~   r  C  s    r  __main__)unittestpygame.constantsro   r   r   r   TestCaser   r   r  r   mainr}   r}   r}   r~   <module>   s    oNTf