o
    TÃi8  ã                   @   s8   d dl Z d dlmZ d dlZg d¢ZG dd„ deƒZdS )é    N)ÚTestCase) z["Unclosed array"z["double extra comma",,]z[   , "<-- missing value"]z["Comma after the close"],z["Extra close"]]z:{"Extra value after close": true} "misplaced quoted value"z{"Illegal expression": 1 + 2}z{"Illegal invocation": alert()}z+{"Numbers cannot have leading zeroes": 013}z{"Numbers cannot be hex": 0x14}z"["Illegal backslash escape: \x15"]z[\naked]z"["Illegal backslash escape: \017"]z{"Missing colon" null}z{"Double colon":: null}z {"Comma instead of colon", null}z!["Colon instead of comma": false]z["Bad value", truth]z["	tab	character	in	string	"]z&["tab\   character\   in\  string\  "]z["line
break"]z["line\
break"]z[0e]z[0e+]z[0e+-1]z({"Comma instead if closing brace": true,z["mismatch"}z$["AZ control characters in string"]Ú{z{]z{"foo": "bar"]z{"foo": "bar"c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚTestFailc              	   C   sT   t tƒD ]#\}}|d }zt |¡ W n
 tjy   Y qw |  d||f ¡ qd S )Né   z$Expected failure for fail%d.json: %r)Ú	enumerateÚJSONDOCSÚjsonÚloadsÚHjsonDecodeErrorÚfail)ÚselfÚidxÚdoc© r   úI/home/ubuntu/.local/lib/python3.10/site-packages/hjson/tests/test_fail.pyÚtest_failuresT   s   ÿùzTestFail.test_failuresc              	   C   sj   dD ]0}zt  |¡ W n! t jy   Y q ty,   t ¡ d }|  d||f ¡ Y qw |  d¡ qd S )N)ú[,]r   r   ú!Unexpected exception raised %r %sz Unexpected success parsing '[,]')r   r	   r
   Ú	ExceptionÚsysÚexc_infor   )r   r   Úer   r   r   Útest_array_decoder_issue46^   s   þ÷z#TestFail.test_array_decoder_issue46c                 C   sÎ   g d¢}|D ]^\}}}zt  |¡ W nI t jyD   t ¡ d }|  |jd t|ƒ… |d|j||f ¡ |  |j|d|j||f ¡ Y q t	y[   t ¡ d }|  
d||f ¡ Y qw |  
d|f ¡ qd S )N))ú[z#End of input while parsing an arrayr   )z[42,úExpecting valueé   )z["úUnterminated string starting atr   )z["spamr   r   )z["spam",r   é   )r   úBad key name (eof)r   )z{"r   r   )z{"spamr   r   )z{"spam"zExpecting ':' delimiteré   )z{"spam":r   r   )z{"spam":42,r   é   )ú"r   r   )z"spamr   r   )z[,zFound a punctuator characterr   r   z%r doesn't start with %r for %rzpos %r != %r for %rr   zUnexpected success parsing '%r')r   r	   r
   r   r   ÚassertEqualÚmsgÚlenÚposr   r   )r   Ú
test_casesÚdatar#   r   r   r   r   r   Útest_truncated_inputk   s*   ýþþðzTestFail.test_truncated_inputN)Ú__name__Ú
__module__Ú__qualname__r   r   r(   r   r   r   r   r   S   s    
r   )r   Úunittestr   Úhjsonr   r   r   r   r   r   r   Ú<module>   s
    L