summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/read-package-json/node_modules/json-parse-helpfulerror/node_modules/jju/test/portable-json5-tests.yaml
blob: 5bf6ac38fe13bf739ea5e256c27fb94cc103f894 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
# vi:set ts=2 sts=2 sw=2 et:
#
# Copyright (c) JD 2456730 Alex Kocharin <alex@kocharin.ru>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# The original file is available here:
# https://github.com/rlidwka/jju/tree/master/test/portable-json5-tests.yaml
#
# ----------------------------------------------------------------------------
#
# Portable JSON5 test suite.
#
# This file contains an actual YAML data and it may include fancy syntax.
# If your platform does not support YAML, you might wish to pre-process it
# using a generic YAML parser.
#

%YAML 1.2
---
#
# "input" is an arbitrary JSON5 you have to parse
# "output" is a normalized JSON you have to compare your result with,
#          or !error (null) if your input should result in parser error
#
# Types of tests:
#
#  - basic    - Tests that every JSON5 parser should pass.
#
#  - advanced - Tests that bring close compatibility with javascript. Not
#               strictly required, but nice to have for completeness.
#
#  - extra    - Extra test cases you can follow at your discretion.
#
# Questionable features like elisions go to extra. All valid javascript, but
# invalid json5 also goes to extra. Feel free to ignore this section if you
# want to. Thus, eval(input) is a complete json5 parser, that should pass all
# basic and advanced tests.
#

# Basic types in minimal form
# ---------------------------

type-no-data:
  type: extra
  output: !error
  input: ''

type-null:
  type: basic
  output: null
  input: >
    null

# undefined is not supported,
# null should be used instead
type-no-undefined:
  type: extra
  output: !error
  input: >
    undefined

type-no-raw:
  type: extra
  output: !error
  input: >
    foobar

type-bool-true:
  type: basic
  output: true
  input: >
    true

type-bool-false:
  type: basic
  output: false
  input: >
    false

type-number:
  type: basic
  output: 0
  input: >
    0

type-string:
  type: basic
  output: ""
  input: >
    ""

type-object:
  type: basic
  output: {}
  input: >
    {}

type-array:
  type: basic
  output: []
  input: >
    []

# Numbers: special
# ----------------

# note: it's hard to test this
# just add `1/x < 0` check in your code somewhere
num-negative-zero:
  type: extra
  output: -0.0
  input: >
    -0

num-nan:
  type: basic
  output: .nan
  input: >
    NaN

num-signed-nan:
  type: basic
  output: .nan
  input: >
    +NaN

num-positive-inf:
  type: basic
  output: +.inf
  input: >
    Infinity

num-negative-inf:
  type: basic
  output: -.inf
  input: >
    -Infinity

num-inf-exact-case:
  type: extra
  output: !error
  input: >
    INFINITY

# Numbers: hexadecimal
# --------------------

num-hex-zero:
  type: basic
  output: 0
  input: >
    0x0

num-cut-hex:
  type: basic
  output: !error
  input: >
    0x

num-all-hex:
  type: basic
  output: 12841684683518
  input: >
    0xBADF00DCAFE

num-mixed-case:
  type: basic
  output: 3735928559
  input: >
    0xDeAdBEef

num-signed-hex:
  type: advanced
  output: 31
  input: >
    +0x1F

num-negative-hex:
  type: advanced
  output: -31
  input: >
    -0x1f

num-bad-hex:
  type: advanced
  output: !error
  input: >
    0xBADxF00D

num-no-hex-float:
  type: advanced
  output: !error
  input: >
    0x12.345

# this is not actually an exponent :)
num-hex-exponent:
  type: advanced
  output: 4836
  input: >
    0x0012e4

# Numbers: octal
# --------------

# Octals are primarily used in config files
# to set up a file mask (like 0777)
#
# Note: they will have 0o12345 syntax instead
# of 012345 in the ES6, so we'll need to switch
# as well in the future

num-octal:
  type: extra
  output: 342391
  input: >
    01234567

num-octal-zeroes:
  type: extra
  output: -24000
  input: >
    -000000056700

num-bad-octal:
  type: extra
  output: !error
  input: >
    012345678

num-no-octal-float:
  type: extra
  output: !error
  input: >
    012.345

num-no-octal-exp:
  type: extra
  output: !error
  input: >
    0123e4

# Numbers: floating point
# -----------------------

num-float:
  type: basic
  output: 123.456
  input: >
    123.456

num-signed-foat:
  type: basic
  output: -0.00098765
  input: >
    -0.00098765

num-omit-trailing-mantissa:
  type: basic
  output: 1234000
  input: >
    1234.e3

num-omit-leading-mantissa:
  type: advanced
  output: -123.4
  input: >
    -.1234e3

num-bad-float:
  type: advanced
  output: !error
  input: >
    0.12.345

num-bad-sum:
  type: extra
  output: !error
  input: >
    0.12+345

num-uc-exp:
  type: advanced
  output: -1230000
  input: >
    -123E+4

num-float-exp:
  type: basic
  output: 123000
  input: >
    0.0123e7

num-bad-exp:
  type: extra
  output: !error
  input: >
    123e7.3

num-bad-char:
  type: extra
  output: !error
  input: >
    123a456

num-no-exp:
  type: advanced
  output: !error
  input: >
    123e

num-zero-exp:
  type: advanced
  output: -0.0
  input: >
    -.00e-0

num-dec-base-signed-exp:
  type: advanced
  output: 0.00000123
  input: >
    1230000E-012

# String: quotes
# --------------

string-double-quotes:
  type: basic
  output: foobar
  input: >
    "foobar"

string-single-quotes:
  type: basic
  output: foobar
  input: >
    'foobar'

string-open:
  type: basic
  output: !error
  input: >
    "\\\\\\\\\\\\\"

string-not-open:
  type: basic
  output: "\\\\\\\\\\\\\\"
  input: >
    "\\\\\\\\\\\\\\"

string-continuation:
  type: advanced
  output: "  foo    bar   "
  input: >
    "  foo \
       bar \
      "

string-win-continuation:
  type: advanced
  output: "foobar"
  input: "'foo\\\r\nbar'"

string-win-reverse-continuation:
  type: advanced
  output: !error
  input: "'foo\\\n\rbar'"

string-unicode-continuation:
  type: advanced
  output: "foobarbaz"
  input: "'foo\\\u2028bar\\\u2029baz'"

string-multi-bad-continuation:
  type: advanced
  output: !error
  input: >
    foo\

    bar

string-bad-ending:
  type: basic
  output: !error
  input: "'foo\rbar'"

string-bad-ending-2028:
  type: advanced
  output: !error
  input: "'foo\u2028bar'"

string-bad-ending-2029:
  type: advanced
  output: !error
  input: "'foo\u2029bar'"

string-literal-unicode:
  type: advanced
  output: "foo\uFEFF\u2030bar\u1234"
  input: "'foo\uFEFF\u2030bar\u1234'"

string-control-char:
  type: advanced
  output: "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0b\x0c\x0e\x0f"
  input: "'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0b\x0c\x0e\x0f'"

# String: escape sequences
# ------------------------

string-octal-escape:
  type: extra
  output: "\x1b[1;32mhi\x1b[m??"
  input: >
    '\033[1;32mhi\033[m\077\077'

string-octal-two-digits:
  type: extra
  output: "\n\x1c\x2e\x07890\x01"
  input: >
    '\12\34\56\78\90\1'

string-octal-three-digits:
  type: extra
  output: "\n34.78\xff 0"
  input: >
    '\01234\5678\377\400'

string-hex-escape:
  type: extra
  output: "\x01\x23\xab\xcd\xef"
  input: >
    "\x01\x23\xab\xCd\xEF"

# \0 is *not* an octal escape sequence,
# and is allowed even in strict mode
string-zero-point:
  type: basic
  output: "\0"
  input: >
    '\0'

string-escape-double-quotes:
  type: basic
  output: "\"''"
  input: >
    "\"'\'"

string-escape-single-quotes:
  type: basic
  output: "   '\"\"   "
  input: >
    '   \'"\"   '

string-escape-json-chars:
  type: basic
  output: "\\\/\b\f\n\r\t"
  input: >
    "\\\/\b\f\n\r\t"

# this character was left out of
# json spec for whatever reason
string-escape-slash-v:
  type: basic
  output: "\v"
  input: >
    "\v"

string-unicode-escape:
  type: basic
  output: "\u0000\uffffx\ufeff\u1234\u9f6a\u2028\uabcd"
  input: >
    "\u0000\uFFFFx\uFeFf\u1234\u9F6a\u2028\uabcd"

string-arbitrary-escape:
  type: advanced
  output: "X12Uqwe\r\tyiopasd\fghjklzc\u000b\b\nm9 "
  input: >
    '\X12\U\q\w\e\r\t\y\i\o\p\a\s\d\f\g\h\j\k\l\z\c\v\b\n\m\9\ '

string-bad-unicode:
  type: advanced
  output: !error
  input: >
    '\uEFGH'

string-incomplete-unicode:
  type: advanced
  output: !error
  input: >
    '\u$'

string-bad-hex:
  type: advanced
  output: !error
  input: >
    '\xFG'

string-incomplete-hex:
  type: advanced
  output: !error
  input: >
    '\x$'

# Object literals
# ---------------

object-nested:
  type: basic
  output: {q:{'w':{"e":[1]}}}
  input: |
    {q:{'w':{"e":[1]}}}

object-trailing-comma:
  type: basic
  output: {foo: 'bar'}
  input: |
    {foo: 'bar',}

object-leading-comma-style:
  type: basic
  output: {q: 1,w: 2,e: 3}
  input: |
    { q: 1
    , w: 2
    , e: 3
    }

object-incomplete:
  type: basic
  output: !error
  input: |
    {q:1,w:2,{}

object-isnt-array:
  type: basic
  output: !error
  input: |
    {1,2}

object-no-single-comma:
  type: basic
  output: !error
  input: |
    {,}

object-no-elisions:
  type: basic
  output: !error
  input: |
    {q:1,,w:2}

# Objects: keys
# -------------

object-singlequoted:
  type: basic
  output: {q: 1,w: 2,e: 3}
  input: |
    {'q':1,'w':2,'e':3}

object-doublequoted:
  type: basic
  output: {q: 1,w: 2,e: 3}
  input: |
    {"q":1,"w":2,"e":3}

object-unquoted:
  type: basic
  output: {$FOO_bar123: 'baz'}
  input: >
    {$FOO_bar123: 'baz'}

object-no-first-digit:
  type: advanced
  output: !error
  input: >
    {123foo: bar}

object-unquoted-unicode:
  type: advanced
  output: {"\u1f04\u03bb\u03c6\u03b1": baz}
  input: "{\u1f04\u03bb\u03c6\u03b1:'baz'}"

object-unicode-escape-key:
  type: advanced
  output: {foo: 'bar', "\u1f04\u03bb\u03c6\u03b1": baz, "qwe\u1f04rty": quux}
  input: |
    {foo:'bar', \u1f04\u03bb\u03c6\u03b1:'baz', qwe\u1f04rty: "quux"}

object-no-raw-literal:
  type: extra
  output: !error
  input: |
    {foo: bar}

object-bad-literal:
  type: advanced
  output: !error
  input: |
    {foo-bar: 123}

object-no-space-in-key:
  type: advanced
  output: !error
  input: |
    {foo bar: 123}

object-no-comment-in-key:
  type: advanced
  output: !error
  input: |
    {foo/*bar*/baz: 123}

object-float-keys:
  type: advanced
  output: {'1': 'one', '3.1415': 'pi'}
  input: |
    {1:'one', 3.1415:'pi'}

object-no-negative:
  type: advanced
  output: !error
  input: |
    {-5: 123}

object-exponent-keys:
  type: advanced
  output: {'1': 'exp', '1000': 'pos', '0.001': 'neg'}
  input: |
    {1e0: 'exp', 1e+3: 'pos', 1e-3: 'neg'}

object-octal-keys:
  type: extra
  output: {'668': 1}
  input: |
    {01234: 1}

object-hex-keys:
  type: advanced
  output: {'51966': 1}
  input: |
    {0xCAFE: 1}

object-null-keys:
  type: basic
  output: {'null': null}
  input: |
    {null: null}

object-no-array-keys:
  type: extra
  output: !error
  input: |
    {[]: 123}

object-no-empty-keys:
  type: basic
  output: !error
  input: |
    {: 123}

object-empty-string-key:
  type: basic
  output: {s: {'': 1}, m: {'': 2}}
  input: |
    {s: {'': 1}, m: {"": 2}}

object-bad-unicode-space:
  type: advanced
  output: !error
  input: |
    { \u0020foobar: 123 }

object-bad-unicode-dash:
  type: advanced
  output: !error
  input: |
    { foo\u002dbar: 123}

object-incomplete-unicode-sequence:
  type: advanced
  output: !error
  input: |
    { foo\u12f: 123 }

object-double-escape:
  type: advanced
  output: !error
  input: |
    { foo\\u1234bar: 123 }

object-we-arent-es3:
  type: basic
  output: {new: 1, delete: 2, throw: 3}
  input: |
    {new: 1, delete: 2, throw: 3}

object-last-digits:
  type: basic
  output: {$123e2: 1, abc123: 2}
  input: |
    {$123e2: 1, abc123: 2}

object-unicode-in-string:
  type: advanced
  output: {"\uff13qwe": 123}
  input: |
    {"\uff13qwe": 123}

object-unicode-esc-in-string:
  type: advanced
  output: {"\\uff13qwe": 123}
  input: |
    {"\\uff13qwe": 123}

object-unicode-digits-first-esc:
  type: advanced
  output: !error
  input: |
    {\uff13qwe: 123}

object-unicode-digits-first-lit:
  type: advanced
  output: !error
  input: "{\uff13qwe: 123}"

object-unicode-weirdness-esc:
  type: advanced
  output: {"digit\uff13": 1, "comb\u094F": 2, "punct\u2040": 3, "zwnj\u200C": 4}
  input: |
    {digit\uff13: 1, comb\u094F: 2, punct\u2040: 3, zwnj\u200C: 4}

object-unicode-weirdness-lit:
  type: advanced
  output: {"digit\uff13": 1, "comb\u094F": 2, "punct\u2040": 3, "zwnj\u200C": 4}
  input: "{digit\uff13: 1, comb\u094F: 2, punct\u2040: 3, zwnj\u200C: 4}"

# Array literals
# --------------

array-all-types:
  type: basic
  output: [1.2,"3,4",{},[],null,+.inf]
  input: |
    [1.2,"3,4",{},[],null,Infinity]

array-trailing-comma:
  type: basic
  output: [1,2,3,4]
  input: |
    [1,2,3,4,]

array-leading-comma-style:
  type: basic
  output: [quux,foo,bar,baz]
  input: |
    [ 'quux'
    , 'foo'
    , 'bar'
    , 'baz'
    ]

array-incomplete:
  type: basic
  output: !error
  input: |
    [1,2,3,[]

array-nested:
  type: basic
  output: [[[[[[]]]]],[[],[]]]
  input: |
    [[[[[[/*[]*/]]]]],[[],[]]]

array-isnt-object:
  type: extra
  output: !error
  input: |
    [1:2]

array-no-single-comma:
  type: extra
  output: !error
  input: |
    [,]

array-no-elisions:
  type: extra
  output: !error
  input: |
    [1,,2,3]

# Comments
# --------

comment-single:
  type: basic
  output: foobar
  input: |
    // blahblah
    "foobar"
    // another one

comment-multi:
  type: basic
  output: foobar
  input: |
    /*
     * 123
     */
    "foobar"
    /**/

comment-single-newlines:
  type: advanced
  output: [ 123, 456, 789 ]
  input: "[// foo\r123,// bar\u2028456,// baz\u2029789]"

comment-inside:
  type: advanced
  output: [123, '// foo', '/* bar']
  input: >
    [
      /*
      " // */ 123, // ",
      "// foo",
      '/* bar',
    ]

comment-in-token:
  type: advanced
  output: !error
  input:
    123/*comment*/456

comment-java-style:
  type: basic
  output: 123
  input:
    /*****************/
    123
    /****************/

comment-object:
  type: basic
  output: {q: 123}
  input: /**/{/**/q/**/:/**/123/**/,/**/}//

# Whitespace
# ----------

ws-no-whitespace:
  type: basic
  output: {"foo":bar,bar:["qwe",null,[],{}],"baz":123}
  input: '{foo:"bar","bar":["qwe",null,[],{}],"baz":123}'

ws-allow-prefix:
  type: basic
  output: 123
  input: " \t123"

ws-unicode-spaces:
  type: advanced
  output: { foo : 123 }
  input: "
    \u0020\u00A0\uFEFF
    {
    \x09\x0A\x0B\x0C\x0D\u1680\u180E
      foo
    \u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A
      :
    \u2028\u2029\u202F\u205F\u3000
      123
    \uFEFF
    }"

ws-unicode-newlines:
  type: advanced
  output: [ 123, 456 ]
  input: "
    [
      \u000D
      123,
      \u2028
      456,
      \u2029
    ]
    "

# Multiple tokens
# ---------------

multi-string-nospace:
  type: basic
  output: !error
  input: '"foo""bar"'

multi-string:
  type: basic
  output: !error
  input: '"foo" "bar"'

# note: valid javascript
multi-array:
  type: extra
  output: !error
  input: '[0] [0]'

multi-object:
  type: basic
  output: !error
  input: '{} {}'
...