
    i                     B    S SK Jr  S SKrS SKJr  S SKr " S S\5      rg)    )absolute_importN)TestCasec                       \ rS rSr\" \S5      (       d  SS jrS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rSrg)
TestDecode   assertIsNc                 J    U R                  XL U=(       d	    U< SU< 35        g )Nz is )
assertTrue)selfexpr1expr2msgs       U/home/james-whalen/.local/lib/python3.13/site-packages/dirtyjson/tests/test_decode.pyr   TestDecode.assertIs
   s    OOENC,N3NO    c                     [         R                  " S[        R                  S9nU R	                  [        U[        R                  5      5        U R                  U[        R                  " S5      5        g )Nz1.1)parse_float)	dirtyjsonloadsdecimalDecimalr
   
isinstanceassertEqualr   rvals     r   test_decimalTestDecode.test_decimal   sF    u'//B
49:wu56r   c                     [         R                  " S[        S9nU R                  [	        U[        5      5        U R                  US5        g )N1)	parse_intg      ?)r   r   floatr
   r   r   r   s     r   
test_floatTestDecode.test_float   s5    se4
4/0s#r   c                 Z    [         R                  " S5      nU R                  USSS.5        g )Nz,{   "key"    :    "value"    ,  "k":"v"    }valuevkeykr   r   r   r   s     r   test_decoder_optimizations%TestDecode.test_decoder_optimizations   s&    MNwS9:r   c                 *   SnU R                  [        R                  " U5      [        U5      5        SnU R                  [        R                  " U5      [        U5      5        SnU R                  [        R                  " U5      [        U5      5        g )Nz{}z[]"")r   r   r   evalr   ss     r   test_empty_objectsTestDecode.test_empty_objects   sh    +T!W5+T!W5+T!W5r   c                     U" U5      n[        US   5      [        US   5      su  pEu  pgU R                  XF5        U R                  XW5        g )Nr      )sortedr   )r   sourcer   r   abcds           r   check_keys_reuseTestDecode.check_keys_reuse#   sB    V}Q&a/aar   c                 f    SR                  S5      nU R                  U[        R                  5        g )N2   [{"a_key": 1, "b_é": 2}, {"a_key": 3, "b_é": 4}]utf8)encoder<   r   r   r0   s     r   test_keys_reuse_strTestDecode.test_keys_reuse_str)   s&    ELLVTa1r   c                 H    SnU R                  U[        R                  5        g )Nr?   )r<   r   r   r0   s     r   test_keys_reuse_unicode"TestDecode.test_keys_reuse_unicode-   s    Ea1r   c                 8   U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S/5        U R                  [        R                  " S5      S/5        g )Nr.    z[""]r   r   r   r   s    r   test_empty_stringsTestDecode.test_empty_strings1   j    .3/502$71C59r   c                 8   U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S5        U R                  [        R                  " S5      S/5        U R                  [        R                  " S5      S/5        g )Nz''rH   z['']rI   rJ   s    r   %test_empty_strings_with_single_quotes0TestDecode.test_empty_strings_with_single_quotes7   rM   r   c                 F   SSS.n[         R                  " S5      nU R                  X!5        [         R                  " S5      nU R                  X!5        [         R                  " S5      nU R                  X!5        [         R                  " S5      nU R                  X!5        g )Nr%   r&   r'   z{"key": "value", "k": "v"}z{'key': 'value', 'k': 'v'}z{key: 'value', k: 'v'}z{key: 'value', k: 'v',}r*   )r   resultr   s      r   test_object_keysTestDecode.test_object_keys=   s     s+?@&?@&;<&<=&r   c                 4   SnUR                  S5      n[        R                  " XS9nU R                  USS/ SQS.5        [        R                  " XS-   SS	9nU R                  U/ SQ5        [        R                  " USS
9nU R                  USS/ SQS.5        g )Nz
// here are some comments
var a = 1; // here is a line of regular JS

var b = {test: 1, 'aack': 0x80, "bar": [1, 2, 3]};
console.log(b);
{)start_indexr5      r5         testaackbarT)rW   search_for_first_object)r`   )indexr   r   r   )r   r1   first_object_indexr   s       r   test_not_at_beginning TestDecode.test_not_at_beginningH   s     WWS\qA4	JKq1.D^bcy)q$?4	JKr   c           
      n    Sn[         R                  " U5      nU R                  USS/ SQSSS S.S.5        g )	Nan  
// here are some comments
{
    // comments inside too
    test: 1,    // and at the end of lines
    'aack': 0x80,
    "bar": [ // even inside arrays
        1,
        2,
        3, // and after trailing commas
    ],
    more: { // and inside objects
        once: true,
        twice: false,
        three_times3: null // and at the end
    }
}
console.log(b);
r5   rX   rY   TF)oncetwicethree_times3)r]   r^   r_   morer*   r   r1   r   s      r    test_ignore_single_line_comments+TestDecode.test_ignore_single_line_comments[   sJ    & q!4	\`kp  CG  TH   I  	Jr   c                 d    Sn[         R                  " U5      nU R                  USS/ SQS.5        g )Na  
/* here are some comments
 * that should all be skipped
 * right up until the terminator */ {
    /* comments inside too */
    test: 1,    /* and at the end of lines */
    'aack': 0x80,
    "bar": [ // even inside arrays
        1,
        2,
        3, // and after trailing commas
    ],
    /* comment this block out
    more: { // and inside objects
        once: true,
        twice: false,
        three_times3: null // and at the end
    } */
}
console.log(b);
r5   rX   rY   r\   r*   rj   s      r   test_ignore_inline_comments&TestDecode.test_ignore_inline_commentsr   s0    * q!4	JKr    )N)__name__
__module____qualname____firstlineno__hasattrr   r   r   r"   r+   r2   r<   rB   rE   rK   rO   rS   rc   rk   rn   __static_attributes__rp   r   r   r   r      sY    8Z((	P7
$
;622::	'L&J.Lr   r   )
__future__r   r   unittestr   r   r   rp   r   r   <module>ry      s!    &   AL ALr   