@@ -154,6 +154,45 @@ describe("parse()", () => {
154
154
} ) . to . throw ( "Unexpected token Number found." ) ;
155
155
} ) ;
156
156
157
+ it ( "should throw an error when 123 is used as a property key" , ( ) => {
158
+ const text = "{ 123: 1 }" ;
159
+
160
+ expect ( ( ) => {
161
+ parse ( text , { mode : "json5" } ) ;
162
+ } ) . to . throw ( "Unexpected token Number found." ) ;
163
+ } ) ;
164
+
165
+ it ( "should throw an error when +NaN is used as a property key" , ( ) => {
166
+ const text = "{ +NaN: 1 }" ;
167
+
168
+ expect ( ( ) => {
169
+ parse ( text , { mode : "json5" } ) ;
170
+ } ) . to . throw ( "Unexpected token Number found." ) ;
171
+ } ) ;
172
+
173
+ it ( "should throw an error when -NaN is used as a property key" , ( ) => {
174
+ const text = "{ -NaN: 1 }" ;
175
+
176
+ expect ( ( ) => {
177
+ parse ( text , { mode : "json5" } ) ;
178
+ } ) . to . throw ( "Unexpected token Number found." ) ;
179
+ } ) ;
180
+
181
+ it ( "should throw an error when +Infinity is used as a property key" , ( ) => {
182
+ const text = "{ +Infinity: 1 }" ;
183
+
184
+ expect ( ( ) => {
185
+ parse ( text , { mode : "json5" } ) ;
186
+ } ) . to . throw ( "Unexpected token Number found." ) ;
187
+ } ) ;
188
+
189
+ it ( "should throw an error when -Infinity is used as a property key" , ( ) => {
190
+ const text = "{ -Infinity: 1 }" ;
191
+
192
+ expect ( ( ) => {
193
+ parse ( text , { mode : "json5" } ) ;
194
+ } ) . to . throw ( "Unexpected token Number found." ) ;
195
+ } ) ;
157
196
158
197
} ) ;
159
198
} ) ;
0 commit comments