
    Gg                     B    d dl mZ d dlZd dlmZ d dlZ G d de      Zy)    )absolute_importN)TestCasec                   t    e Zd Z eed      sddZd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zy)
TestDecodeassertIsNc                 >    | j                  ||u |xs |d|       y )Nz is )
assertTrue)selfexpr1expr2msgs       x/home/kushmeetdev/apache_webroot/langgraph_flaskproject/venv/lib/python3.12/site-packages/dirtyjson/tests/test_decode.pyr   zTestDecode.assertIs
   s    OOEUNC,N3NO    c                     t        j                  dt        j                        }| j	                  t        |t        j                               | j                  |t        j                  d             y )Nz1.1)parse_float)	dirtyjsonloadsdecimalDecimalr	   
isinstanceassertEqualr
   rvals     r   test_decimalzTestDecode.test_decimal   sF    u'//B
49:wu56r   c                     t        j                  dt              }| j                  t	        |t                     | j                  |d       y )N1)	parse_intg      ?)r   r   floatr	   r   r   r   s     r   
test_floatzTestDecode.test_float   s5    se4
4/0s#r   c                 X    t        j                  d      }| j                  |ddd       y )Nz,{   "key"    :    "value"    ,  "k":"v"    }valuevkeykr   r   r   r   s     r   test_decoder_optimizationsz%TestDecode.test_decoder_optimizations   s&    MNwS9:r   c                 $   d}| j                  t        j                  |      t        |             d}| j                  t        j                  |      t        |             d}| j                  t        j                  |      t        |             y )Nz{}z[]"")r   r   r   evalr
   ss     r   test_empty_objectszTestDecode.test_empty_objects   sh    +T!W5+T!W5+T!W5r   c                      ||      }t        |d         t        |d         c\  }}\  }}| j                  ||       | j                  ||       y )Nr      )sortedr   )r
   sourcer   r   abcds           r   check_keys_reusezTestDecode.check_keys_reuse#   sJ    V}Q&a/AAaar   c                 f    dj                  d      }| j                  |t        j                         y )N2   [{"a_key": 1, "b_é": 2}, {"a_key": 3, "b_é": 4}]utf8)encoder6   r   r   r+   s     r   test_keys_reuse_strzTestDecode.test_keys_reuse_str)   s&    ELLVTa1r   c                 H    d}| j                  |t        j                         y )Nr8   )r6   r   r   r+   s     r   test_keys_reuse_unicodez"TestDecode.test_keys_reuse_unicode-   s    Ea1r   c                 0   | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      dg       | j                  t        j                  d      dg       y )Nr)    z[""]r   r   r   r
   s    r   test_empty_stringszTestDecode.test_empty_strings1   j    .3/502$71C59r   c                 0   | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      dg       | j                  t        j                  d      dg       y )Nz''r?   z['']r@   rA   s    r   %test_empty_strings_with_single_quotesz0TestDecode.test_empty_strings_with_single_quotes7   rC   r   c                 F   ddd}t        j                  d      }| j                  ||       t        j                  d      }| j                  ||       t        j                  d      }| j                  ||       t        j                  d      }| j                  ||       y )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_keyszTestDecode.test_object_keys=   s     s+?@v&?@v&;<v&<=v&r   c                 D   d}|j                  d      }t        j                  ||      }| j                  |ddg dd       t        j                  ||dz   d	      }| j                  |g d       t        j                  |d
      }| j                  |ddg dd       y )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_indexr/      r/         testaackbarT)rK   search_for_first_object)rT   )indexr   r   r   )r
   r,   first_object_indexr   s       r   test_not_at_beginningz TestDecode.test_not_at_beginningH   s     WWS\q.@A4	JKq.@1.D^bcy)q$?4	JKr   c           
      l    d}t        j                  |      }| j                  |ddg dddd dd       y )	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);
r/   rL   rM   TF)oncetwicethree_times3)rQ   rR   rS   morer&   r
   r,   r   s      r    test_ignore_single_line_commentsz+TestDecode.test_ignore_single_line_comments[   sJ    & q!4	\`kp  CG  TH   I  	Jr   c                 b    d}t        j                  |      }| j                  |ddg dd       y )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);
r/   rL   rM   rP   r&   r]   s      r   test_ignore_inline_commentsz&TestDecode.test_ignore_inline_commentsr   s0    * q!4	JKr   )N)__name__
__module____qualname__hasattrr   r   r   r   r'   r-   r6   r;   r=   rB   rE   rH   rW   r^   r`    r   r   r   r      sV    8Z(	P7
$
;622::	'L&J.Lr   r   )
__future__r   r   unittestr   r   r   re   r   r   <module>rh      s!    &   AL ALr   