From d108c3ab81aa939ac82b42a3116f9dbf3cc74ac9 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Thu, 30 Jul 2026 23:35:34 +0200 Subject: [PATCH 1/5] test(yaml-lexer): measure YL against the YAML Test Suite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vendors the community YAML Test Suite (351 files, 406 cases) and measures where YL actually stands. This is a "see where we are" instrument, not a pass/fail gate: very few YAML parsers reach 100%, and YL is not trying to — it reads YAML AS JSON, so anything the JSON data model cannot express is out of scope by construction rather than a bug. That framing is what makes the suite usable for us: its `json` field is the JSON a document is equivalent to, which is exactly our expectation. A case is lexed twice — the YAML with YL, the expected JSON with the JSON lexer L — and conformance means the two token streams are identical. Organised like the JSON conformance test (buckets + xfail inventory + golden snapshot of the parts that can only be observed). Baseline -------- accept + token stream matches the expected JSON 204 / 272 (75%) invalid document rejected 85 / 94 (90%) recorded only (no single-root JSON equivalent) 63 known divergences 54 The 54 divergences group into five causes, listed per case in conformanceXFail and analysed in CONFORMANCE.md: 23 non-scalar mapping keys. Mostly keys that RESOLVE to a string (`*alias : v`, `&a k : v`, `!!str k : v`) — the suite's own JSON shows the resolved string as the key. A feature gap, not a scope boundary, and the biggest single win available: it would take the accept rate to ~82%. 14 multiple documents. Out of scope until ND-JSON lands. 9 invalid documents we ACCEPT. The only group where we are wrong in the dangerous direction; all inherited from goccy (flow collections, comment placement, tabs) rather than from our walk. 5 accepted but the token stream differs — scalar resolution (!!binary, non-specific tags, trailing whitespace). Subtlest group: nothing errors. 3 valid documents goccy will not parse at all. Notes on the harness -------------------- The suite renders invisible characters visibly and they MUST be translated back — a fixture that hinges on a trailing space or a hard tab silently becomes a different, usually valid, document otherwise. My first implementation matched a fixed set of tab widths instead of upstream's /—*»/ and mangled any run of four or more em-dashes; fixing it moved 7 cases from "divergent" to passing. The rule is now a regexp and is documented in SOURCE.md. The third bucket is not a weasel. A multi-document stream's `json` field holds several values in sequence and an empty document's is empty; neither is a JSON token stream, so there is nothing to compare and only the verdict is recorded. testdata/conformance_recorded.golden pins those verdicts, so "out of scope" cannot quietly become "unnoticed regression" — the same blind spot the JSON suite had with its i_ cases, where ten documents carrying ill-formed UTF-8 were accepted for months with the suite green. Both drive modes (bytes and reader) run every case and must agree with each other before either is compared to the suite. Co-Authored-By: Claude Opus 5 (1M context) Signed-off-by: Frederic BIDON --- json/lexers/yaml-lexer/CONFORMANCE.md | 138 ++++++++ .../yaml-lexer/conformance_golden_test.go | 104 ++++++ .../yaml-lexer/conformance_suite_test.go | 176 ++++++++++ json/lexers/yaml-lexer/conformance_test.go | 305 ++++++++++++++++++ .../yaml-lexer/conformance_xfail_test.go | 102 ++++++ .../testdata/conformance_recorded.golden | 63 ++++ .../testdata/yaml-test-suite/LICENSE | 21 ++ .../testdata/yaml-test-suite/SOURCE.md | 51 +++ .../testdata/yaml-test-suite/src/229Q.yaml | 56 ++++ .../testdata/yaml-test-suite/src/236B.yaml | 15 + .../testdata/yaml-test-suite/src/26DV.yaml | 82 +++++ .../testdata/yaml-test-suite/src/27NA.yaml | 17 + .../testdata/yaml-test-suite/src/2AUY.yaml | 32 ++ .../testdata/yaml-test-suite/src/2CMS.yaml | 12 + .../testdata/yaml-test-suite/src/2EBW.yaml | 41 +++ .../testdata/yaml-test-suite/src/2G84.yaml | 38 +++ .../testdata/yaml-test-suite/src/2JQS.yaml | 18 ++ .../testdata/yaml-test-suite/src/2LFX.yaml | 22 ++ .../testdata/yaml-test-suite/src/2SXE.yaml | 27 ++ .../testdata/yaml-test-suite/src/2XXW.yaml | 36 +++ .../testdata/yaml-test-suite/src/33X3.yaml | 30 ++ .../testdata/yaml-test-suite/src/35KP.yaml | 44 +++ .../testdata/yaml-test-suite/src/36F6.yaml | 28 ++ .../testdata/yaml-test-suite/src/3ALJ.yaml | 28 ++ .../testdata/yaml-test-suite/src/3GZX.yaml | 31 ++ .../testdata/yaml-test-suite/src/3HFZ.yaml | 17 + .../testdata/yaml-test-suite/src/3MYT.yaml | 18 ++ .../testdata/yaml-test-suite/src/3R3P.yaml | 22 ++ .../testdata/yaml-test-suite/src/3RLN.yaml | 87 +++++ .../testdata/yaml-test-suite/src/3UYS.yaml | 21 ++ .../testdata/yaml-test-suite/src/4ABK.yaml | 27 ++ .../testdata/yaml-test-suite/src/4CQQ.yaml | 30 ++ .../testdata/yaml-test-suite/src/4EJS.yaml | 15 + .../testdata/yaml-test-suite/src/4FJ6.yaml | 42 +++ .../testdata/yaml-test-suite/src/4GC6.yaml | 14 + .../testdata/yaml-test-suite/src/4H7K.yaml | 17 + .../testdata/yaml-test-suite/src/4HVU.yaml | 19 ++ .../testdata/yaml-test-suite/src/4JVG.yaml | 20 ++ .../testdata/yaml-test-suite/src/4MUZ.yaml | 56 ++++ .../testdata/yaml-test-suite/src/4Q9F.yaml | 29 ++ .../testdata/yaml-test-suite/src/4QFQ.yaml | 44 +++ .../testdata/yaml-test-suite/src/4RWC.yaml | 27 ++ .../testdata/yaml-test-suite/src/4UYU.yaml | 14 + .../testdata/yaml-test-suite/src/4V8U.yaml | 17 + .../testdata/yaml-test-suite/src/4WA9.yaml | 40 +++ .../testdata/yaml-test-suite/src/4ZYM.yaml | 41 +++ .../testdata/yaml-test-suite/src/52DL.yaml | 17 + .../testdata/yaml-test-suite/src/54T7.yaml | 25 ++ .../testdata/yaml-test-suite/src/55WF.yaml | 11 + .../testdata/yaml-test-suite/src/565N.yaml | 36 +++ .../testdata/yaml-test-suite/src/57H4.yaml | 49 +++ .../testdata/yaml-test-suite/src/58MP.yaml | 21 ++ .../testdata/yaml-test-suite/src/5BVJ.yaml | 33 ++ .../testdata/yaml-test-suite/src/5C5M.yaml | 42 +++ .../testdata/yaml-test-suite/src/5GBF.yaml | 33 ++ .../testdata/yaml-test-suite/src/5KJE.yaml | 38 +++ .../testdata/yaml-test-suite/src/5LLU.yaml | 16 + .../testdata/yaml-test-suite/src/5MUD.yaml | 24 ++ .../testdata/yaml-test-suite/src/5NYZ.yaml | 22 ++ .../testdata/yaml-test-suite/src/5T43.yaml | 37 +++ .../testdata/yaml-test-suite/src/5TRB.yaml | 13 + .../testdata/yaml-test-suite/src/5TYM.yaml | 24 ++ .../testdata/yaml-test-suite/src/5U3A.yaml | 13 + .../testdata/yaml-test-suite/src/5WE3.yaml | 38 +++ .../testdata/yaml-test-suite/src/62EZ.yaml | 17 + .../testdata/yaml-test-suite/src/652Z.yaml | 31 ++ .../testdata/yaml-test-suite/src/65WH.yaml | 18 ++ .../testdata/yaml-test-suite/src/6BCT.yaml | 37 +++ .../testdata/yaml-test-suite/src/6BFJ.yaml | 28 ++ .../testdata/yaml-test-suite/src/6CA3.yaml | 18 ++ .../testdata/yaml-test-suite/src/6CK3.yaml | 26 ++ .../testdata/yaml-test-suite/src/6FWR.yaml | 27 ++ .../testdata/yaml-test-suite/src/6H3V.yaml | 21 ++ .../testdata/yaml-test-suite/src/6HB6.yaml | 55 ++++ .../testdata/yaml-test-suite/src/6JQW.yaml | 21 ++ .../testdata/yaml-test-suite/src/6JTT.yaml | 17 + .../testdata/yaml-test-suite/src/6JWB.yaml | 38 +++ .../testdata/yaml-test-suite/src/6KGN.yaml | 28 ++ .../testdata/yaml-test-suite/src/6LVF.yaml | 18 ++ .../testdata/yaml-test-suite/src/6M2F.yaml | 22 ++ .../testdata/yaml-test-suite/src/6PBE.yaml | 33 ++ .../testdata/yaml-test-suite/src/6S55.yaml | 18 ++ .../testdata/yaml-test-suite/src/6SLA.yaml | 27 ++ .../testdata/yaml-test-suite/src/6VJK.yaml | 29 ++ .../testdata/yaml-test-suite/src/6WLZ.yaml | 35 ++ .../testdata/yaml-test-suite/src/6WPF.yaml | 25 ++ .../testdata/yaml-test-suite/src/6XDY.yaml | 22 ++ .../testdata/yaml-test-suite/src/6ZKB.yaml | 40 +++ .../testdata/yaml-test-suite/src/735Y.yaml | 38 +++ .../testdata/yaml-test-suite/src/74H7.yaml | 41 +++ .../testdata/yaml-test-suite/src/753E.yaml | 22 ++ .../testdata/yaml-test-suite/src/7A4E.yaml | 19 ++ .../testdata/yaml-test-suite/src/7BMT.yaml | 90 ++++++ .../testdata/yaml-test-suite/src/7BUB.yaml | 49 +++ .../testdata/yaml-test-suite/src/7FWL.yaml | 22 ++ .../testdata/yaml-test-suite/src/7LBH.yaml | 15 + .../testdata/yaml-test-suite/src/7MNF.yaml | 18 ++ .../testdata/yaml-test-suite/src/7T8X.yaml | 41 +++ .../testdata/yaml-test-suite/src/7TMG.yaml | 27 ++ .../testdata/yaml-test-suite/src/7W2P.yaml | 31 ++ .../testdata/yaml-test-suite/src/7Z25.yaml | 30 ++ .../testdata/yaml-test-suite/src/7ZZ5.yaml | 63 ++++ .../testdata/yaml-test-suite/src/82AN.yaml | 17 + .../testdata/yaml-test-suite/src/87E4.yaml | 33 ++ .../testdata/yaml-test-suite/src/8CWC.yaml | 23 ++ .../testdata/yaml-test-suite/src/8G76.yaml | 14 + .../testdata/yaml-test-suite/src/8KB6.yaml | 45 +++ .../testdata/yaml-test-suite/src/8MK2.yaml | 14 + .../testdata/yaml-test-suite/src/8QBE.yaml | 31 ++ .../testdata/yaml-test-suite/src/8UDB.yaml | 48 +++ .../testdata/yaml-test-suite/src/8XDJ.yaml | 15 + .../testdata/yaml-test-suite/src/8XYN.yaml | 22 ++ .../testdata/yaml-test-suite/src/93JH.yaml | 40 +++ .../testdata/yaml-test-suite/src/93WF.yaml | 27 ++ .../testdata/yaml-test-suite/src/96L6.yaml | 20 ++ .../testdata/yaml-test-suite/src/96NN.yaml | 25 ++ .../testdata/yaml-test-suite/src/98YD.yaml | 11 + .../testdata/yaml-test-suite/src/9BXH.yaml | 45 +++ .../testdata/yaml-test-suite/src/9C9N.yaml | 17 + .../testdata/yaml-test-suite/src/9CWY.yaml | 19 ++ .../testdata/yaml-test-suite/src/9DXL.yaml | 45 +++ .../testdata/yaml-test-suite/src/9FMG.yaml | 45 +++ .../testdata/yaml-test-suite/src/9HCY.yaml | 14 + .../testdata/yaml-test-suite/src/9J7A.yaml | 25 ++ .../testdata/yaml-test-suite/src/9JBA.yaml | 16 + .../testdata/yaml-test-suite/src/9KAX.yaml | 104 ++++++ .../testdata/yaml-test-suite/src/9KBC.yaml | 11 + .../testdata/yaml-test-suite/src/9MAG.yaml | 12 + .../testdata/yaml-test-suite/src/9MMA.yaml | 9 + .../testdata/yaml-test-suite/src/9MMW.yaml | 41 +++ .../testdata/yaml-test-suite/src/9MQT.yaml | 31 ++ .../testdata/yaml-test-suite/src/9SA2.yaml | 37 +++ .../testdata/yaml-test-suite/src/9SHH.yaml | 23 ++ .../testdata/yaml-test-suite/src/9TFX.yaml | 22 ++ .../testdata/yaml-test-suite/src/9U5K.yaml | 61 ++++ .../testdata/yaml-test-suite/src/9WXW.yaml | 28 ++ .../testdata/yaml-test-suite/src/9YRD.yaml | 23 ++ .../testdata/yaml-test-suite/src/A2M4.yaml | 39 +++ .../testdata/yaml-test-suite/src/A6F9.yaml | 37 +++ .../testdata/yaml-test-suite/src/A984.yaml | 29 ++ .../testdata/yaml-test-suite/src/AB8U.yaml | 21 ++ .../testdata/yaml-test-suite/src/AVM7.yaml | 10 + .../testdata/yaml-test-suite/src/AZ63.yaml | 31 ++ .../testdata/yaml-test-suite/src/AZW3.yaml | 31 ++ .../testdata/yaml-test-suite/src/B3HG.yaml | 24 ++ .../testdata/yaml-test-suite/src/B63P.yaml | 10 + .../testdata/yaml-test-suite/src/BD7L.yaml | 15 + .../testdata/yaml-test-suite/src/BEC7.yaml | 19 ++ .../testdata/yaml-test-suite/src/BF9H.yaml | 16 + .../testdata/yaml-test-suite/src/BS4K.yaml | 13 + .../testdata/yaml-test-suite/src/BU8L.yaml | 29 ++ .../testdata/yaml-test-suite/src/C2DT.yaml | 33 ++ .../testdata/yaml-test-suite/src/C2SP.yaml | 13 + .../testdata/yaml-test-suite/src/C4HZ.yaml | 100 ++++++ .../testdata/yaml-test-suite/src/CC74.yaml | 18 ++ .../testdata/yaml-test-suite/src/CFD4.yaml | 29 ++ .../testdata/yaml-test-suite/src/CML9.yaml | 16 + .../testdata/yaml-test-suite/src/CN3R.yaml | 56 ++++ .../testdata/yaml-test-suite/src/CPZ3.yaml | 23 ++ .../testdata/yaml-test-suite/src/CQ3W.yaml | 13 + .../testdata/yaml-test-suite/src/CT4Q.yaml | 28 ++ .../testdata/yaml-test-suite/src/CTN5.yaml | 15 + .../testdata/yaml-test-suite/src/CUP7.yaml | 26 ++ .../testdata/yaml-test-suite/src/CVW2.yaml | 16 + .../testdata/yaml-test-suite/src/CXX2.yaml | 10 + .../testdata/yaml-test-suite/src/D49Q.yaml | 15 + .../testdata/yaml-test-suite/src/D83L.yaml | 28 ++ .../testdata/yaml-test-suite/src/D88J.yaml | 29 ++ .../testdata/yaml-test-suite/src/D9TU.yaml | 19 ++ .../testdata/yaml-test-suite/src/DBG4.yaml | 62 ++++ .../testdata/yaml-test-suite/src/DC7X.yaml | 37 +++ .../testdata/yaml-test-suite/src/DE56.yaml | 87 +++++ .../testdata/yaml-test-suite/src/DFF7.yaml | 27 ++ .../testdata/yaml-test-suite/src/DHP8.yaml | 26 ++ .../testdata/yaml-test-suite/src/DK3J.yaml | 20 ++ .../testdata/yaml-test-suite/src/DK4H.yaml | 14 + .../testdata/yaml-test-suite/src/DK95.yaml | 172 ++++++++++ .../testdata/yaml-test-suite/src/DMG6.yaml | 18 ++ .../testdata/yaml-test-suite/src/DWX9.yaml | 32 ++ .../testdata/yaml-test-suite/src/E76Z.yaml | 26 ++ .../testdata/yaml-test-suite/src/EB22.yaml | 16 + .../testdata/yaml-test-suite/src/EHF6.yaml | 33 ++ .../testdata/yaml-test-suite/src/EW3V.yaml | 13 + .../testdata/yaml-test-suite/src/EX5H.yaml | 28 ++ .../testdata/yaml-test-suite/src/EXG3.yaml | 20 ++ .../testdata/yaml-test-suite/src/F2C7.yaml | 32 ++ .../testdata/yaml-test-suite/src/F3CP.yaml | 47 +++ .../testdata/yaml-test-suite/src/F6MC.yaml | 40 +++ .../testdata/yaml-test-suite/src/F8F9.yaml | 52 +++ .../testdata/yaml-test-suite/src/FBC9.yaml | 37 +++ .../testdata/yaml-test-suite/src/FH7J.yaml | 33 ++ .../testdata/yaml-test-suite/src/FP8R.yaml | 20 ++ .../testdata/yaml-test-suite/src/FQ7F.yaml | 33 ++ .../testdata/yaml-test-suite/src/FRK4.yaml | 20 ++ .../testdata/yaml-test-suite/src/FTA2.yaml | 22 ++ .../testdata/yaml-test-suite/src/FUP4.yaml | 30 ++ .../testdata/yaml-test-suite/src/G4RS.yaml | 47 +++ .../testdata/yaml-test-suite/src/G5U8.yaml | 13 + .../testdata/yaml-test-suite/src/G7JE.yaml | 15 + .../testdata/yaml-test-suite/src/G992.yaml | 21 ++ .../testdata/yaml-test-suite/src/G9HC.yaml | 16 + .../testdata/yaml-test-suite/src/GDY7.yaml | 14 + .../testdata/yaml-test-suite/src/GH63.yaml | 27 ++ .../testdata/yaml-test-suite/src/GT5M.yaml | 14 + .../testdata/yaml-test-suite/src/H2RW.yaml | 51 +++ .../testdata/yaml-test-suite/src/H3Z8.yaml | 23 ++ .../testdata/yaml-test-suite/src/H7J7.yaml | 15 + .../testdata/yaml-test-suite/src/H7TQ.yaml | 10 + .../testdata/yaml-test-suite/src/HM87.yaml | 37 +++ .../testdata/yaml-test-suite/src/HMK4.yaml | 38 +++ .../testdata/yaml-test-suite/src/HMQ5.yaml | 27 ++ .../testdata/yaml-test-suite/src/HRE5.yaml | 13 + .../testdata/yaml-test-suite/src/HS5T.yaml | 21 ++ .../testdata/yaml-test-suite/src/HU3P.yaml | 14 + .../testdata/yaml-test-suite/src/HWV9.yaml | 11 + .../testdata/yaml-test-suite/src/J3BT.yaml | 33 ++ .../testdata/yaml-test-suite/src/J5UC.yaml | 27 ++ .../testdata/yaml-test-suite/src/J7PZ.yaml | 52 +++ .../testdata/yaml-test-suite/src/J7VC.yaml | 28 ++ .../testdata/yaml-test-suite/src/J9HZ.yaml | 49 +++ .../testdata/yaml-test-suite/src/JEF9.yaml | 53 +++ .../testdata/yaml-test-suite/src/JHB9.yaml | 49 +++ .../testdata/yaml-test-suite/src/JKF3.yaml | 13 + .../testdata/yaml-test-suite/src/JQ4R.yaml | 36 +++ .../testdata/yaml-test-suite/src/JR7V.yaml | 76 +++++ .../testdata/yaml-test-suite/src/JS2J.yaml | 23 ++ .../testdata/yaml-test-suite/src/JTV5.yaml | 30 ++ .../testdata/yaml-test-suite/src/JY7Z.yaml | 17 + .../testdata/yaml-test-suite/src/K3WX.yaml | 24 ++ .../testdata/yaml-test-suite/src/K4SU.yaml | 24 ++ .../testdata/yaml-test-suite/src/K527.yaml | 27 ++ .../testdata/yaml-test-suite/src/K54U.yaml | 17 + .../testdata/yaml-test-suite/src/K858.yaml | 36 +++ .../testdata/yaml-test-suite/src/KH5V.yaml | 40 +++ .../testdata/yaml-test-suite/src/KK5P.yaml | 81 +++++ .../testdata/yaml-test-suite/src/KMK3.yaml | 29 ++ .../testdata/yaml-test-suite/src/KS4U.yaml | 17 + .../testdata/yaml-test-suite/src/KSS4.yaml | 27 ++ .../testdata/yaml-test-suite/src/L24T.yaml | 45 +++ .../testdata/yaml-test-suite/src/L383.yaml | 22 ++ .../testdata/yaml-test-suite/src/L94M.yaml | 28 ++ .../testdata/yaml-test-suite/src/L9U5.yaml | 33 ++ .../testdata/yaml-test-suite/src/LE5A.yaml | 30 ++ .../testdata/yaml-test-suite/src/LHL4.yaml | 11 + .../testdata/yaml-test-suite/src/LP6E.yaml | 55 ++++ .../testdata/yaml-test-suite/src/LQZ7.yaml | 33 ++ .../testdata/yaml-test-suite/src/LX3P.yaml | 20 ++ .../testdata/yaml-test-suite/src/M29M.yaml | 33 ++ .../testdata/yaml-test-suite/src/M2N8.yaml | 42 +++ .../testdata/yaml-test-suite/src/M5C3.yaml | 32 ++ .../testdata/yaml-test-suite/src/M5DY.yaml | 46 +++ .../testdata/yaml-test-suite/src/M6YH.yaml | 41 +++ .../testdata/yaml-test-suite/src/M7A3.yaml | 29 ++ .../testdata/yaml-test-suite/src/M7NX.yaml | 53 +++ .../testdata/yaml-test-suite/src/M9B4.yaml | 22 ++ .../testdata/yaml-test-suite/src/MJS9.yaml | 21 ++ .../testdata/yaml-test-suite/src/MUS6.yaml | 49 +++ .../testdata/yaml-test-suite/src/MXS3.yaml | 25 ++ .../testdata/yaml-test-suite/src/MYW6.yaml | 22 ++ .../testdata/yaml-test-suite/src/MZX3.yaml | 31 ++ .../testdata/yaml-test-suite/src/N4JP.yaml | 18 ++ .../testdata/yaml-test-suite/src/N782.yaml | 14 + .../testdata/yaml-test-suite/src/NAT4.yaml | 77 +++++ .../testdata/yaml-test-suite/src/NB6Z.yaml | 27 ++ .../testdata/yaml-test-suite/src/NHX8.yaml | 19 ++ .../testdata/yaml-test-suite/src/NJ66.yaml | 37 +++ .../testdata/yaml-test-suite/src/NKF9.yaml | 60 ++++ .../testdata/yaml-test-suite/src/NP9H.yaml | 20 ++ .../testdata/yaml-test-suite/src/P2AD.yaml | 42 +++ .../testdata/yaml-test-suite/src/P2EQ.yaml | 16 + .../testdata/yaml-test-suite/src/P76L.yaml | 18 ++ .../testdata/yaml-test-suite/src/P94K.yaml | 25 ++ .../testdata/yaml-test-suite/src/PBJ2.yaml | 54 ++++ .../testdata/yaml-test-suite/src/PRH3.yaml | 25 ++ .../testdata/yaml-test-suite/src/PUW8.yaml | 30 ++ .../testdata/yaml-test-suite/src/PW8X.yaml | 52 +++ .../testdata/yaml-test-suite/src/Q4CL.yaml | 17 + .../testdata/yaml-test-suite/src/Q5MG.yaml | 17 + .../testdata/yaml-test-suite/src/Q88A.yaml | 48 +++ .../testdata/yaml-test-suite/src/Q8AD.yaml | 23 ++ .../testdata/yaml-test-suite/src/Q9WF.yaml | 35 ++ .../testdata/yaml-test-suite/src/QB6E.yaml | 15 + .../testdata/yaml-test-suite/src/QF4Y.yaml | 27 ++ .../testdata/yaml-test-suite/src/QLJ7.yaml | 22 ++ .../testdata/yaml-test-suite/src/QT73.yaml | 12 + .../testdata/yaml-test-suite/src/R4YG.yaml | 44 +++ .../testdata/yaml-test-suite/src/R52L.yaml | 43 +++ .../testdata/yaml-test-suite/src/RHX7.yaml | 16 + .../testdata/yaml-test-suite/src/RLU9.yaml | 38 +++ .../testdata/yaml-test-suite/src/RR7F.yaml | 27 ++ .../testdata/yaml-test-suite/src/RTP8.yaml | 20 ++ .../testdata/yaml-test-suite/src/RXY3.yaml | 13 + .../testdata/yaml-test-suite/src/RZP5.yaml | 58 ++++ .../testdata/yaml-test-suite/src/RZT7.yaml | 133 ++++++++ .../testdata/yaml-test-suite/src/S3PD.yaml | 29 ++ .../testdata/yaml-test-suite/src/S4GJ.yaml | 14 + .../testdata/yaml-test-suite/src/S4JQ.yaml | 29 ++ .../testdata/yaml-test-suite/src/S4T7.yaml | 20 ++ .../testdata/yaml-test-suite/src/S7BG.yaml | 22 ++ .../testdata/yaml-test-suite/src/S98Z.yaml | 16 + .../testdata/yaml-test-suite/src/S9E8.yaml | 49 +++ .../testdata/yaml-test-suite/src/SBG9.yaml | 30 ++ .../testdata/yaml-test-suite/src/SF5V.yaml | 11 + .../testdata/yaml-test-suite/src/SKE5.yaml | 34 ++ .../testdata/yaml-test-suite/src/SM9W.yaml | 34 ++ .../testdata/yaml-test-suite/src/SR86.yaml | 15 + .../testdata/yaml-test-suite/src/SSW6.yaml | 17 + .../testdata/yaml-test-suite/src/SU5Z.yaml | 13 + .../testdata/yaml-test-suite/src/SU74.yaml | 14 + .../testdata/yaml-test-suite/src/SY6V.yaml | 9 + .../testdata/yaml-test-suite/src/SYW4.yaml | 31 ++ .../testdata/yaml-test-suite/src/T26H.yaml | 32 ++ .../testdata/yaml-test-suite/src/T4YY.yaml | 26 ++ .../testdata/yaml-test-suite/src/T5N4.yaml | 24 ++ .../testdata/yaml-test-suite/src/T833.yaml | 15 + .../testdata/yaml-test-suite/src/TD5N.yaml | 15 + .../testdata/yaml-test-suite/src/TE2A.yaml | 28 ++ .../testdata/yaml-test-suite/src/TL85.yaml | 22 ++ .../testdata/yaml-test-suite/src/TS54.yaml | 29 ++ .../testdata/yaml-test-suite/src/U3C3.yaml | 18 ++ .../testdata/yaml-test-suite/src/U3XV.yaml | 92 ++++++ .../testdata/yaml-test-suite/src/U44R.yaml | 17 + .../testdata/yaml-test-suite/src/U99R.yaml | 11 + .../testdata/yaml-test-suite/src/U9NS.yaml | 49 +++ .../testdata/yaml-test-suite/src/UDM2.yaml | 25 ++ .../testdata/yaml-test-suite/src/UDR7.yaml | 44 +++ .../testdata/yaml-test-suite/src/UGM3.yaml | 163 ++++++++++ .../testdata/yaml-test-suite/src/UKK6.yaml | 43 +++ .../testdata/yaml-test-suite/src/UT92.yaml | 35 ++ .../testdata/yaml-test-suite/src/UV7Q.yaml | 28 ++ .../testdata/yaml-test-suite/src/V55R.yaml | 27 ++ .../testdata/yaml-test-suite/src/V9D5.yaml | 29 ++ .../testdata/yaml-test-suite/src/VJP3.yaml | 49 +++ .../testdata/yaml-test-suite/src/W42U.yaml | 47 +++ .../testdata/yaml-test-suite/src/W4TN.yaml | 31 ++ .../testdata/yaml-test-suite/src/W5VH.yaml | 23 ++ .../testdata/yaml-test-suite/src/W9L4.yaml | 16 + .../testdata/yaml-test-suite/src/WZ62.yaml | 28 ++ .../testdata/yaml-test-suite/src/X38W.yaml | 33 ++ .../testdata/yaml-test-suite/src/X4QW.yaml | 13 + .../testdata/yaml-test-suite/src/X8DW.yaml | 25 ++ .../testdata/yaml-test-suite/src/XLQ9.yaml | 19 ++ .../testdata/yaml-test-suite/src/XV9V.yaml | 33 ++ .../testdata/yaml-test-suite/src/XW4D.yaml | 59 ++++ .../testdata/yaml-test-suite/src/Y2GN.yaml | 23 ++ .../testdata/yaml-test-suite/src/Y79Y.yaml | 119 +++++++ .../testdata/yaml-test-suite/src/YD5X.yaml | 58 ++++ .../testdata/yaml-test-suite/src/YJV2.yaml | 11 + .../testdata/yaml-test-suite/src/Z67P.yaml | 30 ++ .../testdata/yaml-test-suite/src/Z9M4.yaml | 23 ++ .../testdata/yaml-test-suite/src/ZCZ6.yaml | 12 + .../testdata/yaml-test-suite/src/ZF4X.yaml | 49 +++ .../testdata/yaml-test-suite/src/ZH7C.yaml | 23 ++ .../testdata/yaml-test-suite/src/ZK9H.yaml | 37 +++ .../testdata/yaml-test-suite/src/ZL4Z.yaml | 14 + .../testdata/yaml-test-suite/src/ZVH3.yaml | 16 + .../testdata/yaml-test-suite/src/ZWK4.yaml | 33 ++ .../testdata/yaml-test-suite/src/ZXT5.yaml | 13 + .../testdata/yaml-test-suite/src/ZYU8.yaml | 32 ++ 359 files changed, 11732 insertions(+) create mode 100644 json/lexers/yaml-lexer/CONFORMANCE.md create mode 100644 json/lexers/yaml-lexer/conformance_golden_test.go create mode 100644 json/lexers/yaml-lexer/conformance_suite_test.go create mode 100644 json/lexers/yaml-lexer/conformance_test.go create mode 100644 json/lexers/yaml-lexer/conformance_xfail_test.go create mode 100644 json/lexers/yaml-lexer/testdata/conformance_recorded.golden create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/LICENSE create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/SOURCE.md create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/229Q.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/236B.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/26DV.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/27NA.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2AUY.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2CMS.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2EBW.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2G84.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2JQS.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2LFX.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2SXE.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2XXW.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/33X3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/35KP.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/36F6.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3ALJ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3GZX.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3HFZ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3MYT.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3R3P.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3RLN.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3UYS.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4ABK.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4CQQ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4EJS.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4FJ6.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4GC6.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4H7K.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4HVU.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4JVG.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4MUZ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4Q9F.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4QFQ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4RWC.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4UYU.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4V8U.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4WA9.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4ZYM.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/52DL.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/54T7.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/55WF.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/565N.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/57H4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/58MP.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5BVJ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5C5M.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5GBF.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5KJE.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5LLU.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5MUD.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5NYZ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5T43.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5TRB.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5TYM.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5U3A.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5WE3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/62EZ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/652Z.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/65WH.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6BCT.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6BFJ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6CA3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6CK3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6FWR.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6H3V.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6HB6.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6JQW.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6JTT.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6JWB.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6KGN.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6LVF.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6M2F.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6PBE.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6S55.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6SLA.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6VJK.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6WLZ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6WPF.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6XDY.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6ZKB.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/735Y.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/74H7.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/753E.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7A4E.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7BMT.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7BUB.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7FWL.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7LBH.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7MNF.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7T8X.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7TMG.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7W2P.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7Z25.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7ZZ5.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/82AN.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/87E4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8CWC.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8G76.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8KB6.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8MK2.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8QBE.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8UDB.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8XDJ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8XYN.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/93JH.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/93WF.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/96L6.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/96NN.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/98YD.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9BXH.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9C9N.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9CWY.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9DXL.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9FMG.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9HCY.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9J7A.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9JBA.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9KAX.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9KBC.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MAG.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MMA.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MMW.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MQT.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9SA2.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9SHH.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9TFX.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9U5K.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9WXW.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9YRD.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/A2M4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/A6F9.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/A984.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AB8U.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AVM7.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AZ63.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AZW3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/B3HG.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/B63P.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BD7L.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BEC7.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BF9H.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BS4K.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BU8L.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/C2DT.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/C2SP.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/C4HZ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CC74.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CFD4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CML9.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CN3R.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CPZ3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CQ3W.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CT4Q.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CTN5.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CUP7.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CVW2.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CXX2.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D49Q.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D83L.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D88J.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D9TU.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DBG4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DC7X.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DE56.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DFF7.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DHP8.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DK3J.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DK4H.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DK95.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DMG6.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DWX9.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/E76Z.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EB22.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EHF6.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EW3V.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EX5H.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EXG3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F2C7.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F3CP.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F6MC.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F8F9.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FBC9.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FH7J.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FP8R.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FQ7F.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FRK4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FTA2.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FUP4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G4RS.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G5U8.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G7JE.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G992.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G9HC.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/GDY7.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/GH63.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/GT5M.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H2RW.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H3Z8.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H7J7.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H7TQ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HM87.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HMK4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HMQ5.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HRE5.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HS5T.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HU3P.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HWV9.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J3BT.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J5UC.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J7PZ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J7VC.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J9HZ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JEF9.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JHB9.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JKF3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JQ4R.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JR7V.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JS2J.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JTV5.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JY7Z.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K3WX.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K4SU.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K527.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K54U.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K858.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KH5V.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KK5P.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KMK3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KS4U.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KSS4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L24T.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L383.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L94M.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L9U5.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LE5A.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LHL4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LP6E.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LQZ7.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LX3P.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M29M.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M2N8.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M5C3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M5DY.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M6YH.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M7A3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M7NX.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M9B4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MJS9.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MUS6.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MXS3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MYW6.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MZX3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/N4JP.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/N782.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NAT4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NB6Z.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NHX8.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NJ66.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NKF9.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NP9H.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P2AD.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P2EQ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P76L.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P94K.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PBJ2.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PRH3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PUW8.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PW8X.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q4CL.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q5MG.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q88A.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q8AD.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q9WF.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QB6E.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QF4Y.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QLJ7.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QT73.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/R4YG.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/R52L.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RHX7.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RLU9.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RR7F.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RTP8.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RXY3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RZP5.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RZT7.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S3PD.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S4GJ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S4JQ.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S4T7.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S7BG.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S98Z.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S9E8.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SBG9.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SF5V.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SKE5.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SM9W.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SR86.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SSW6.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SU5Z.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SU74.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SY6V.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SYW4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T26H.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T4YY.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T5N4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T833.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TD5N.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TE2A.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TL85.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TS54.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U3C3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U3XV.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U44R.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U99R.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U9NS.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UDM2.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UDR7.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UGM3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UKK6.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UT92.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UV7Q.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/V55R.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/V9D5.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/VJP3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W42U.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W4TN.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W5VH.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W9L4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/WZ62.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/X38W.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/X4QW.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/X8DW.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/XLQ9.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/XV9V.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/XW4D.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Y2GN.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Y79Y.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/YD5X.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/YJV2.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Z67P.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Z9M4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZCZ6.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZF4X.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZH7C.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZK9H.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZL4Z.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZVH3.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZWK4.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZXT5.yaml create mode 100644 json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZYU8.yaml diff --git a/json/lexers/yaml-lexer/CONFORMANCE.md b/json/lexers/yaml-lexer/CONFORMANCE.md new file mode 100644 index 0000000..a60f69f --- /dev/null +++ b/json/lexers/yaml-lexer/CONFORMANCE.md @@ -0,0 +1,138 @@ +# YAML conformance: where `YL` stands + +Baseline measured against the vendored [YAML Test Suite](testdata/yaml-test-suite/SOURCE.md) +(revision `da267a5c`, 351 files → **406 cases**), by `TestConformanceYAML`. + +``` +accept + token stream matches the expected JSON 204 / 272 (75%) +invalid document rejected 85 / 94 (90%) +recorded only (no single-root JSON equivalent) 63 +known divergences (conformanceXFail) 54 +``` + +## What is being measured + +`YL` reads YAML **as JSON**, so the suite's `json` field — the JSON a document is +equivalent to — is exactly the right expectation. Each case is lexed twice: the YAML +with `YL`, the expected JSON with the JSON lexer `L`. Conformance means the two token +streams are identical. + +That framing matters for reading the numbers: a case `YL` fails is not necessarily a +YAML bug. It may be a construct JSON cannot express, in which case being unable to lex +it is correct behavior. The 54 divergences below are split accordingly. + +Three buckets, mirroring the JSON suite's `y_`/`n_`/`i_` split: + +| bucket | expectation | +|---|---| +| `json` is one JSON document | must accept, and produce `L`'s token stream for it | +| `fail: true` | must reject | +| anything else | no single-root JSON equivalent — behavior only recorded | + +The third bucket exists because a multi-document stream's `json` field holds several +values in sequence, and an empty document's is empty. Neither is a JSON token stream, +so there is nothing to compare — only the accept/reject verdict, which +`testdata/conformance_recorded.golden` pins so out-of-scope cannot quietly become +unnoticed regression. + +## The 54 divergences + +### 1. Non-scalar mapping keys — 23 cases + +`YL` requires an object key to be a scalar, because JSON keys are strings. Most of +these, however, are keys that *resolve* to a string: + +```yaml +top3: &node3 + *alias1 : scalar3 # the suite expects {"scalar1": "scalar3"} +``` + +An alias, an anchored scalar (`&a key : v`) or a tagged one (`!!str key : v`) is +rejected today, though the resolved key is an ordinary string and the suite's own JSON +shows it as such. **This is a feature gap, not a scope boundary**, and it is the +largest single group. + +Genuinely out of scope within this group: explicit complex keys (`? [a, b] : c`), +which JSON cannot express at all. + +### 2. Multiple documents — 14 cases + +A JSON token stream has one root, so a `%YAML`/`---` multi-document stream is rejected. +Out of scope until the ND-JSON work on the roadmap lands, at which point these become +an NDJSON mode rather than an error. + +(Note these are cases where the *expectation* is still single-root — a directive plus +one document. Streams whose expectation is genuinely several JSON values fall into the +recorded bucket instead.) + +### 3. Invalid documents we accept — 9 cases + +The most valuable group: we are **more permissive than YAML allows**. + +``` +9C9N Wrong indented flow sequence +9JBA Invalid comment after end of flow sequence +CVW2 Invalid comment after comma +G5U8 Plain dashes in flow sequence +QB6E Wrong indented multiline quoted scalar +SU5Z Comment without whitespace after doublequoted scalar +U99R Invalid comma in tag +Y79Y/3 Tabs in various contexts +YJV2 Dash in flow sequence +``` + +All are inherited from the underlying `goccy/go-yaml` parser rather than introduced by +our walk — flow collections, comment placement and tabs. Each needs confirming against +goccy upstream before deciding whether to report it there or pre-validate ourselves. + +### 4. Accepted, but the token stream differs — 5 cases + +``` +565N Construct Binary (!!binary tag) +L24T/1 Trailing line of spaces +LE5A Spec Example 7.24. Flow Nodes +S4JQ Spec Example 6.28. Non-Specific Tags +UGM3 Spec Example 2.27. Invoice +``` + +Scalar-resolution divergences. The subtlest group, because nothing errors — the +document is accepted and the values are simply not the ones the suite expects. + +### 5. Valid documents the parser rejects — 3 cases + +`goccy` fails to parse these at all (`4MUZ/2` flow mapping with the colon on the next +line; two `DK95` tab cases). The fix is upstream, or a pre-pass of our own. + +## Divergences by suite tag + +Which YAML *features* are involved (a case carries several tags, so these overlap): + +``` +spec 22 mapping 21 tag 16 explicit-key 12 flow 10 sequence 10 +directive 8 alias 7 comment 7 unknown-tag 7 whitespace 7 error 6 +header 6 indent 6 anchor 5 1.3-err 4 double 4 … +``` + +## Reading this as a work list + +In rough order of value per unit of effort: + +1. **Resolved-scalar keys** (group 1) — 23 cases, one coherent feature: resolve an + alias/anchor/tag on the key side and use the resulting scalar. Would take the + accept rate from 75% to roughly 82%. +2. **Over-permissiveness** (group 3) — 9 cases, and the only group where we accept + documents we should reject. Worth confirming against goccy first. +3. **Scalar resolution** (group 4) — 5 cases, each needing individual reading. +4. **Multi-document** (group 2) — 14 cases, blocked on the ND-JSON decision. +5. **Upstream parse failures** (group 5) — 3 cases, not ours to fix directly. + +## Maintaining this + +`conformanceXFail` in `conformance_xfail_test.go` lists every divergence with its +reason. The suite is green while they stay divergent, and an entry that starts passing +is reported as an error, so the list cannot rot into an excuse. + +```sh +go test ./json/lexers/yaml-lexer -run TestConformanceYAML -v # full report +go test ./json/lexers/yaml-lexer -run TestConformanceYAML -update-golden +``` diff --git a/json/lexers/yaml-lexer/conformance_golden_test.go b/json/lexers/yaml-lexer/conformance_golden_test.go new file mode 100644 index 0000000..20135f7 --- /dev/null +++ b/json/lexers/yaml-lexer/conformance_golden_test.go @@ -0,0 +1,104 @@ +package lexer_test + +import ( + "flag" + "os" + "path/filepath" + "sort" + "strings" + "testing" +) + +// updateGolden regenerates the recorded-behavior snapshot instead of asserting against it. +// +//nolint:gochecknoglobals // the standard golden-file switch must be a package-level flag +var updateGolden = flag.Bool( + "update-golden", + false, + "rewrite the YAML conformance recorded-behavior snapshot from the current run", +) + +// checkRecordedGolden pins what YL does with every suite case that has no single-root JSON equivalent — multi-document +// streams, empty documents, and valid YAML the JSON data model cannot express. +// +// Nothing asserts these, because there is no expectation to assert against: they are out of scope by construction. +// Snapshotting them is what stops "out of scope" from quietly becoming "unnoticed regression" — the same blind spot +// the JSON suite had with its i_ cases, where ten documents carrying ill-formed UTF-8 were accepted for months +// without a single test going red. +// +// Run with -update-golden after an intentional change and review the diff. +func checkRecordedGolden(t *testing.T, records map[string]string) { + t.Helper() + + golden := filepath.Join(currentDir(), "testdata", "conformance_recorded.golden") + + labels := make([]string, 0, len(records)) + for label := range records { + labels = append(labels, label) + } + sort.Strings(labels) + + var b strings.Builder + for _, label := range labels { + b.WriteString(label) + b.WriteString("\t") + b.WriteString(records[label]) + b.WriteString("\n") + } + got := b.String() + + if *updateGolden { + if err := os.WriteFile(golden, []byte(got), 0o600); err != nil { + t.Fatalf("cannot write %s: %v", golden, err) + } + t.Logf("updated %s (%d cases)", golden, len(labels)) + + return + } + + want, err := os.ReadFile(golden) + if err != nil { + t.Fatalf("cannot read %s (run with -update-golden to create it): %v", golden, err) + } + + if string(want) == got { + return + } + + t.Errorf("recorded behavior changed for out-of-scope cases.\n"+ + "If the change is intended, re-run with -update-golden and review the diff.\n%s", + diffRecorded(strings.Split(strings.TrimRight(string(want), "\n"), "\n"), + strings.Split(strings.TrimRight(got, "\n"), "\n"))) +} + +func diffRecorded(want, got []string) string { + index := func(lines []string) map[string]string { + m := make(map[string]string, len(lines)) + for _, line := range lines { + label, rest, _ := strings.Cut(line, "\t") + m[label] = rest + } + + return m + } + + wantBy, gotBy := index(want), index(got) + + var out []string + for label, w := range wantBy { + switch g, ok := gotBy[label]; { + case !ok: + out = append(out, " gone: "+label) + case g != w: + out = append(out, " changed: "+label+"\n was: "+w+"\n now: "+g) + } + } + for label := range gotBy { + if _, ok := wantBy[label]; !ok { + out = append(out, " new: "+label) + } + } + sort.Strings(out) + + return strings.Join(out, "\n") +} diff --git a/json/lexers/yaml-lexer/conformance_suite_test.go b/json/lexers/yaml-lexer/conformance_suite_test.go new file mode 100644 index 0000000..1aa5b67 --- /dev/null +++ b/json/lexers/yaml-lexer/conformance_suite_test.go @@ -0,0 +1,176 @@ +package lexer_test + +import ( + "os" + "path/filepath" + "regexp" + "runtime" + "sort" + "strings" + "testing" + + "github.com/goccy/go-yaml" +) + +// tabRun matches the suite's rendering of a hard tab: "»" preceded by any number of em-dashes used to show its +// width. Mirrors upstream's s/—*»/\t/g. +var tabRun = regexp.MustCompile("—*»") + +// Loader for the vendored YAML Test Suite (see testdata/yaml-test-suite/SOURCE.md). +// +// Each src/.yaml is a YAML sequence of one or more related cases. Only the first carries the descriptive fields; +// the rest inherit them, so a file is really "one scenario, several inputs". + +// suiteCase is one test case from the suite, with the suite's visible-character encoding already translated. +type suiteCase struct { + id string // the file name without extension, e.g. "2G84" + sub int // index within the file (0 when the file holds a single case) + name string + tags []string + + yaml string // the input document + json string // the equivalent JSON, empty when the case has none + // hasJSON distinguishes "no JSON equivalent" from "the JSON equivalent is the empty document". + hasJSON bool + fail bool // the document is invalid and must be rejected +} + +// label identifies a case in test output and in the expectation tables. +func (c suiteCase) label() string { + if c.sub == 0 { + return c.id + } + + return c.id + "/" + itoa(c.sub) +} + +// rawCase mirrors the on-disk shape. Every field is a pointer or a slice so an ABSENT field can be told from an empty +// one — the difference between "no JSON equivalent" and "the JSON equivalent is empty" decides which bucket a case +// lands in. +type rawCase struct { + Name *string `yaml:"name"` + Tags *string `yaml:"tags"` + YAML *string `yaml:"yaml"` + JSON *string `yaml:"json"` + Fail *bool `yaml:"fail"` +} + +// suiteUnescape translates the suite's visible stand-ins back into the characters they represent. +// +// This is the Go equivalent of upstream's bin/YAMLTestSuite.pm `sub unescape`, and it is not optional: several cases +// hinge on a trailing space or a hard tab that would otherwise be invisible (and would be stripped by an editor). +func suiteUnescape(s string) string { + s = strings.ReplaceAll(s, "␣", " ") + + // A hard tab, written as "»" preceded by ANY number of em-dashes for width. Upstream's rule is the regexp + // /—*»/ — matching a fixed set of widths instead silently leaves stray dashes behind for a wider run, which + // turns the fixture into a different (and usually invalid) document. + s = tabRun.ReplaceAllString(s, "\t") + + s = strings.ReplaceAll(s, "←", "\r") + s = strings.ReplaceAll(s, "⇔", "\uFEFF") + s = strings.ReplaceAll(s, "↵", "") // marks a trailing newline that is already there + + // "∎" marks an input with NO final newline: drop the mark and the newline the fixture had to end with. + if cut, ok := strings.CutSuffix(s, "∎\n"); ok { + s = cut + } + s = strings.TrimSuffix(s, "∎") + + return s +} + +// loadSuite reads every vendored case, applying the suite's inheritance rule and unescaping. +func loadSuite(t *testing.T) []suiteCase { + t.Helper() + + dir := filepath.Join(currentDir(), "testdata", "yaml-test-suite", "src") + entries, err := os.ReadDir(dir) + if err != nil { + t.Fatalf("cannot read the vendored YAML test suite: %v", err) + } + + var out []suiteCase + for _, e := range entries { + if e.IsDir() || !strings.HasSuffix(e.Name(), ".yaml") { + continue + } + + data, rerr := os.ReadFile(filepath.Join(dir, e.Name())) + if rerr != nil { + t.Fatalf("cannot read %s: %v", e.Name(), rerr) + } + + var raws []rawCase + if uerr := yaml.Unmarshal(data, &raws); uerr != nil { + t.Fatalf("cannot parse the suite fixture %s: %v", e.Name(), uerr) + } + + id := strings.TrimSuffix(e.Name(), ".yaml") + var name string + var tags []string + for i, raw := range raws { + // only the first case in a file carries the descriptive fields; the others inherit + if raw.Name != nil { + name = *raw.Name + } + if raw.Tags != nil { + tags = strings.Fields(*raw.Tags) + } + if raw.YAML == nil { + // a case with no input of its own is a description-only entry + continue + } + + sub := 0 + if len(raws) > 1 { + sub = i + } + + c := suiteCase{ + id: id, + sub: sub, + name: name, + tags: tags, + yaml: suiteUnescape(*raw.YAML), + fail: raw.Fail != nil && *raw.Fail, + } + if raw.JSON != nil { + c.json = suiteUnescape(*raw.JSON) + c.hasJSON = true + } + + out = append(out, c) + } + } + + sort.Slice(out, func(i, j int) bool { + if out[i].id != out[j].id { + return out[i].id < out[j].id + } + + return out[i].sub < out[j].sub + }) + + return out +} + +func currentDir() string { + _, filename, _, _ := runtime.Caller(1) //nolint:dogsled // only the file name is needed + + return filepath.Dir(filename) +} + +func itoa(i int) string { + if i == 0 { + return "0" + } + + var digits []byte + for i > 0 { + digits = append([]byte{byte('0' + i%10)}, digits...) + i /= 10 + } + + return string(digits) +} diff --git a/json/lexers/yaml-lexer/conformance_test.go b/json/lexers/yaml-lexer/conformance_test.go new file mode 100644 index 0000000..fd677a0 --- /dev/null +++ b/json/lexers/yaml-lexer/conformance_test.go @@ -0,0 +1,305 @@ +package lexer_test + +import ( + "bytes" + "fmt" + "sort" + "strings" + "testing" + + jsonlexer "github.com/go-openapi/core/json/lexers/default-lexer" + yamllexer "github.com/go-openapi/core/json/lexers/yaml-lexer" +) + +// Conformance of YL against the vendored YAML Test Suite (testdata/yaml-test-suite/SOURCE.md). +// +// What "conformant" means here is narrower than for a YAML processor, and deliberately so: YL exists to read YAML +// **as JSON**, so the suite's `json` field — the JSON its input is equivalent to — is exactly our expectation. A case +// is measured by lexing the YAML with YL and the expected JSON with the JSON lexer L, then comparing the two token +// streams. Anything the JSON data model cannot express is not a failure, it is out of scope. +// +// Three buckets, mirroring the JSON suite's y_/n_/i_ split: +// +// - `json` is ONE JSON document → MUST accept, and produce L's token stream for it. +// - `fail: true` → MUST reject. +// - anything else → no single-root JSON equivalent: behavior is only recorded. +// +// That last bucket is not a weasel: a multi-document YAML stream has a `json` field holding several values in +// sequence, and an empty document has an empty one. Neither is a JSON token stream, so there is nothing to compare +// against — only YL's accept/reject to record, which the golden snapshot pins so it cannot drift unnoticed. +// +// Known divergences are listed in conformanceXFail so the suite stays green and guards against NEW regressions. That +// list is the point of this test: it is the honest inventory of where YL stands. + +// conformanceModes are the ways a document is driven through YL. Both must agree with the expectation; a divergence +// between them is a bug regardless of what the suite says. +type conformanceMode struct { + name string + run func(t *testing.T, data []byte) ([]fzTok, error) +} + +func conformanceModes() []conformanceMode { + opts := []yamllexer.Option{ + // bound the walk so a pathological fixture fails the test instead of taking the process down + yamllexer.WithMaxContainerStack(512), + yamllexer.WithMaxTokens(1 << 20), + } + + return []conformanceMode{ + { + name: "YL/bytes", + run: func(t *testing.T, data []byte) ([]fzTok, error) { + return fzDrain(yamllexer.NewWithBytes(data, opts...), conformanceBudget(data), t) + }, + }, + { + name: "YL/reader", + run: func(t *testing.T, data []byte) ([]fzTok, error) { + return fzDrain( + yamllexer.New(bytes.NewReader(data), opts...), + conformanceBudget(data), + t, + ) + }, + }, + } +} + +func conformanceBudget(data []byte) int { return 16*len(data) + 4096 } + +// jsonTokens lexes the suite's expected JSON with the JSON lexer, giving the token stream YL must reproduce. +func jsonTokens(t *testing.T, want string) ([]fzTok, error) { + t.Helper() + + l := jsonlexer.NewWithBytes([]byte(want)) + var out []fzTok + for tok := range l.Tokens() { + out = append(out, fzRec(tok, l.IndentLevel())) + } + + return out, l.Err() +} + +func TestConformanceYAML(t *testing.T) { + cases := loadSuite(t) + xfail := conformanceXFail() + modes := conformanceModes() + + var ( + seenXFail = map[string]bool{} + // records holds the accept/reject verdict for every case we can only observe, snapshotted so a change in + // out-of-scope behavior shows up as a reviewable diff instead of silence + records = map[string]string{} + // failures by suite tag, so the report says which YAML FEATURES we do not cover rather than just how many + // cases are red + failsByTag = map[string]int{} + report []string + + passAccept, passReject, recordOnly int + xfailCount, unexpectedOK int + ) + + for _, c := range cases { + t.Run(c.label(), func(t *testing.T) { + data := []byte(c.yaml) + + // every mode must agree with itself before it can be compared to the suite + results := make([]conformanceVerdict, 0, len(modes)) + for _, m := range modes { + toks, err := m.run(t, data) + results = append(results, conformanceVerdict{mode: m.name, toks: toks, err: err}) + } + for _, r := range results[1:] { + if (r.err == nil) != (results[0].err == nil) { + t.Errorf("%s and %s disagree on accept/reject: %v vs %v", + results[0].mode, r.mode, results[0].err, r.err) + } + } + got := results[0] + + switch { + case c.fail: + if got.err == nil { + recordFailure(failsByTag, c) + reportf(&report, "%s ACCEPTED an invalid document (%s)", c.label(), c.name) + markXFail(t, c, xfail, seenXFail, &xfailCount, + "accepted a document the suite marks invalid") + + return + } + passReject++ + + case c.hasJSON: + want, jerr := jsonTokens(t, c.json) + if jerr != nil { + // Not one JSON document: an empty expectation (an empty YAML document) or several values in + // sequence (a multi-document stream). Our contract is a single JSON token stream, so there is + // no comparison to make — record the verdict instead. + recordOnly++ + recordVerdict(records, c, got.err) + + return + } + + switch { + case got.err != nil: + recordFailure(failsByTag, c) + reportf( + &report, + "%s REJECTED a valid document: %v (%s)", + c.label(), + got.err, + c.name, + ) + markXFail(t, c, xfail, seenXFail, &xfailCount, "rejected: "+got.err.Error()) + case !fzToksEqual(got.toks, want): + recordFailure(failsByTag, c) + reportf( + &report, + "%s token stream differs from the expected JSON (%s)", + c.label(), + c.name, + ) + markXFail( + t, + c, + xfail, + seenXFail, + &xfailCount, + "token stream differs:\n yaml: "+summarize( + got.toks, + )+"\n json: "+summarize( + want, + ), + ) + default: + passAccept++ + if xfail[c.label()] != "" { + seenXFail[c.label()] = true + unexpectedOK++ + t.Errorf( + "now conforms but is listed in conformanceXFail: remove %q", + c.label(), + ) + } + } + + default: + recordOnly++ + recordVerdict(records, c, got.err) + } + }) + } + + for label := range xfail { + if !seenXFail[label] { + t.Errorf("conformanceXFail lists %q but it was not found/exercised", label) + } + } + + sort.Strings(report) + t.Logf("=== divergences (%d) ===", len(report)) + for _, line := range report { + t.Logf(" %s", line) + } + + tags := make([]string, 0, len(failsByTag)) + for tag := range failsByTag { + tags = append(tags, tag) + } + sort.Slice(tags, func(i, j int) bool { + if failsByTag[tags[i]] != failsByTag[tags[j]] { + return failsByTag[tags[i]] > failsByTag[tags[j]] + } + + return tags[i] < tags[j] + }) + t.Logf("=== divergences by suite tag (which YAML features we do not cover) ===") + for _, tag := range tags { + t.Logf(" %-24s %d", tag, failsByTag[tag]) + } + + t.Logf( + "=== summary: accept+match=%d, reject=%d, record-only=%d, xfail=%d, unexpected-pass=%d, total=%d ===", + passAccept, + passReject, + recordOnly, + xfailCount, + unexpectedOK, + len(cases), + ) + + checkRecordedGolden(t, records) +} + +// recordVerdict notes what YL did with a case we cannot measure against a JSON token stream. +func recordVerdict(records map[string]string, c suiteCase, err error) { + verdict := "accept" + if err != nil { + verdict = "reject" + } + records[c.label()] = verdict + "\t" + c.name +} + +type conformanceVerdict struct { + mode string + toks []fzTok + err error +} + +func recordFailure(byTag map[string]int, c suiteCase) { + for _, tag := range c.tags { + byTag[tag]++ + } + if len(c.tags) == 0 { + byTag["(untagged)"]++ + } +} + +func reportf(report *[]string, format string, args ...any) { + *report = append(*report, fmt.Sprintf(format, args...)) +} + +// markXFail turns a divergence into a hard failure unless it is a known one. +func markXFail( + t *testing.T, + c suiteCase, + xfail map[string]string, + seen map[string]bool, + count *int, + detail string, +) { + t.Helper() + + if _, known := xfail[c.label()]; known { + seen[c.label()] = true + *count++ + t.Logf("xfail (known): %s — %s", c.label(), detail) + + return + } + + t.Errorf("conformance divergence: %s (%s)\n %s", c.label(), c.name, detail) +} + +// summarize renders a token stream compactly enough to read in a failure message. +func summarize(toks []fzTok) string { + const maximum = 12 + + parts := make([]string, 0, maximum) + for i, tk := range toks { + if i == maximum { + parts = append(parts, fmt.Sprintf("... (%d more)", len(toks)-maximum)) + + break + } + if tk.val != "" { + parts = append(parts, fmt.Sprintf("%v(%q)", tk.kind, tk.val)) + + continue + } + parts = append(parts, fmt.Sprint(tk.kind)) + } + + return strings.Join(parts, " ") +} diff --git a/json/lexers/yaml-lexer/conformance_xfail_test.go b/json/lexers/yaml-lexer/conformance_xfail_test.go new file mode 100644 index 0000000..36a2029 --- /dev/null +++ b/json/lexers/yaml-lexer/conformance_xfail_test.go @@ -0,0 +1,102 @@ +package lexer_test + +// conformanceXFail is the inventory of where YL stands against the YAML Test Suite: every case whose behavior +// diverges from the suite's expectation, mapped to the reason. +// +// Listed entries are reported as expected failures rather than hard ones, so the suite stays green and guards +// against NEW regressions. An entry that starts passing is reported as an error ("remove from xfail"), so the list +// cannot rot into an excuse. +// +// Baseline: 204/272 documents with a JSON equivalent are accepted AND lex to that JSON; 85/94 invalid documents are +// rejected. The 54 entries below group into five causes, in descending order of how much work they represent. +// +// See CONFORMANCE.md for the full analysis. +func conformanceXFail() map[string]string { + return map[string]string{ + // --------------------------------------------------------------------------------------------------- + // 1. Non-scalar mapping keys (23). YL requires an object key to be a scalar, since JSON keys are + // strings. But most of these are keys that RESOLVE to a string -- an alias (`*a : v`), an anchored or + // tagged scalar (`&a k : v`, `!!str k : v`) -- and the suite's own JSON expectation shows the resolved + // string as the key. Supporting them is a real feature gap, not a scope boundary. The genuinely + // out-of-scope ones are complex keys (`? [a, b] : c`), which JSON cannot express at all. + // --------------------------------------------------------------------------------------------------- + "26DV": "non-scalar mapping key", + "2SXE": "non-scalar mapping key", + "2XXW": "non-scalar mapping key", + "5WE3": "non-scalar mapping key", + "74H7": "non-scalar mapping key", + "7BMT": "non-scalar mapping key", + "7FWL": "non-scalar mapping key", + "7W2P": "non-scalar mapping key", + "A2M4": "non-scalar mapping key", + "CN3R": "non-scalar mapping key", + "CT4Q": "non-scalar mapping key", + "E76Z": "non-scalar mapping key", + "GH63": "non-scalar mapping key", + "HMQ5": "non-scalar mapping key", + "JTV5": "non-scalar mapping key", + "L94M": "non-scalar mapping key", + "RR7F": "non-scalar mapping key", + "S9E8": "non-scalar mapping key", + "U3XV": "non-scalar mapping key", + "WZ62": "non-scalar mapping key", + "X8DW": "non-scalar mapping key", + "ZH7C": "non-scalar mapping key", + "ZWK4": "non-scalar mapping key", + + // --------------------------------------------------------------------------------------------------- + // 2. Multiple documents (14). A JSON token stream has one root, so YL rejects a multi-document stream. + // The suite's json field for these holds several JSON values in sequence. Out of scope until the + // ND-JSON work lands (see the lexers README roadmap), at which point they become an NDJSON mode. + // --------------------------------------------------------------------------------------------------- + "27NA": "multiple documents", + "2LFX": "multiple documents", + "6CK3": "multiple documents", + "6LVF": "multiple documents", + "BEC7": "multiple documents", + "C4HZ": "multiple documents", + "CC74": "multiple documents", + "DK95/7": "multiple documents", + "MUS6/2": "multiple documents", + "P76L": "multiple documents", + "RTP8": "multiple documents", + "U3C3": "multiple documents", + "Z9M4": "multiple documents", + "ZYU8": "multiple documents", + + // --------------------------------------------------------------------------------------------------- + // 3. Invalid documents we ACCEPT (9). Real conformance bugs, and the most valuable group: we are more + // permissive than YAML allows, mostly around flow collections, comments and tabs. Inherited from the + // underlying goccy parser rather than introduced by our walk, so each needs to be confirmed against + // goccy upstream before we decide whether to pre-validate ourselves. + // --------------------------------------------------------------------------------------------------- + "9C9N": "we accept an invalid document", + "9JBA": "we accept an invalid document", + "CVW2": "we accept an invalid document", + "G5U8": "we accept an invalid document", + "QB6E": "we accept an invalid document", + "SU5Z": "we accept an invalid document", + "U99R": "we accept an invalid document", + "Y79Y/3": "we accept an invalid document", + "YJV2": "we accept an invalid document", + + // --------------------------------------------------------------------------------------------------- + // 4. Accepted, but the token stream differs from the expected JSON (5). Semantic divergences in how a + // scalar is resolved -- tags (!!binary, !!str), trailing whitespace, flow nodes. Each needs reading + // individually; they are the subtlest of the five groups because nothing errors. + // --------------------------------------------------------------------------------------------------- + "565N": "token stream differs from the expected JSON", + "L24T/1": "token stream differs from the expected JSON", + "LE5A": "token stream differs from the expected JSON", + "S4JQ": "token stream differs from the expected JSON", + "UGM3": "token stream differs from the expected JSON", + + // --------------------------------------------------------------------------------------------------- + // 5. Valid documents rejected by the underlying parser (3). goccy fails to parse these at all, so the + // fix is upstream (or a pre-pass of our own). + // --------------------------------------------------------------------------------------------------- + "4MUZ/2": "goccy fails to parse a valid document", + "DK95/4": "goccy fails to parse a valid document", + "VJP3/1": "goccy fails to parse a valid document", + } +} diff --git a/json/lexers/yaml-lexer/testdata/conformance_recorded.golden b/json/lexers/yaml-lexer/testdata/conformance_recorded.golden new file mode 100644 index 0000000..09fa185 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/conformance_recorded.golden @@ -0,0 +1,63 @@ +2G84/3 accept Literal modifers +2JQS reject Block Mapping with Missing Keys +35KP reject Tags for Root Objects +4ABK accept Flow Mapping Separate Values +4FJ6 reject Nested implicit complex keys +4MUZ/1 accept Flow mapping colon on line after key +5TYM reject Spec Example 6.21. Local Tag Prefix +6BFJ reject Mapping, key and flow sequence item anchors +6M2F reject Aliases in Explicit Block Mapping +6PBE reject Zero-indented sequences in explicit mapping keys +6WLZ reject Spec Example 6.18. Primary Tag Handle [1.3] +6XDY accept Two document start markers +6ZKB reject Spec Example 9.6. Stream +7Z25 reject Bare document after document end marker +8G76 accept Spec Example 6.10. Comment Lines +96NN/1 accept Leading tab content in literals +98YD accept Spec Example 5.5. Comment Indicator +9DXL reject Spec Example 9.6. Stream [1.3] +9KAX reject Various combinations of tags and anchors +9MMW reject Single Pair Implicit Entries +9WXW reject Spec Example 6.18. Primary Tag Handle +AVM7 accept Empty Stream +CFD4 reject Empty implicit key in single pair flow sequences +DFF7 reject Spec Example 7.16. Flow Mapping Entries +FH7J reject Tags on Empty Scalars +FRK4 reject Spec Example 7.3. Completely Empty Flow Nodes +HWV9 accept Document-end marker +JEF9/2 accept Trailing whitespace in streams +JHB9 reject Spec Example 2.7. Two Documents in a Stream +KK5P reject Various combinations of explicit block mappings +KSS4 reject Scalars on --- line +L383 reject Two scalar docs with trailing comments +LX3P reject Implicit Flow Mapping Key on one line +M2N8 reject Question mark edge cases +M2N8/1 reject Question mark edge cases +M5DY reject Spec Example 2.11. Mapping between Sequences +M7A3 reject Spec Example 9.3. Bare Documents +MUS6/3 reject Directive variants +MUS6/4 reject Directive variants +MUS6/5 reject Directive variants +MUS6/6 reject Directive variants +NHX8 reject Empty Lines at End of Document +NKF9 reject Empty keys in block and flow mapping +PUW8 reject Document start on last line +PW8X reject Anchors on Empty Scalars +Q9WF reject Spec Example 6.12. Separation Spaces +QT73 accept Comment and document-end marker +RZP5 reject Various Trailing Comments [1.3] +RZT7 reject Spec Example 2.28. Log File +S3PD reject Spec Example 8.18. Implicit Block Mapping Entries +SBG9 reject Flow Sequence in Flow Mapping +SM9W/1 reject Single character streams +U9NS reject Spec Example 2.8. Play by Play Feed from a Game +UKK6 reject Syntax character edge cases +UKK6/2 accept Syntax character edge cases +UT92 reject Spec Example 9.4. Explicit Documents +V9D5 reject Spec Example 8.19. Compact Block Mappings +W4TN reject Spec Example 9.5. Directives Documents +X38W reject Aliases in Flow Objects +XW4D reject Various Trailing Comments +ZYU8/1 reject Directive variants +ZYU8/2 reject Directive variants +ZYU8/3 reject Directive variants diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/LICENSE b/json/lexers/yaml-lexer/testdata/yaml-test-suite/LICENSE new file mode 100644 index 0000000..5059e95 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016-2020 Ingy döt Net + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/SOURCE.md b/json/lexers/yaml-lexer/testdata/yaml-test-suite/SOURCE.md new file mode 100644 index 0000000..fea6e2d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/SOURCE.md @@ -0,0 +1,51 @@ +# Vendored YAML Test Suite + +Fixtures vendored from the community **YAML Test Suite**: + +- Upstream: https://github.com/yaml/yaml-test-suite +- Vendored revision: `da267a5c` (2025-12-25, `main` branch) +- License: MIT (see `LICENSE` in this directory) + +## Layout + +`src/*.yaml` — each file is a YAML *sequence* of one or more related test cases +sharing an id (the file name). Only the first case in a file carries `name`, +`from` and `tags`; later cases inherit them. + +Fields we consume: + +- `yaml` — the input document (see "Special characters" below). +- `json` — the equivalent JSON. Present when the document has a JSON + representation; this is the expectation our lexer is measured against, since + `YL` deliberately trims YAML down to JSON semantics. +- `fail: true` — the document is invalid and must be rejected. + +Fields we ignore: `tree` (event stream), `dump`/`emit` (canonical YAML output), +`from`, `also`, `note` — they describe what a *YAML emitter* must do, not a +lexer reduced to the JSON data model. + +A case with neither `json` nor `fail` is valid YAML with no JSON equivalent +(non-string keys, tags, aliases to non-JSON structures, …). Those are +implementation-defined for us and only have their behavior recorded. + +## Special characters + +The suite writes otherwise-invisible characters as visible ones. They MUST be +translated before use (upstream `bin/YAMLTestSuite.pm`, `sub unescape`): + +| in the fixture | means | +|---|---| +| `␣` | a trailing space | +| `»`, optionally preceded by em-dashes (`—»`, `——»`, `———»`) | a tab | +| `←` | a carriage return | +| `⇔` | a byte order mark (U+FEFF) | +| `↵` | marks a trailing newline; removed | +| `∎` at end of input | the input has NO final newline; the mark and its newline are removed | + +Getting this wrong is silent: a case that hinges on a trailing space simply +becomes a different (usually valid) document. + +## Updating + +Re-copy `src/*.yaml` from a fresh checkout and bump the revision above. Do not +edit the fixtures in place. diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/229Q.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/229Q.yaml new file mode 100644 index 0000000..e4f92ce --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/229Q.yaml @@ -0,0 +1,56 @@ +--- +- name: Spec Example 2.4. Sequence of Mappings + from: http://www.yaml.org/spec/1.2/spec.html#id2760193 + tags: sequence mapping spec + yaml: | + - + name: Mark McGwire + hr: 65 + avg: 0.278 + - + name: Sammy Sosa + hr: 63 + avg: 0.288 + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL :name + =VAL :Mark McGwire + =VAL :hr + =VAL :65 + =VAL :avg + =VAL :0.278 + -MAP + +MAP + =VAL :name + =VAL :Sammy Sosa + =VAL :hr + =VAL :63 + =VAL :avg + =VAL :0.288 + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "name": "Mark McGwire", + "hr": 65, + "avg": 0.278 + }, + { + "name": "Sammy Sosa", + "hr": 63, + "avg": 0.288 + } + ] + dump: | + - name: Mark McGwire + hr: 65 + avg: 0.278 + - name: Sammy Sosa + hr: 63 + avg: 0.288 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/236B.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/236B.yaml new file mode 100644 index 0000000..2c82424 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/236B.yaml @@ -0,0 +1,15 @@ +--- +- name: Invalid value after mapping + from: '@perlpunk' + tags: error mapping + fail: true + yaml: | + foo: + bar + invalid + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :bar diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/26DV.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/26DV.yaml new file mode 100644 index 0000000..ada7c5f --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/26DV.yaml @@ -0,0 +1,82 @@ +--- +- name: Whitespace around colon in mappings + from: '@perlpunk' + tags: alias mapping whitespace + yaml: | + "top1" :␣ + "key1" : &alias1 scalar1 + 'top2' :␣ + 'key2' : &alias2 scalar2 + top3: &node3␣ + *alias1 : scalar3 + top4:␣ + *alias2 : scalar4 + top5 :␣␣␣␣ + scalar5 + top6:␣ + &anchor6 'key6' : scalar6 + tree: | + +STR + +DOC + +MAP + =VAL "top1 + +MAP + =VAL "key1 + =VAL &alias1 :scalar1 + -MAP + =VAL 'top2 + +MAP + =VAL 'key2 + =VAL &alias2 :scalar2 + -MAP + =VAL :top3 + +MAP &node3 + =ALI *alias1 + =VAL :scalar3 + -MAP + =VAL :top4 + +MAP + =ALI *alias2 + =VAL :scalar4 + -MAP + =VAL :top5 + =VAL :scalar5 + =VAL :top6 + +MAP + =VAL &anchor6 'key6 + =VAL :scalar6 + -MAP + -MAP + -DOC + -STR + json: | + { + "top1": { + "key1": "scalar1" + }, + "top2": { + "key2": "scalar2" + }, + "top3": { + "scalar1": "scalar3" + }, + "top4": { + "scalar2": "scalar4" + }, + "top5": "scalar5", + "top6": { + "key6": "scalar6" + } + } + dump: | + "top1": + "key1": &alias1 scalar1 + 'top2': + 'key2': &alias2 scalar2 + top3: &node3 + *alias1 : scalar3 + top4: + *alias2 : scalar4 + top5: scalar5 + top6: + &anchor6 'key6': scalar6 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/27NA.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/27NA.yaml new file mode 100644 index 0000000..8be2be4 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/27NA.yaml @@ -0,0 +1,17 @@ +--- +- name: Spec Example 5.9. Directive Indicator + from: http://www.yaml.org/spec/1.2/spec.html#id2774058 + tags: spec directive 1.3-err + yaml: | + %YAML 1.2 + --- text + tree: | + +STR + +DOC --- + =VAL :text + -DOC + -STR + json: | + "text" + dump: | + --- text diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2AUY.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2AUY.yaml new file mode 100644 index 0000000..e5ca696 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2AUY.yaml @@ -0,0 +1,32 @@ +--- +- name: Tags in Block Sequence + from: NimYAML tests + tags: tag sequence + yaml: |2 + - !!str a + - b + - !!int 42 + - d + tree: | + +STR + +DOC + +SEQ + =VAL :a + =VAL :b + =VAL :42 + =VAL :d + -SEQ + -DOC + -STR + json: | + [ + "a", + "b", + 42, + "d" + ] + dump: | + - !!str a + - b + - !!int 42 + - d diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2CMS.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2CMS.yaml new file mode 100644 index 0000000..4af7e53 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2CMS.yaml @@ -0,0 +1,12 @@ +--- +- name: Invalid mapping in plain multiline + from: '@perlpunk' + tags: error mapping + fail: true + yaml: | + this + is + invalid: x + tree: | + +STR + +DOC diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2EBW.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2EBW.yaml new file mode 100644 index 0000000..c7b0e16 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2EBW.yaml @@ -0,0 +1,41 @@ +--- +- name: Allowed characters in keys + from: '@perlpunk' + tags: mapping scalar + yaml: | + a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~: safe + ?foo: safe question mark + :foo: safe colon + -foo: safe dash + this is#not: a comment + tree: | + +STR + +DOC + +MAP + =VAL :a!"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~ + =VAL :safe + =VAL :?foo + =VAL :safe question mark + =VAL ::foo + =VAL :safe colon + =VAL :-foo + =VAL :safe dash + =VAL :this is#not + =VAL :a comment + -MAP + -DOC + -STR + json: | + { + "a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~": "safe", + "?foo": "safe question mark", + ":foo": "safe colon", + "-foo": "safe dash", + "this is#not": "a comment" + } + dump: | + a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~: safe + ?foo: safe question mark + :foo: safe colon + -foo: safe dash + this is#not: a comment diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2G84.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2G84.yaml new file mode 100644 index 0000000..7268c99 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2G84.yaml @@ -0,0 +1,38 @@ +--- +- name: Literal modifers + from: '@ingydotnet' + tags: literal scalar + fail: true + yaml: | + --- |0 + tree: | + +STR + +DOC --- + +- fail: true + yaml: | + --- |10 + +- yaml: | + --- |1-∎ + tree: | + +STR + +DOC --- + =VAL | + -DOC + -STR + json: | + "" + emit: | + --- "" + +- yaml: | + --- |1+∎ + tree: | + +STR + +DOC --- + =VAL | + -DOC + -STR + emit: | + --- "" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2JQS.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2JQS.yaml new file mode 100644 index 0000000..c1cd08e --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2JQS.yaml @@ -0,0 +1,18 @@ +--- +- name: Block Mapping with Missing Keys + from: NimYAML tests + tags: duplicate-key mapping empty-key + yaml: | + : a + : b + tree: | + +STR + +DOC + +MAP + =VAL : + =VAL :a + =VAL : + =VAL :b + -MAP + -DOC + -STR diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2LFX.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2LFX.yaml new file mode 100644 index 0000000..3d80b7d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2LFX.yaml @@ -0,0 +1,22 @@ +--- +- name: Spec Example 6.13. Reserved Directives [1.3] + from: 6LVF, modified for YAML 1.3 + tags: spec directive header double 1.3-mod + yaml: | + %FOO bar baz # Should be ignored + # with a warning. + --- + "foo" + tree: | + +STR + +DOC --- + =VAL "foo + -DOC + -STR + json: | + "foo" + dump: | + --- + "foo" + emit: | + --- "foo" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2SXE.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2SXE.yaml new file mode 100644 index 0000000..44dae4d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2SXE.yaml @@ -0,0 +1,27 @@ +--- +- name: Anchors With Colon in Name + from: Mailing List Discussion + tags: alias edge mapping 1.3-err + yaml: | + &a: key: &a value + foo: + *a: + tree: | + +STR + +DOC + +MAP + =VAL &a: :key + =VAL &a :value + =VAL :foo + =ALI *a: + -MAP + -DOC + -STR + json: | + { + "key": "value", + "foo": "key" + } + dump: | + &a: key: &a value + foo: *a: diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2XXW.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2XXW.yaml new file mode 100644 index 0000000..83cad46 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/2XXW.yaml @@ -0,0 +1,36 @@ +--- +- name: Spec Example 2.25. Unordered Sets + from: http://www.yaml.org/spec/1.2/spec.html#id2761758 + tags: spec mapping unknown-tag explicit-key + yaml: | + # Sets are represented as a + # Mapping where each key is + # associated with a null value + --- !!set + ? Mark McGwire + ? Sammy Sosa + ? Ken Griff + tree: | + +STR + +DOC --- + +MAP + =VAL :Mark McGwire + =VAL : + =VAL :Sammy Sosa + =VAL : + =VAL :Ken Griff + =VAL : + -MAP + -DOC + -STR + json: | + { + "Mark McGwire": null, + "Sammy Sosa": null, + "Ken Griff": null + } + dump: | + --- !!set + Mark McGwire: + Sammy Sosa: + Ken Griff: diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/33X3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/33X3.yaml new file mode 100644 index 0000000..6068f92 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/33X3.yaml @@ -0,0 +1,30 @@ +--- +- name: Three explicit integers in a block sequence + from: IRC + tags: sequence tag + yaml: | + --- + - !!int 1 + - !!int -2 + - !!int 33 + tree: | + +STR + +DOC --- + +SEQ + =VAL :1 + =VAL :-2 + =VAL :33 + -SEQ + -DOC + -STR + json: | + [ + 1, + -2, + 33 + ] + dump: | + --- + - !!int 1 + - !!int -2 + - !!int 33 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/35KP.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/35KP.yaml new file mode 100644 index 0000000..f89db13 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/35KP.yaml @@ -0,0 +1,44 @@ +--- +- name: Tags for Root Objects + from: NimYAML tests + tags: explicit-key header mapping tag + yaml: | + --- !!map + ? a + : b + --- !!seq + - !!str c + --- !!str + d + e + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL :b + -MAP + -DOC + +DOC --- + +SEQ + =VAL :c + -SEQ + -DOC + +DOC --- + =VAL :d e + -DOC + -STR + json: | + { + "a": "b" + } + [ + "c" + ] + "d e" + dump: | + --- !!map + a: b + --- !!seq + - !!str c + --- !!str d e diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/36F6.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/36F6.yaml new file mode 100644 index 0000000..c4fe0b1 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/36F6.yaml @@ -0,0 +1,28 @@ +--- +- name: Multiline plain scalar with empty line + from: '@perlpunk' + tags: mapping scalar + yaml: | + --- + plain: a + b + + c + tree: | + +STR + +DOC --- + +MAP + =VAL :plain + =VAL :a b\nc + -MAP + -DOC + -STR + json: | + { + "plain": "a b\nc" + } + dump: | + --- + plain: 'a b + + c' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3ALJ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3ALJ.yaml new file mode 100644 index 0000000..7c2044c --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3ALJ.yaml @@ -0,0 +1,28 @@ +--- +- name: Block Sequence in Block Sequence + from: NimYAML tests + tags: sequence + yaml: | + - - s1_i1 + - s1_i2 + - s2 + tree: | + +STR + +DOC + +SEQ + +SEQ + =VAL :s1_i1 + =VAL :s1_i2 + -SEQ + =VAL :s2 + -SEQ + -DOC + -STR + json: | + [ + [ + "s1_i1", + "s1_i2" + ], + "s2" + ] diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3GZX.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3GZX.yaml new file mode 100644 index 0000000..d5e68c2 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3GZX.yaml @@ -0,0 +1,31 @@ +--- +- name: Spec Example 7.1. Alias Nodes + from: http://www.yaml.org/spec/1.2/spec.html#id2786448 + tags: mapping spec alias + yaml: | + First occurrence: &anchor Foo + Second occurrence: *anchor + Override anchor: &anchor Bar + Reuse anchor: *anchor + tree: | + +STR + +DOC + +MAP + =VAL :First occurrence + =VAL &anchor :Foo + =VAL :Second occurrence + =ALI *anchor + =VAL :Override anchor + =VAL &anchor :Bar + =VAL :Reuse anchor + =ALI *anchor + -MAP + -DOC + -STR + json: | + { + "First occurrence": "Foo", + "Second occurrence": "Foo", + "Override anchor": "Bar", + "Reuse anchor": "Bar" + } diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3HFZ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3HFZ.yaml new file mode 100644 index 0000000..f83d768 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3HFZ.yaml @@ -0,0 +1,17 @@ +--- +- name: Invalid content after document end marker + from: '@perlpunk' + tags: error footer + fail: true + yaml: | + --- + key: value + ... invalid + tree: | + +STR + +DOC --- + +MAP + =VAL :key + =VAL :value + -MAP + -DOC ... diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3MYT.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3MYT.yaml new file mode 100644 index 0000000..85644c6 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3MYT.yaml @@ -0,0 +1,18 @@ +--- +- name: Plain Scalar looking like key, comment, anchor and tag + from: https://gist.github.com/anonymous/a98d50ce42a59b1e999552bea7a31f57 via @ingydotnet + tags: scalar + yaml: | + --- + k:#foo + &a !t s + tree: | + +STR + +DOC --- + =VAL :k:#foo &a !t s + -DOC + -STR + json: | + "k:#foo &a !t s" + dump: | + --- k:#foo &a !t s diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3R3P.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3R3P.yaml new file mode 100644 index 0000000..df3fef9 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3R3P.yaml @@ -0,0 +1,22 @@ +--- +- name: Single block sequence with anchor + from: '@perlpunk' + tags: anchor sequence + yaml: | + &sequence + - a + tree: | + +STR + +DOC + +SEQ &sequence + =VAL :a + -SEQ + -DOC + -STR + json: | + [ + "a" + ] + dump: | + &sequence + - a diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3RLN.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3RLN.yaml new file mode 100644 index 0000000..14de69a --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3RLN.yaml @@ -0,0 +1,87 @@ +--- +- name: Leading tabs in double quoted + from: '@ingydotnet' + tags: double whitespace + yaml: | + "1 leading + \ttab" + tree: | + +STR + +DOC + =VAL "1 leading \ttab + -DOC + -STR + json: | + "1 leading \ttab" + emit: | + "1 leading \ttab" + +- yaml: | + "2 leading + \———»tab" + tree: | + +STR + +DOC + =VAL "2 leading \ttab + -DOC + -STR + json: | + "2 leading \ttab" + emit: | + "2 leading \ttab" + +- yaml: | + "3 leading + ————»tab" + tree: | + +STR + +DOC + =VAL "3 leading tab + -DOC + -STR + json: | + "3 leading tab" + emit: | + "3 leading tab" + +- yaml: | + "4 leading + \t tab" + tree: | + +STR + +DOC + =VAL "4 leading \t tab + -DOC + -STR + json: | + "4 leading \t tab" + emit: | + "4 leading \t tab" + +- yaml: | + "5 leading + \———» tab" + tree: | + +STR + +DOC + =VAL "5 leading \t tab + -DOC + -STR + json: | + "5 leading \t tab" + emit: | + "5 leading \t tab" + +- yaml: | + "6 leading + ————» tab" + tree: | + +STR + +DOC + =VAL "6 leading tab + -DOC + -STR + json: | + "6 leading tab" + emit: | + "6 leading tab" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3UYS.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3UYS.yaml new file mode 100644 index 0000000..781181c --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/3UYS.yaml @@ -0,0 +1,21 @@ +--- +- name: Escaped slash in double quotes + from: '@perlpunk' + tags: double + yaml: | + escaped slash: "a\/b" + tree: | + +STR + +DOC + +MAP + =VAL :escaped slash + =VAL "a/b + -MAP + -DOC + -STR + json: | + { + "escaped slash": "a/b" + } + dump: | + escaped slash: "a/b" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4ABK.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4ABK.yaml new file mode 100644 index 0000000..8c0ed87 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4ABK.yaml @@ -0,0 +1,27 @@ +--- +- name: Flow Mapping Separate Values + from: http://www.yaml.org/spec/1.2/spec.html#id2791704 + tags: flow mapping + yaml: | + { + unquoted : "separate", + http://foo.com, + omitted value:, + } + tree: | + +STR + +DOC + +MAP {} + =VAL :unquoted + =VAL "separate + =VAL :http://foo.com + =VAL : + =VAL :omitted value + =VAL : + -MAP + -DOC + -STR + dump: | + unquoted: "separate" + http://foo.com: null + omitted value: null diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4CQQ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4CQQ.yaml new file mode 100644 index 0000000..3af04ed --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4CQQ.yaml @@ -0,0 +1,30 @@ +--- +- name: Spec Example 2.18. Multi-line Flow Scalars + from: http://www.yaml.org/spec/1.2/spec.html#id2761268 + tags: spec scalar + yaml: | + plain: + This unquoted scalar + spans many lines. + + quoted: "So does this + quoted scalar.\n" + tree: | + +STR + +DOC + +MAP + =VAL :plain + =VAL :This unquoted scalar spans many lines. + =VAL :quoted + =VAL "So does this quoted scalar.\n + -MAP + -DOC + -STR + json: | + { + "plain": "This unquoted scalar spans many lines.", + "quoted": "So does this quoted scalar.\n" + } + dump: | + plain: This unquoted scalar spans many lines. + quoted: "So does this quoted scalar.\n" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4EJS.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4EJS.yaml new file mode 100644 index 0000000..16b8643 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4EJS.yaml @@ -0,0 +1,15 @@ +--- +- name: Invalid tabs as indendation in a mapping + from: https://github.com/nodeca/js-yaml/issues/80 + tags: error mapping whitespace + fail: true + yaml: | + --- + a: + ———»b: + ———»———»c: value + tree: | + +STR + +DOC --- + +MAP + =VAL :a diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4FJ6.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4FJ6.yaml new file mode 100644 index 0000000..dee37a8 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4FJ6.yaml @@ -0,0 +1,42 @@ +--- +- name: Nested implicit complex keys + from: '@perlpunk' + tags: complex-key flow mapping sequence + yaml: | + --- + [ + [ a, [ [[b,c]]: d, e]]: 23 + ] + tree: | + +STR + +DOC --- + +SEQ [] + +MAP {} + +SEQ [] + =VAL :a + +SEQ [] + +MAP {} + +SEQ [] + +SEQ [] + =VAL :b + =VAL :c + -SEQ + -SEQ + =VAL :d + -MAP + =VAL :e + -SEQ + -SEQ + =VAL :23 + -MAP + -SEQ + -DOC + -STR + dump: | + --- + - ? - a + - - ? - - b + - c + : d + - e + : 23 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4GC6.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4GC6.yaml new file mode 100644 index 0000000..732618b --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4GC6.yaml @@ -0,0 +1,14 @@ +--- +- name: Spec Example 7.7. Single Quoted Characters + from: http://www.yaml.org/spec/1.2/spec.html#id2788307 + tags: spec scalar 1.3-err + yaml: | + 'here''s to "quotes"' + tree: | + +STR + +DOC + =VAL 'here's to "quotes" + -DOC + -STR + json: | + "here's to \"quotes\"" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4H7K.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4H7K.yaml new file mode 100644 index 0000000..66228b2 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4H7K.yaml @@ -0,0 +1,17 @@ +--- +- name: Flow sequence with invalid extra closing bracket + from: '@perlpunk' + tags: error flow sequence + fail: true + yaml: | + --- + [ a, b, c ] ] + tree: | + +STR + +DOC --- + +SEQ + =VAL :a + =VAL :b + =VAL :c + -SEQ + -DOC diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4HVU.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4HVU.yaml new file mode 100644 index 0000000..dce4ae0 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4HVU.yaml @@ -0,0 +1,19 @@ +--- +- name: Wrong indendation in Sequence + from: '@perlpunk' + tags: error sequence indent + fail: true + yaml: | + key: + - ok + - also ok + - wrong + tree: | + +STR + +DOC + +MAP + =VAL :key + +SEQ + =VAL :ok + =VAL :also ok + -SEQ diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4JVG.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4JVG.yaml new file mode 100644 index 0000000..69fff4f --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4JVG.yaml @@ -0,0 +1,20 @@ +--- +- name: Scalar value with two anchors + from: '@perlpunk' + tags: anchor error mapping + fail: true + yaml: | + top1: &node1 + &k1 key1: val1 + top2: &node2 + &v2 val2 + tree: | + +STR + +DOC + +MAP + =VAL :top1 + +MAP &node1 + =VAL &k1 :key1 + =VAL :val1 + -MAP + =VAL :top2 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4MUZ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4MUZ.yaml new file mode 100644 index 0000000..758db65 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4MUZ.yaml @@ -0,0 +1,56 @@ +--- +- name: Flow mapping colon on line after key + from: '@ingydotnet' + tags: flow mapping + yaml: | + {"foo" + : "bar"} + tree: | + +STR + +DOC + +MAP {} + =VAL "foo + =VAL "bar + -MAP + -DOC + -STR + json: | + { + "foo": "bar" + } + emit: | + "foo": "bar" + +- yaml: | + {"foo" + : bar} + tree: | + +STR + +DOC + +MAP {} + =VAL "foo + =VAL :bar + -MAP + -DOC + -STR + emit: | + "foo": bar + +- yaml: | + {foo + : bar} + tree: | + +STR + +DOC + +MAP {} + =VAL :foo + =VAL :bar + -MAP + -DOC + -STR + json: | + { + "foo": "bar" + } + emit: | + foo: bar diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4Q9F.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4Q9F.yaml new file mode 100644 index 0000000..a0f663a --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4Q9F.yaml @@ -0,0 +1,29 @@ +--- +- name: Folded Block Scalar [1.3] + from: TS54, modified for YAML 1.3 + tags: folded scalar 1.3-mod whitespace + yaml: | + --- > + ab + cd + ␣ + ef + + + gh + tree: | + +STR + +DOC --- + =VAL >ab cd\nef\n\ngh\n + -DOC + -STR + json: | + "ab cd\nef\n\ngh\n" + dump: | + --- > + ab cd + + ef + + + gh diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4QFQ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4QFQ.yaml new file mode 100644 index 0000000..5fac10d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4QFQ.yaml @@ -0,0 +1,44 @@ +--- +- name: Spec Example 8.2. Block Indentation Indicator [1.3] + from: R4YG, modified for YAML 1.3 + tags: spec literal folded scalar libyaml-err 1.3-mod whitespace + yaml: | + - | + detected + - > + ␣ + ␣␣ + # detected + - |1 + explicit + - > + detected + tree: | + +STR + +DOC + +SEQ + =VAL |detected\n + =VAL >\n\n# detected\n + =VAL | explicit\n + =VAL >detected\n + -SEQ + -DOC + -STR + json: | + [ + "detected\n", + "\n\n# detected\n", + " explicit\n", + "detected\n" + ] + emit: | + - | + detected + - >2 + + + # detected + - |2 + explicit + - > + detected diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4RWC.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4RWC.yaml new file mode 100644 index 0000000..4e800b5 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4RWC.yaml @@ -0,0 +1,27 @@ +--- +- name: Trailing spaces after flow collection + tags: flow whitespace + from: '@ingydotnet' + yaml: |2 + [1, 2, 3]␣␣ + ␣␣∎ + tree: | + +STR + +DOC + +SEQ [] + =VAL :1 + =VAL :2 + =VAL :3 + -SEQ + -DOC + -STR + json: | + [ + 1, + 2, + 3 + ] + dump: | + - 1 + - 2 + - 3 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4UYU.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4UYU.yaml new file mode 100644 index 0000000..6b28d53 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4UYU.yaml @@ -0,0 +1,14 @@ +--- +- name: Colon in Double Quoted String + from: NimYAML tests + tags: mapping scalar 1.3-err + yaml: | + "foo: bar\": baz" + tree: | + +STR + +DOC + =VAL "foo: bar": baz + -DOC + -STR + json: | + "foo: bar\": baz" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4V8U.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4V8U.yaml new file mode 100644 index 0000000..26561ec --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4V8U.yaml @@ -0,0 +1,17 @@ +--- +- name: Plain scalar with backslashes + from: '@perlpunk' + tags: scalar + yaml: | + --- + plain\value\with\backslashes + tree: | + +STR + +DOC --- + =VAL :plain\\value\\with\\backslashes + -DOC + -STR + json: | + "plain\\value\\with\\backslashes" + dump: | + --- plain\value\with\backslashes diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4WA9.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4WA9.yaml new file mode 100644 index 0000000..4f9be4a --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4WA9.yaml @@ -0,0 +1,40 @@ +--- +- name: Literal scalars + from: '@ingydotnet' + tags: indent literal + yaml: | + - aaa: |2 + xxx + bbb: | + xxx + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL :aaa + =VAL |xxx\n + =VAL :bbb + =VAL |xxx\n + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "aaa" : "xxx\n", + "bbb" : "xxx\n" + } + ] + dump: | + --- + - aaa: | + xxx + bbb: | + xxx + emit: | + - aaa: | + xxx + bbb: | + xxx diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4ZYM.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4ZYM.yaml new file mode 100644 index 0000000..c57907e --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/4ZYM.yaml @@ -0,0 +1,41 @@ +--- +- name: Spec Example 6.4. Line Prefixes + from: http://www.yaml.org/spec/1.2/spec.html#id2778720 + tags: spec scalar literal double upto-1.2 whitespace + yaml: | + plain: text + lines + quoted: "text + —»lines" + block: | + text + »lines + tree: | + +STR + +DOC + +MAP + =VAL :plain + =VAL :text lines + =VAL :quoted + =VAL "text lines + =VAL :block + =VAL |text\n \tlines\n + -MAP + -DOC + -STR + json: | + { + "plain": "text lines", + "quoted": "text lines", + "block": "text\n \tlines\n" + } + dump: | + plain: text lines + quoted: "text lines" + block: "text\n \tlines\n" + emit: | + plain: text lines + quoted: "text lines" + block: | + text + »lines diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/52DL.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/52DL.yaml new file mode 100644 index 0000000..42749d3 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/52DL.yaml @@ -0,0 +1,17 @@ +--- +- name: Explicit Non-Specific Tag [1.3] + from: 8MK2, modified for YAML 1.3 + tags: tag 1.3-mod + yaml: | + --- + ! a + tree: | + +STR + +DOC --- + =VAL :a + -DOC + -STR + json: | + "a" + dump: | + --- ! a diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/54T7.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/54T7.yaml new file mode 100644 index 0000000..d08227d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/54T7.yaml @@ -0,0 +1,25 @@ +--- +- name: Flow Mapping + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml + tags: flow mapping + yaml: | + {foo: you, bar: far} + tree: | + +STR + +DOC + +MAP {} + =VAL :foo + =VAL :you + =VAL :bar + =VAL :far + -MAP + -DOC + -STR + json: | + { + "foo": "you", + "bar": "far" + } + dump: | + foo: you + bar: far diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/55WF.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/55WF.yaml new file mode 100644 index 0000000..88d84e5 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/55WF.yaml @@ -0,0 +1,11 @@ +--- +- name: Invalid escape in double quoted string + from: '@perlpunk' + tags: error double + fail: true + yaml: | + --- + "\." + tree: | + +STR + +DOC --- diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/565N.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/565N.yaml new file mode 100644 index 0000000..d2986b4 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/565N.yaml @@ -0,0 +1,36 @@ +--- +- name: Construct Binary + from: https://github.com/yaml/pyyaml/blob/master/tests/data/construct-binary-py2.data + tags: tag unknown-tag + yaml: | + canonical: !!binary "\ + R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\ + OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\ + +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\ + AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=" + generic: !!binary | + R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5 + OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+ + +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC + AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs= + description: + The binary value above is a tiny arrow encoded as a gif image. + tree: | + +STR + +DOC + +MAP + =VAL :canonical + =VAL "R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLCAgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs= + =VAL :generic + =VAL |R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\nOTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\n+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\nAgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=\n + =VAL :description + =VAL :The binary value above is a tiny arrow encoded as a gif image. + -MAP + -DOC + -STR + json: | + { + "canonical": "R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLCAgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=", + "generic": "R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\nOTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\n+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\nAgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=\n", + "description": "The binary value above is a tiny arrow encoded as a gif image." + } diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/57H4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/57H4.yaml new file mode 100644 index 0000000..d16f095 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/57H4.yaml @@ -0,0 +1,49 @@ +--- +- name: Spec Example 8.22. Block Collection Nodes + from: http://www.yaml.org/spec/1.2/spec.html#id2800008 + tags: sequence mapping tag + yaml: | + sequence: !!seq + - entry + - !!seq + - nested + mapping: !!map + foo: bar + tree: | + +STR + +DOC + +MAP + =VAL :sequence + +SEQ + =VAL :entry + +SEQ + =VAL :nested + -SEQ + -SEQ + =VAL :mapping + +MAP + =VAL :foo + =VAL :bar + -MAP + -MAP + -DOC + -STR + json: | + { + "sequence": [ + "entry", + [ + "nested" + ] + ], + "mapping": { + "foo": "bar" + } + } + dump: | + sequence: !!seq + - entry + - !!seq + - nested + mapping: !!map + foo: bar diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/58MP.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/58MP.yaml new file mode 100644 index 0000000..485e5ae --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/58MP.yaml @@ -0,0 +1,21 @@ +--- +- name: Flow mapping edge cases + from: '@ingydotnet' + tags: edge flow mapping + yaml: | + {x: :x} + tree: | + +STR + +DOC + +MAP {} + =VAL :x + =VAL ::x + -MAP + -DOC + -STR + json: | + { + "x": ":x" + } + dump: | + x: :x diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5BVJ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5BVJ.yaml new file mode 100644 index 0000000..1aebbce --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5BVJ.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 5.7. Block Scalar Indicators + from: http://www.yaml.org/spec/1.2/spec.html#id2773653 + tags: spec literal folded scalar + yaml: | + literal: | + some + text + folded: > + some + text + tree: | + +STR + +DOC + +MAP + =VAL :literal + =VAL |some\ntext\n + =VAL :folded + =VAL >some text\n + -MAP + -DOC + -STR + json: | + { + "literal": "some\ntext\n", + "folded": "some text\n" + } + dump: | + literal: | + some + text + folded: > + some text diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5C5M.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5C5M.yaml new file mode 100644 index 0000000..d9f7803 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5C5M.yaml @@ -0,0 +1,42 @@ +--- +- name: Spec Example 7.15. Flow Mappings + from: http://www.yaml.org/spec/1.2/spec.html#id2791018 + tags: spec flow mapping + yaml: | + - { one : two , three: four , } + - {five: six,seven : eight} + tree: | + +STR + +DOC + +SEQ + +MAP {} + =VAL :one + =VAL :two + =VAL :three + =VAL :four + -MAP + +MAP {} + =VAL :five + =VAL :six + =VAL :seven + =VAL :eight + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "one": "two", + "three": "four" + }, + { + "five": "six", + "seven": "eight" + } + ] + dump: | + - one: two + three: four + - five: six + seven: eight diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5GBF.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5GBF.yaml new file mode 100644 index 0000000..98cd36e --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5GBF.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 6.5. Empty Lines + from: http://www.yaml.org/spec/1.2/spec.html#id2778971 + tags: double literal spec scalar upto-1.2 whitespace + yaml: | + Folding: + "Empty line + » + as a line feed" + Chomping: | + Clipped empty lines + ␣ + ↵ + tree: | + +STR + +DOC + +MAP + =VAL :Folding + =VAL "Empty line\nas a line feed + =VAL :Chomping + =VAL |Clipped empty lines\n + -MAP + -DOC + -STR + json: | + { + "Folding": "Empty line\nas a line feed", + "Chomping": "Clipped empty lines\n" + } + dump: | + Folding: "Empty line\nas a line feed" + Chomping: | + Clipped empty lines diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5KJE.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5KJE.yaml new file mode 100644 index 0000000..1239c55 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5KJE.yaml @@ -0,0 +1,38 @@ +--- +- name: Spec Example 7.13. Flow Sequence + from: http://www.yaml.org/spec/1.2/spec.html#id2790506 + tags: spec flow sequence + yaml: | + - [ one, two, ] + - [three ,four] + tree: | + +STR + +DOC + +SEQ + +SEQ [] + =VAL :one + =VAL :two + -SEQ + +SEQ [] + =VAL :three + =VAL :four + -SEQ + -SEQ + -DOC + -STR + json: | + [ + [ + "one", + "two" + ], + [ + "three", + "four" + ] + ] + dump: | + - - one + - two + - - three + - four diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5LLU.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5LLU.yaml new file mode 100644 index 0000000..46685ff --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5LLU.yaml @@ -0,0 +1,16 @@ +--- +- name: Block scalar with wrong indented line after spaces only + from: '@perlpunk' + tags: error folded whitespace + fail: true + yaml: | + block scalar: > + ␣ + ␣␣ + ␣␣␣ + invalid + tree: | + +STR + +DOC + +MAP + =VAL :block scalar diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5MUD.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5MUD.yaml new file mode 100644 index 0000000..b327acf --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5MUD.yaml @@ -0,0 +1,24 @@ +--- +- name: Colon and adjacent value on next line + from: '@perlpunk' + tags: double flow mapping + yaml: | + --- + { "foo" + :bar } + tree: | + +STR + +DOC --- + +MAP {} + =VAL "foo + =VAL :bar + -MAP + -DOC + -STR + json: | + { + "foo": "bar" + } + dump: | + --- + "foo": bar diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5NYZ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5NYZ.yaml new file mode 100644 index 0000000..7e09408 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5NYZ.yaml @@ -0,0 +1,22 @@ +--- +- name: Spec Example 6.9. Separated Comment + from: http://www.yaml.org/spec/1.2/spec.html#id2780342 + tags: mapping spec comment + yaml: | + key: # Comment + value + tree: | + +STR + +DOC + +MAP + =VAL :key + =VAL :value + -MAP + -DOC + -STR + json: | + { + "key": "value" + } + dump: | + key: value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5T43.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5T43.yaml new file mode 100644 index 0000000..5b6ceee --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5T43.yaml @@ -0,0 +1,37 @@ +--- +- name: Colon at the beginning of adjacent flow scalar + from: '@perlpunk' + tags: flow mapping scalar + yaml: | + - { "key":value } + - { "key"::value } + tree: | + +STR + +DOC + +SEQ + +MAP {} + =VAL "key + =VAL :value + -MAP + +MAP {} + =VAL "key + =VAL ::value + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "key": "value" + }, + { + "key": ":value" + } + ] + dump: | + - key: value + - key: :value + emit: | + - "key": value + - "key": :value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5TRB.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5TRB.yaml new file mode 100644 index 0000000..3cf6470 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5TRB.yaml @@ -0,0 +1,13 @@ +--- +- name: Invalid document-start marker in doublequoted tring + from: '@perlpunk' + tags: header double error + fail: true + yaml: | + --- + " + --- + " + tree: | + +STR + +DOC --- diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5TYM.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5TYM.yaml new file mode 100644 index 0000000..be41933 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5TYM.yaml @@ -0,0 +1,24 @@ +--- +- name: Spec Example 6.21. Local Tag Prefix + from: http://www.yaml.org/spec/1.2/spec.html#id2783499 + tags: local-tag spec directive tag + yaml: | + %TAG !m! !my- + --- # Bulb here + !m!light fluorescent + ... + %TAG !m! !my- + --- # Color here + !m!light green + tree: | + +STR + +DOC --- + =VAL :fluorescent + -DOC ... + +DOC --- + =VAL :green + -DOC + -STR + json: | + "fluorescent" + "green" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5U3A.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5U3A.yaml new file mode 100644 index 0000000..c7642cc --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5U3A.yaml @@ -0,0 +1,13 @@ +--- +- name: Sequence on same Line as Mapping Key + from: '@perlpunk' + tags: error sequence mapping + fail: true + yaml: | + key: - a + - b + tree: | + +STR + +DOC + +MAP + =VAL :key diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5WE3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5WE3.yaml new file mode 100644 index 0000000..95b643b --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/5WE3.yaml @@ -0,0 +1,38 @@ +--- +- name: Spec Example 8.17. Explicit Block Mapping Entries + from: http://www.yaml.org/spec/1.2/spec.html#id2798425 + tags: explicit-key spec mapping comment literal sequence + yaml: | + ? explicit key # Empty value + ? | + block key + : - one # Explicit compact + - two # block value + tree: | + +STR + +DOC + +MAP + =VAL :explicit key + =VAL : + =VAL |block key\n + +SEQ + =VAL :one + =VAL :two + -SEQ + -MAP + -DOC + -STR + json: | + { + "explicit key": null, + "block key\n": [ + "one", + "two" + ] + } + dump: | + explicit key: + ? | + block key + : - one + - two diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/62EZ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/62EZ.yaml new file mode 100644 index 0000000..b517ecf --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/62EZ.yaml @@ -0,0 +1,17 @@ +--- +- name: Invalid block mapping key on same line as previous key + from: '@perlpunk' + tags: error flow mapping + fail: true + yaml: | + --- + x: { y: z }in: valid + tree: | + +STR + +DOC --- + +MAP + =VAL :x + +MAP {} + =VAL :y + =VAL :z + -MAP diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/652Z.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/652Z.yaml new file mode 100644 index 0000000..afdc01b --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/652Z.yaml @@ -0,0 +1,31 @@ +--- +- name: Question mark at start of flow key + from: '@ingydotnet' + tags: flow + yaml: | + { ?foo: bar, + bar: 42 + } + tree: | + +STR + +DOC + +MAP {} + =VAL :?foo + =VAL :bar + =VAL :bar + =VAL :42 + -MAP + -DOC + -STR + json: | + { + "?foo" : "bar", + "bar" : 42 + } + dump: | + --- + ?foo: bar + bar: 42 + emit: | + ?foo: bar + bar: 42 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/65WH.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/65WH.yaml new file mode 100644 index 0000000..be1c765 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/65WH.yaml @@ -0,0 +1,18 @@ +--- +- name: Single Entry Block Sequence + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/sequence.tml + tags: sequence + yaml: | + - foo + tree: | + +STR + +DOC + +SEQ + =VAL :foo + -SEQ + -DOC + -STR + json: | + [ + "foo" + ] diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6BCT.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6BCT.yaml new file mode 100644 index 0000000..7a0bb52 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6BCT.yaml @@ -0,0 +1,37 @@ +--- +- name: Spec Example 6.3. Separation Spaces + from: http://www.yaml.org/spec/1.2/spec.html#id2778394 + tags: spec libyaml-err sequence whitespace upto-1.2 + yaml: | + - foo:—» bar + - - baz + -»baz + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL :foo + =VAL :bar + -MAP + +SEQ + =VAL :baz + =VAL :baz + -SEQ + -SEQ + -DOC + -STR + json: | + [ + { + "foo": "bar" + }, + [ + "baz", + "baz" + ] + ] + dump: | + - foo: bar + - - baz + - baz diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6BFJ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6BFJ.yaml new file mode 100644 index 0000000..4c084d3 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6BFJ.yaml @@ -0,0 +1,28 @@ +--- +- name: Mapping, key and flow sequence item anchors + from: '@perlpunk' + tags: anchor complex-key flow mapping sequence + yaml: | + --- + &mapping + &key [ &item a, b, c ]: value + tree: | + +STR + +DOC --- + +MAP &mapping + +SEQ [] &key + =VAL &item :a + =VAL :b + =VAL :c + -SEQ + =VAL :value + -MAP + -DOC + -STR + dump: | + --- &mapping + ? &key + - &item a + - b + - c + : value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6CA3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6CA3.yaml new file mode 100644 index 0000000..b16e19c --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6CA3.yaml @@ -0,0 +1,18 @@ +--- +- name: Tab indented top flow + from: '@ingydotnet' + tags: indent whitespace + yaml: | + ————»[ + ————»] + tree: | + +STR + +DOC + +SEQ [] + -SEQ + -DOC + -STR + json: | + [] + emit: | + --- [] diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6CK3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6CK3.yaml new file mode 100644 index 0000000..5908c82 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6CK3.yaml @@ -0,0 +1,26 @@ +--- +- name: Spec Example 6.26. Tag Shorthands + from: http://www.yaml.org/spec/1.2/spec.html#id2785009 + tags: spec tag local-tag + yaml: | + %TAG !e! tag:example.com,2000:app/ + --- + - !local foo + - !!str bar + - !e!tag%21 baz + tree: | + +STR + +DOC --- + +SEQ + =VAL :foo + =VAL :bar + =VAL :baz + -SEQ + -DOC + -STR + json: | + [ + "foo", + "bar", + "baz" + ] diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6FWR.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6FWR.yaml new file mode 100644 index 0000000..b5660e2 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6FWR.yaml @@ -0,0 +1,27 @@ +--- +- name: Block Scalar Keep + from: NimYAML tests + tags: literal scalar whitespace + yaml: | + --- |+ + ab + ␣ + ␣␣ + ... + tree: | + +STR + +DOC --- + =VAL |ab\n\n \n + -DOC ... + -STR + json: | + "ab\n\n \n" + dump: | + "ab\n\n \n" + ... + emit: | + --- | + ab + + ␣␣␣ + ... diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6H3V.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6H3V.yaml new file mode 100644 index 0000000..858613d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6H3V.yaml @@ -0,0 +1,21 @@ +--- +- name: Backslashes in singlequotes + from: '@perlpunk' + tags: scalar single + yaml: | + 'foo: bar\': baz' + tree: | + +STR + +DOC + +MAP + =VAL 'foo: bar\\ + =VAL :baz' + -MAP + -DOC + -STR + json: | + { + "foo: bar\\": "baz'" + } + dump: | + 'foo: bar\': baz' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6HB6.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6HB6.yaml new file mode 100644 index 0000000..96d25c8 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6HB6.yaml @@ -0,0 +1,55 @@ +--- +- name: Spec Example 6.1. Indentation Spaces + from: http://www.yaml.org/spec/1.2/spec.html#id2777865 + tags: comment flow spec indent upto-1.2 whitespace + yaml: |2 + # Leading comment line spaces are + # neither content nor indentation. + ␣␣␣␣ + Not indented: + By one space: | + By four + spaces + Flow style: [ # Leading spaces + By two, # in flow style + Also by two, # are neither + —»Still by two # content nor + ] # indentation. + tree: | + +STR + +DOC + +MAP + =VAL :Not indented + +MAP + =VAL :By one space + =VAL |By four\n spaces\n + =VAL :Flow style + +SEQ [] + =VAL :By two + =VAL :Also by two + =VAL :Still by two + -SEQ + -MAP + -MAP + -DOC + -STR + json: | + { + "Not indented": { + "By one space": "By four\n spaces\n", + "Flow style": [ + "By two", + "Also by two", + "Still by two" + ] + } + } + dump: | + Not indented: + By one space: | + By four + spaces + Flow style: + - By two + - Also by two + - Still by two diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6JQW.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6JQW.yaml new file mode 100644 index 0000000..34b8463 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6JQW.yaml @@ -0,0 +1,21 @@ +--- +- name: Spec Example 2.13. In literals, newlines are preserved + from: http://www.yaml.org/spec/1.2/spec.html#id2759963 + tags: spec scalar literal comment + yaml: | + # ASCII Art + --- | + \//||\/|| + // || ||__ + tree: | + +STR + +DOC --- + =VAL |\\//||\\/||\n// || ||__\n + -DOC + -STR + json: | + "\\//||\\/||\n// || ||__\n" + dump: | + --- | + \//||\/|| + // || ||__ diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6JTT.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6JTT.yaml new file mode 100644 index 0000000..a06cb73 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6JTT.yaml @@ -0,0 +1,17 @@ +--- +- name: Flow sequence without closing bracket + from: '@perlpunk' + tags: error flow sequence + fail: true + yaml: | + --- + [ [ a, b, c ] + tree: | + +STR + +DOC --- + +SEQ [] + +SEQ [] + =VAL :a + =VAL :b + =VAL :c + -SEQ diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6JWB.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6JWB.yaml new file mode 100644 index 0000000..5c376b6 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6JWB.yaml @@ -0,0 +1,38 @@ +--- +- name: Tags for Block Objects + from: NimYAML tests + tags: mapping sequence tag + yaml: | + foo: !!seq + - !!str a + - !!map + key: !!str value + tree: | + +STR + +DOC + +MAP + =VAL :foo + +SEQ + =VAL :a + +MAP + =VAL :key + =VAL :value + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "foo": [ + "a", + { + "key": "value" + } + ] + } + dump: | + foo: !!seq + - !!str a + - !!map + key: !!str value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6KGN.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6KGN.yaml new file mode 100644 index 0000000..dac198d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6KGN.yaml @@ -0,0 +1,28 @@ +--- +- name: Anchor for empty node + from: https://github.com/nodeca/js-yaml/issues/301 + tags: alias anchor + yaml: | + --- + a: &anchor + b: *anchor + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL &anchor : + =VAL :b + =ALI *anchor + -MAP + -DOC + -STR + json: | + { + "a": null, + "b": null + } + dump: | + --- + a: &anchor + b: *anchor diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6LVF.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6LVF.yaml new file mode 100644 index 0000000..4ea8f74 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6LVF.yaml @@ -0,0 +1,18 @@ +--- +- name: Spec Example 6.13. Reserved Directives + from: http://www.yaml.org/spec/1.2/spec.html#id2781445 + tags: spec directive header double 1.3-err + yaml: | + %FOO bar baz # Should be ignored + # with a warning. + --- "foo" + tree: | + +STR + +DOC --- + =VAL "foo + -DOC + -STR + json: | + "foo" + dump: | + --- "foo" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6M2F.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6M2F.yaml new file mode 100644 index 0000000..a2f357e --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6M2F.yaml @@ -0,0 +1,22 @@ +--- +- name: Aliases in Explicit Block Mapping + from: NimYAML tests + tags: alias explicit-key empty-key + yaml: | + ? &a a + : &b b + : *a + tree: | + +STR + +DOC + +MAP + =VAL &a :a + =VAL &b :b + =VAL : + =ALI *a + -MAP + -DOC + -STR + dump: | + &a a: &b b + : *a diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6PBE.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6PBE.yaml new file mode 100644 index 0000000..39edcf9 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6PBE.yaml @@ -0,0 +1,33 @@ +--- +- name: Zero-indented sequences in explicit mapping keys + from: '@perlpunk' + tags: explicit-key mapping sequence + yaml: | + --- + ? + - a + - b + : + - c + - d + tree: | + +STR + +DOC --- + +MAP + +SEQ + =VAL :a + =VAL :b + -SEQ + +SEQ + =VAL :c + =VAL :d + -SEQ + -MAP + -DOC + -STR + emit: | + --- + ? - a + - b + : - c + - d diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6S55.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6S55.yaml new file mode 100644 index 0000000..61907b2 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6S55.yaml @@ -0,0 +1,18 @@ +--- +- name: Invalid scalar at the end of sequence + from: '@perlpunk' + tags: error mapping sequence + fail: true + yaml: | + key: + - bar + - baz + invalid + tree: | + +STR + +DOC + +MAP + =VAL :key + +SEQ + =VAL :bar + =VAL :baz diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6SLA.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6SLA.yaml new file mode 100644 index 0000000..426c195 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6SLA.yaml @@ -0,0 +1,27 @@ +--- +- name: Allowed characters in quoted mapping key + from: '@perlpunk' + tags: mapping single double + yaml: | + "foo\nbar:baz\tx \\$%^&*()x": 23 + 'x\ny:z\tx $%^&*()x': 24 + tree: | + +STR + +DOC + +MAP + =VAL "foo\nbar:baz\tx \\$%^&*()x + =VAL :23 + =VAL 'x\\ny:z\\tx $%^&*()x + =VAL :24 + -MAP + -DOC + -STR + json: | + { + "foo\nbar:baz\tx \\$%^&*()x": 23, + "x\\ny:z\\tx $%^&*()x": 24 + } + dump: | + ? "foo\nbar:baz\tx \\$%^&*()x" + : 23 + 'x\ny:z\tx $%^&*()x': 24 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6VJK.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6VJK.yaml new file mode 100644 index 0000000..ccfcf67 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6VJK.yaml @@ -0,0 +1,29 @@ +--- +- name: Spec Example 2.15. Folded newlines are preserved for "more indented" and blank lines + from: http://www.yaml.org/spec/1.2/spec.html#id2761056 + tags: spec folded scalar 1.3-err + yaml: | + > + Sammy Sosa completed another + fine season with great stats. + + 63 Home Runs + 0.288 Batting Average + + What a year! + tree: | + +STR + +DOC + =VAL >Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n + -DOC + -STR + json: | + "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n" + dump: | + > + Sammy Sosa completed another fine season with great stats. + + 63 Home Runs + 0.288 Batting Average + + What a year! diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6WLZ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6WLZ.yaml new file mode 100644 index 0000000..f229cc6 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6WLZ.yaml @@ -0,0 +1,35 @@ +--- +- name: Spec Example 6.18. Primary Tag Handle [1.3] + from: 9WXW, modified for YAML 1.3 + tags: local-tag spec directive tag 1.3-mod + yaml: | + # Private + --- + !foo "bar" + ... + # Global + %TAG ! tag:example.com,2000:app/ + --- + !foo "bar" + tree: | + +STR + +DOC --- + =VAL "bar + -DOC ... + +DOC --- + =VAL "bar + -DOC + -STR + json: | + "bar" + "bar" + dump: | + --- + !foo "bar" + ... + --- ! + "bar" + emit: | + --- !foo "bar" + ... + --- ! "bar" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6WPF.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6WPF.yaml new file mode 100644 index 0000000..9aa2cc0 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6WPF.yaml @@ -0,0 +1,25 @@ +--- +- name: Spec Example 6.8. Flow Folding [1.3] + from: TL85, modified for YAML 1.3 + tags: double spec whitespace scalar 1.3-mod + yaml: | + --- + " + foo␣ + ␣ + bar + + baz + " + tree: | + +STR + +DOC --- + =VAL " foo\nbar\nbaz␣ + -DOC + -STR + json: | + " foo\nbar\nbaz " + dump: | + " foo\nbar\nbaz " + emit: | + --- " foo\nbar\nbaz " diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6XDY.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6XDY.yaml new file mode 100644 index 0000000..92441ab --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6XDY.yaml @@ -0,0 +1,22 @@ +--- +- name: Two document start markers + from: '@perlpunk' + tags: header + yaml: | + --- + --- + tree: | + +STR + +DOC --- + =VAL : + -DOC + +DOC --- + =VAL : + -DOC + -STR + json: | + null + null + dump: | + --- + --- diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6ZKB.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6ZKB.yaml new file mode 100644 index 0000000..d376f3a --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/6ZKB.yaml @@ -0,0 +1,40 @@ +--- +- name: Spec Example 9.6. Stream + from: http://www.yaml.org/spec/1.2/spec.html#id2801896 + tags: spec header 1.3-err + yaml: | + Document + --- + # Empty + ... + %YAML 1.2 + --- + matches %: 20 + tree: | + +STR + +DOC + =VAL :Document + -DOC + +DOC --- + =VAL : + -DOC ... + +DOC --- + +MAP + =VAL :matches % + =VAL :20 + -MAP + -DOC + -STR + json: | + "Document" + null + { + "matches %": 20 + } + emit: | + Document + --- + ... + %YAML 1.2 + --- + matches %: 20 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/735Y.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/735Y.yaml new file mode 100644 index 0000000..fb24919 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/735Y.yaml @@ -0,0 +1,38 @@ +--- +- name: Spec Example 8.20. Block Node Types + from: http://www.yaml.org/spec/1.2/spec.html#id2799426 + tags: comment double spec folded tag + yaml: | + - + "flow in block" + - > + Block scalar + - !!map # Block collection + foo : bar + tree: | + +STR + +DOC + +SEQ + =VAL "flow in block + =VAL >Block scalar\n + +MAP + =VAL :foo + =VAL :bar + -MAP + -SEQ + -DOC + -STR + json: | + [ + "flow in block", + "Block scalar\n", + { + "foo": "bar" + } + ] + dump: | + - "flow in block" + - > + Block scalar + - !!map + foo: bar diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/74H7.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/74H7.yaml new file mode 100644 index 0000000..8e5a1c4 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/74H7.yaml @@ -0,0 +1,41 @@ +--- +- name: Tags in Implicit Mapping + from: NimYAML tests + tags: tag mapping + yaml: | + !!str a: b + c: !!int 42 + e: !!str f + g: h + !!str 23: !!bool false + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL :b + =VAL :c + =VAL :42 + =VAL :e + =VAL :f + =VAL :g + =VAL :h + =VAL :23 + =VAL :false + -MAP + -DOC + -STR + json: | + { + "a": "b", + "c": 42, + "e": "f", + "g": "h", + "23": false + } + dump: | + !!str a: b + c: !!int 42 + e: !!str f + g: h + !!str 23: !!bool false diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/753E.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/753E.yaml new file mode 100644 index 0000000..cc1de02 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/753E.yaml @@ -0,0 +1,22 @@ +--- +- name: Block Scalar Strip [1.3] + from: MYW6, modified for YAML 1.3 + tags: literal scalar 1.3-mod whitespace + yaml: | + --- |- + ab + ␣ + ␣ + ... + tree: | + +STR + +DOC --- + =VAL |ab + -DOC ... + -STR + json: | + "ab" + dump: | + --- |- + ab + ... diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7A4E.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7A4E.yaml new file mode 100644 index 0000000..4c8afc6 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7A4E.yaml @@ -0,0 +1,19 @@ +--- +- name: Spec Example 7.6. Double Quoted Lines + from: http://www.yaml.org/spec/1.2/spec.html#id2787994 + tags: spec scalar upto-1.2 whitespace + yaml: | + " 1st non-empty + + 2nd non-empty␣ + ———»3rd non-empty " + tree: | + +STR + +DOC + =VAL " 1st non-empty\n2nd non-empty 3rd non-empty␣ + -DOC + -STR + json: | + " 1st non-empty\n2nd non-empty 3rd non-empty " + dump: | + " 1st non-empty\n2nd non-empty 3rd non-empty " diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7BMT.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7BMT.yaml new file mode 100644 index 0000000..442862c --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7BMT.yaml @@ -0,0 +1,90 @@ +--- +- name: Node and Mapping Key Anchors [1.3] + from: U3XV, modified for YAML 1.3 + tags: anchor comment mapping 1.3-mod + yaml: | + --- + top1: &node1 + &k1 key1: one + top2: &node2 # comment + key2: two + top3: + &k3 key3: three + top4: &node4 + &k4 key4: four + top5: &node5 + key5: five + top6: &val6 + six + top7: + &val7 seven + tree: | + +STR + +DOC --- + +MAP + =VAL :top1 + +MAP &node1 + =VAL &k1 :key1 + =VAL :one + -MAP + =VAL :top2 + +MAP &node2 + =VAL :key2 + =VAL :two + -MAP + =VAL :top3 + +MAP + =VAL &k3 :key3 + =VAL :three + -MAP + =VAL :top4 + +MAP &node4 + =VAL &k4 :key4 + =VAL :four + -MAP + =VAL :top5 + +MAP &node5 + =VAL :key5 + =VAL :five + -MAP + =VAL :top6 + =VAL &val6 :six + =VAL :top7 + =VAL &val7 :seven + -MAP + -DOC + -STR + json: | + { + "top1": { + "key1": "one" + }, + "top2": { + "key2": "two" + }, + "top3": { + "key3": "three" + }, + "top4": { + "key4": "four" + }, + "top5": { + "key5": "five" + }, + "top6": "six", + "top7": "seven" + } + dump: | + --- + top1: &node1 + &k1 key1: one + top2: &node2 + key2: two + top3: + &k3 key3: three + top4: &node4 + &k4 key4: four + top5: &node5 + key5: five + top6: &val6 six + top7: &val7 seven diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7BUB.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7BUB.yaml new file mode 100644 index 0000000..a52d72d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7BUB.yaml @@ -0,0 +1,49 @@ +--- +- name: Spec Example 2.10. Node for “Sammy Sosa” appears twice in this document + from: http://www.yaml.org/spec/1.2/spec.html#id2760658 + tags: mapping sequence spec alias + yaml: | + --- + hr: + - Mark McGwire + # Following node labeled SS + - &SS Sammy Sosa + rbi: + - *SS # Subsequent occurrence + - Ken Griffey + tree: | + +STR + +DOC --- + +MAP + =VAL :hr + +SEQ + =VAL :Mark McGwire + =VAL &SS :Sammy Sosa + -SEQ + =VAL :rbi + +SEQ + =ALI *SS + =VAL :Ken Griffey + -SEQ + -MAP + -DOC + -STR + json: | + { + "hr": [ + "Mark McGwire", + "Sammy Sosa" + ], + "rbi": [ + "Sammy Sosa", + "Ken Griffey" + ] + } + dump: | + --- + hr: + - Mark McGwire + - &SS Sammy Sosa + rbi: + - *SS + - Ken Griffey diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7FWL.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7FWL.yaml new file mode 100644 index 0000000..b1251b4 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7FWL.yaml @@ -0,0 +1,22 @@ +--- +- name: Spec Example 6.24. Verbatim Tags + from: http://www.yaml.org/spec/1.2/spec.html#id2784370 + tags: mapping spec tag unknown-tag + yaml: | + ! foo : + ! baz + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :baz + -MAP + -DOC + -STR + json: | + { + "foo": "baz" + } + dump: | + !!str foo: !bar baz diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7LBH.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7LBH.yaml new file mode 100644 index 0000000..1d65357 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7LBH.yaml @@ -0,0 +1,15 @@ +--- +- name: Multiline double quoted implicit keys + from: '@perlpunk' + tags: error double + fail: true + yaml: | + "a\nb": 1 + "c + d": 1 + tree: | + +STR + +DOC + +MAP + =VAL "a\nb + =VAL :1 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7MNF.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7MNF.yaml new file mode 100644 index 0000000..91bafac --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7MNF.yaml @@ -0,0 +1,18 @@ +--- +- name: Missing colon + from: '@perlpunk' + tags: error mapping + fail: true + yaml: | + top1: + key1: val1 + top2 + tree: | + +STR + +DOC + +MAP + =VAL :top1 + +MAP + =VAL :key1 + =VAL :val1 + -MAP diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7T8X.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7T8X.yaml new file mode 100644 index 0000000..66e3919 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7T8X.yaml @@ -0,0 +1,41 @@ +--- +- name: Spec Example 8.10. Folded Lines - 8.13. Final Empty Lines + from: http://www.yaml.org/spec/1.2/spec.html#id2796543 + tags: spec folded scalar comment 1.3-err + yaml: | + > + + folded + line + + next + line + * bullet + + * list + * lines + + last + line + + # Comment + tree: | + +STR + +DOC + =VAL >\nfolded line\nnext line\n * bullet\n\n * list\n * lines\n\nlast line\n + -DOC + -STR + json: | + "\nfolded line\nnext line\n * bullet\n\n * list\n * lines\n\nlast line\n" + dump: | + > + + folded line + + next line + * bullet + + * list + * lines + + last line diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7TMG.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7TMG.yaml new file mode 100644 index 0000000..14c0f47 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7TMG.yaml @@ -0,0 +1,27 @@ +--- +- name: Comment in flow sequence before comma + from: '@perlpunk' + tags: comment flow sequence + yaml: | + --- + [ word1 + # comment + , word2] + tree: | + +STR + +DOC --- + +SEQ [] + =VAL :word1 + =VAL :word2 + -SEQ + -DOC + -STR + json: | + [ + "word1", + "word2" + ] + dump: | + --- + - word1 + - word2 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7W2P.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7W2P.yaml new file mode 100644 index 0000000..5fe8606 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7W2P.yaml @@ -0,0 +1,31 @@ +--- +- name: Block Mapping with Missing Values + from: NimYAML tests + tags: explicit-key mapping + yaml: | + ? a + ? b + c: + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL : + =VAL :b + =VAL : + =VAL :c + =VAL : + -MAP + -DOC + -STR + json: | + { + "a": null, + "b": null, + "c": null + } + dump: | + a: + b: + c: diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7Z25.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7Z25.yaml new file mode 100644 index 0000000..fafbbf6 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7Z25.yaml @@ -0,0 +1,30 @@ +--- +- name: Bare document after document end marker + from: '@perlpunk' + tags: footer + yaml: | + --- + scalar1 + ... + key: value + tree: | + +STR + +DOC --- + =VAL :scalar1 + -DOC ... + +DOC + +MAP + =VAL :key + =VAL :value + -MAP + -DOC + -STR + json: | + "scalar1" + { + "key": "value" + } + dump: | + --- scalar1 + ... + key: value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7ZZ5.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7ZZ5.yaml new file mode 100644 index 0000000..ffbeae6 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/7ZZ5.yaml @@ -0,0 +1,63 @@ +--- +- name: Empty flow collections + from: '@perlpunk' + tags: flow mapping sequence + yaml: | + --- + nested sequences: + - - - [] + - - - {} + key1: [] + key2: {} + tree: | + +STR + +DOC --- + +MAP + =VAL :nested sequences + +SEQ + +SEQ + +SEQ + +SEQ [] + -SEQ + -SEQ + -SEQ + +SEQ + +SEQ + +MAP {} + -MAP + -SEQ + -SEQ + -SEQ + =VAL :key1 + +SEQ [] + -SEQ + =VAL :key2 + +MAP {} + -MAP + -MAP + -DOC + -STR + json: | + { + "nested sequences": [ + [ + [ + [] + ] + ], + [ + [ + {} + ] + ] + ], + "key1": [], + "key2": {} + } + dump: | + --- + nested sequences: + - - - [] + - - - {} + key1: [] + key2: {} diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/82AN.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/82AN.yaml new file mode 100644 index 0000000..9ab1cf0 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/82AN.yaml @@ -0,0 +1,17 @@ +--- +- name: Three dashes and content without space + from: '@perlpunk' + tags: scalar 1.3-err + yaml: | + ---word1 + word2 + tree: | + +STR + +DOC + =VAL :---word1 word2 + -DOC + -STR + json: | + "---word1 word2" + dump: | + '---word1 word2' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/87E4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/87E4.yaml new file mode 100644 index 0000000..4ca0ad8 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/87E4.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 7.8. Single Quoted Implicit Keys + from: http://www.yaml.org/spec/1.2/spec.html#id2788496 + tags: spec flow sequence mapping + yaml: | + 'implicit block key' : [ + 'implicit flow key' : value, + ] + tree: | + +STR + +DOC + +MAP + =VAL 'implicit block key + +SEQ [] + +MAP {} + =VAL 'implicit flow key + =VAL :value + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "implicit block key": [ + { + "implicit flow key": "value" + } + ] + } + dump: | + 'implicit block key': + - 'implicit flow key': value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8CWC.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8CWC.yaml new file mode 100644 index 0000000..ba29815 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8CWC.yaml @@ -0,0 +1,23 @@ +--- +- name: Plain mapping key ending with colon + from: '@perlpunk' + tags: mapping scalar + yaml: | + --- + key ends with two colons::: value + tree: | + +STR + +DOC --- + +MAP + =VAL :key ends with two colons:: + =VAL :value + -MAP + -DOC + -STR + json: | + { + "key ends with two colons::": "value" + } + dump: | + --- + 'key ends with two colons::': value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8G76.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8G76.yaml new file mode 100644 index 0000000..48bc590 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8G76.yaml @@ -0,0 +1,14 @@ +--- +- name: Spec Example 6.10. Comment Lines + from: http://www.yaml.org/spec/1.2/spec.html#id2780544 + tags: spec comment empty scalar whitespace + yaml: |2 + # Comment + ␣␣␣ + ↵ + ↵ + tree: | + +STR + -STR + json: '' + dump: '' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8KB6.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8KB6.yaml new file mode 100644 index 0000000..a4090d1 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8KB6.yaml @@ -0,0 +1,45 @@ +--- +- name: Multiline plain flow mapping key without value + from: '@perlpunk' + tags: flow mapping + yaml: | + --- + - { single line, a: b} + - { multi + line, a: b} + tree: | + +STR + +DOC --- + +SEQ + +MAP {} + =VAL :single line + =VAL : + =VAL :a + =VAL :b + -MAP + +MAP {} + =VAL :multi line + =VAL : + =VAL :a + =VAL :b + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "single line": null, + "a": "b" + }, + { + "multi line": null, + "a": "b" + } + ] + dump: | + --- + - single line: + a: b + - multi line: + a: b diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8MK2.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8MK2.yaml new file mode 100644 index 0000000..b5ba6ff --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8MK2.yaml @@ -0,0 +1,14 @@ +--- +- name: Explicit Non-Specific Tag + from: NimYAML tests + tags: tag 1.3-err + yaml: | + ! a + tree: | + +STR + +DOC + =VAL :a + -DOC + -STR + json: | + "a" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8QBE.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8QBE.yaml new file mode 100644 index 0000000..d0ee99c --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8QBE.yaml @@ -0,0 +1,31 @@ +--- +- name: Block Sequence in Block Mapping + from: NimYAML tests + tags: mapping sequence + yaml: | + key: + - item1 + - item2 + tree: | + +STR + +DOC + +MAP + =VAL :key + +SEQ + =VAL :item1 + =VAL :item2 + -SEQ + -MAP + -DOC + -STR + json: | + { + "key": [ + "item1", + "item2" + ] + } + dump: | + key: + - item1 + - item2 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8UDB.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8UDB.yaml new file mode 100644 index 0000000..a8612d3 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8UDB.yaml @@ -0,0 +1,48 @@ +--- +- name: Spec Example 7.14. Flow Sequence Entries + from: http://www.yaml.org/spec/1.2/spec.html#id2790726 + tags: spec flow sequence + yaml: | + [ + "double + quoted", 'single + quoted', + plain + text, [ nested ], + single: pair, + ] + tree: | + +STR + +DOC + +SEQ [] + =VAL "double quoted + =VAL 'single quoted + =VAL :plain text + +SEQ [] + =VAL :nested + -SEQ + +MAP {} + =VAL :single + =VAL :pair + -MAP + -SEQ + -DOC + -STR + json: | + [ + "double quoted", + "single quoted", + "plain text", + [ + "nested" + ], + { + "single": "pair" + } + ] + dump: | + - "double quoted" + - 'single quoted' + - plain text + - - nested + - single: pair diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8XDJ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8XDJ.yaml new file mode 100644 index 0000000..bdba6f1 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8XDJ.yaml @@ -0,0 +1,15 @@ +--- +- name: Comment in plain multiline value + from: https://gist.github.com/anonymous/deeb1ace28d5bf21fb56d80c13e2dc69 via @ingydotnet + tags: error comment scalar + fail: true + yaml: | + key: word1 + # xxx + word2 + tree: | + +STR + +DOC + +MAP + =VAL :key + =VAL :word1 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8XYN.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8XYN.yaml new file mode 100644 index 0000000..bdd99a9 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/8XYN.yaml @@ -0,0 +1,22 @@ +--- +- name: Anchor with unicode character + from: https://github.com/yaml/pyyaml/issues/94 + tags: anchor + yaml: | + --- + - &😁 unicode anchor + tree: | + +STR + +DOC --- + +SEQ + =VAL &😁 :unicode anchor + -SEQ + -DOC + -STR + json: | + [ + "unicode anchor" + ] + dump: | + --- + - &😁 unicode anchor diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/93JH.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/93JH.yaml new file mode 100644 index 0000000..1a9d434 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/93JH.yaml @@ -0,0 +1,40 @@ +--- +- name: Block Mappings in Block Sequence + from: NimYAML tests + tags: mapping sequence + yaml: |2 + - key: value + key2: value2 + - + key3: value3 + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL :key + =VAL :value + =VAL :key2 + =VAL :value2 + -MAP + +MAP + =VAL :key3 + =VAL :value3 + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "key": "value", + "key2": "value2" + }, + { + "key3": "value3" + } + ] + dump: | + - key: value + key2: value2 + - key3: value3 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/93WF.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/93WF.yaml new file mode 100644 index 0000000..49b82f1 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/93WF.yaml @@ -0,0 +1,27 @@ +--- +- name: Spec Example 6.6. Line Folding [1.3] + from: K527, modified for YAML 1.3 + tags: folded spec whitespace scalar 1.3-mod + yaml: | + --- >- + trimmed + ␣␣ + ␣ + + as + space + tree: | + +STR + +DOC --- + =VAL >trimmed\n\n\nas space + -DOC + -STR + json: | + "trimmed\n\n\nas space" + dump: | + --- >- + trimmed + + + + as space diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/96L6.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/96L6.yaml new file mode 100644 index 0000000..53a2cdc --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/96L6.yaml @@ -0,0 +1,20 @@ +--- +- name: Spec Example 2.14. In the folded scalars, newlines become spaces + from: http://www.yaml.org/spec/1.2/spec.html#id2761032 + tags: spec folded scalar + yaml: | + --- > + Mark McGwire's + year was crippled + by a knee injury. + tree: | + +STR + +DOC --- + =VAL >Mark McGwire's year was crippled by a knee injury.\n + -DOC + -STR + json: | + "Mark McGwire's year was crippled by a knee injury.\n" + dump: | + --- > + Mark McGwire's year was crippled by a knee injury. diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/96NN.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/96NN.yaml new file mode 100644 index 0000000..3f75b37 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/96NN.yaml @@ -0,0 +1,25 @@ +--- +- name: Leading tab content in literals + from: '@ingydotnet' + tags: indent literal whitespace + yaml: | + foo: |- + ——»bar + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL |\tbar + -MAP + -DOC + -STR + json: | + {"foo":"\tbar"} + dump: | + foo: |- + ——»bar + +- yaml: | + foo: |- + ——»bar∎ diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/98YD.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/98YD.yaml new file mode 100644 index 0000000..9faa967 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/98YD.yaml @@ -0,0 +1,11 @@ +--- +- name: Spec Example 5.5. Comment Indicator + from: http://www.yaml.org/spec/1.2/spec.html#id2773032 + tags: spec comment empty + yaml: | + # Comment only. + tree: | + +STR + -STR + json: '' + dump: '' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9BXH.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9BXH.yaml new file mode 100644 index 0000000..506e9b4 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9BXH.yaml @@ -0,0 +1,45 @@ +--- +- name: Multiline doublequoted flow mapping key without value + from: '@perlpunk' + tags: double flow mapping + yaml: | + --- + - { "single line", a: b} + - { "multi + line", a: b} + tree: | + +STR + +DOC --- + +SEQ + +MAP {} + =VAL "single line + =VAL : + =VAL :a + =VAL :b + -MAP + +MAP {} + =VAL "multi line + =VAL : + =VAL :a + =VAL :b + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "single line": null, + "a": "b" + }, + { + "multi line": null, + "a": "b" + } + ] + dump: | + --- + - "single line": + a: b + - "multi line": + a: b diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9C9N.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9C9N.yaml new file mode 100644 index 0000000..6c82ee6 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9C9N.yaml @@ -0,0 +1,17 @@ +--- +- name: Wrong indented flow sequence + from: '@perlpunk' + tags: error flow indent sequence + fail: true + yaml: | + --- + flow: [a, + b, + c] + tree: | + +STR + +DOC --- + +MAP + =VAL :flow + +SEQ [] + =VAL :a diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9CWY.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9CWY.yaml new file mode 100644 index 0000000..7fa2584 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9CWY.yaml @@ -0,0 +1,19 @@ +--- +- name: Invalid scalar at the end of mapping + from: '@perlpunk' + tags: error mapping sequence + fail: true + yaml: | + key: + - item1 + - item2 + invalid + tree: | + +STR + +DOC + +MAP + =VAL :key + +SEQ + =VAL :item1 + =VAL :item2 + -SEQ diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9DXL.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9DXL.yaml new file mode 100644 index 0000000..59e47f8 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9DXL.yaml @@ -0,0 +1,45 @@ +--- +- name: Spec Example 9.6. Stream [1.3] + from: 6ZKB, modified for YAML 1.3 + tags: spec header 1.3-mod + yaml: | + Mapping: Document + --- + # Empty + ... + %YAML 1.2 + --- + matches %: 20 + tree: | + +STR + +DOC + +MAP + =VAL :Mapping + =VAL :Document + -MAP + -DOC + +DOC --- + =VAL : + -DOC ... + +DOC --- + +MAP + =VAL :matches % + =VAL :20 + -MAP + -DOC + -STR + json: | + { + "Mapping": "Document" + } + null + { + "matches %": 20 + } + emit: | + Mapping: Document + --- + ... + %YAML 1.2 + --- + matches %: 20 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9FMG.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9FMG.yaml new file mode 100644 index 0000000..f5433d5 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9FMG.yaml @@ -0,0 +1,45 @@ +--- +- name: Multi-level Mapping Indent + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/indent.tml + tags: mapping indent + yaml: | + a: + b: + c: d + e: + f: g + h: i + tree: | + +STR + +DOC + +MAP + =VAL :a + +MAP + =VAL :b + +MAP + =VAL :c + =VAL :d + -MAP + =VAL :e + +MAP + =VAL :f + =VAL :g + -MAP + -MAP + =VAL :h + =VAL :i + -MAP + -DOC + -STR + json: | + { + "a": { + "b": { + "c": "d" + }, + "e": { + "f": "g" + } + }, + "h": "i" + } diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9HCY.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9HCY.yaml new file mode 100644 index 0000000..86fb3a9 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9HCY.yaml @@ -0,0 +1,14 @@ +--- +- name: Need document footer before directives + from: '@ingydotnet' + tags: directive error footer tag unknown-tag + fail: true + yaml: | + !foo "bar" + %TAG ! tag:example.com,2000:app/ + --- + !foo "bar" + tree: | + +STR + +DOC + =VAL "bar diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9J7A.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9J7A.yaml new file mode 100644 index 0000000..dfe0925 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9J7A.yaml @@ -0,0 +1,25 @@ +--- +- name: Simple Mapping Indent + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/indent.tml + tags: simple mapping indent + yaml: | + foo: + bar: baz + tree: | + +STR + +DOC + +MAP + =VAL :foo + +MAP + =VAL :bar + =VAL :baz + -MAP + -MAP + -DOC + -STR + json: | + { + "foo": { + "bar": "baz" + } + } diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9JBA.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9JBA.yaml new file mode 100644 index 0000000..fba48b2 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9JBA.yaml @@ -0,0 +1,16 @@ +--- +- name: Invalid comment after end of flow sequence + from: '@perlpunk' + tags: comment error flow sequence + fail: true + yaml: | + --- + [ a, b, c, ]#invalid + tree: | + +STR + +DOC --- + +SEQ [] + =VAL :a + =VAL :b + =VAL :c + -SEQ diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9KAX.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9KAX.yaml new file mode 100644 index 0000000..2ef2808 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9KAX.yaml @@ -0,0 +1,104 @@ +--- +- name: Various combinations of tags and anchors + from: '@perlpunk' + tags: anchor mapping 1.3-err tag + yaml: | + --- + &a1 + !!str + scalar1 + --- + !!str + &a2 + scalar2 + --- + &a3 + !!str scalar3 + --- + &a4 !!map + &a5 !!str key5: value4 + --- + a6: 1 + &anchor6 b6: 2 + --- + !!map + &a8 !!str key8: value7 + --- + !!map + !!str &a10 key10: value9 + --- + !!str &a11 + value11 + tree: | + +STR + +DOC --- + =VAL &a1 :scalar1 + -DOC + +DOC --- + =VAL &a2 :scalar2 + -DOC + +DOC --- + =VAL &a3 :scalar3 + -DOC + +DOC --- + +MAP &a4 + =VAL &a5 :key5 + =VAL :value4 + -MAP + -DOC + +DOC --- + +MAP + =VAL :a6 + =VAL :1 + =VAL &anchor6 :b6 + =VAL :2 + -MAP + -DOC + +DOC --- + +MAP + =VAL &a8 :key8 + =VAL :value7 + -MAP + -DOC + +DOC --- + +MAP + =VAL &a10 :key10 + =VAL :value9 + -MAP + -DOC + +DOC --- + =VAL &a11 :value11 + -DOC + -STR + json: | + "scalar1" + "scalar2" + "scalar3" + { + "key5": "value4" + } + { + "a6": 1, + "b6": 2 + } + { + "key8": "value7" + } + { + "key10": "value9" + } + "value11" + dump: | + --- &a1 !!str scalar1 + --- &a2 !!str scalar2 + --- &a3 !!str scalar3 + --- &a4 !!map + &a5 !!str key5: value4 + --- + a6: 1 + &anchor6 b6: 2 + --- !!map + &a8 !!str key8: value7 + --- !!map + &a10 !!str key10: value9 + --- &a11 !!str value11 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9KBC.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9KBC.yaml new file mode 100644 index 0000000..8819e58 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9KBC.yaml @@ -0,0 +1,11 @@ +--- +- name: Mapping starting at --- line + from: https://gist.github.com/anonymous/c728390e92ec93fb371ac77f21435cca via @ingydotnet + tags: error header mapping + fail: true + yaml: | + --- key1: value1 + key2: value2 + tree: | + +STR + +DOC --- diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MAG.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MAG.yaml new file mode 100644 index 0000000..424083f --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MAG.yaml @@ -0,0 +1,12 @@ +--- +- name: Flow sequence with invalid comma at the beginning + from: '@perlpunk' + tags: error flow sequence + fail: true + yaml: | + --- + [ , a, b, c ] + tree: | + +STR + +DOC --- + +SEQ [] diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MMA.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MMA.yaml new file mode 100644 index 0000000..5795696 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MMA.yaml @@ -0,0 +1,9 @@ +--- +- name: Directive by itself with no document + from: '@ingydotnet' + tags: error directive + fail: true + yaml: | + %YAML 1.2 + tree: | + +STR diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MMW.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MMW.yaml new file mode 100644 index 0000000..f887d5e --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MMW.yaml @@ -0,0 +1,41 @@ +--- +- name: Single Pair Implicit Entries + from: '@perlpunk, Spec Example 7.21' + tags: flow mapping sequence + yaml: | + - [ YAML : separate ] + - [ "JSON like":adjacent ] + - [ {JSON: like}:adjacent ] + tree: | + +STR + +DOC + +SEQ + +SEQ [] + +MAP {} + =VAL :YAML + =VAL :separate + -MAP + -SEQ + +SEQ [] + +MAP {} + =VAL "JSON like + =VAL :adjacent + -MAP + -SEQ + +SEQ [] + +MAP {} + +MAP {} + =VAL :JSON + =VAL :like + -MAP + =VAL :adjacent + -MAP + -SEQ + -SEQ + -DOC + -STR + dump: | + - - YAML: separate + - - "JSON like": adjacent + - - ? JSON: like + : adjacent diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MQT.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MQT.yaml new file mode 100644 index 0000000..3c315cf --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9MQT.yaml @@ -0,0 +1,31 @@ +--- +- name: Scalar doc with '...' in content + from: '@ingydotnet' + tags: double scalar + yaml: | + --- "a + ...x + b" + tree: | + +STR + +DOC --- + =VAL "a ...x b + -DOC + -STR + json: | + "a ...x b" + dump: | + --- a ...x b + emit: | + --- "a ...x b" + +- fail: true + yaml: | + --- "a + ... x + b" + tree: | + +STR + +DOC --- + dump: null + emit: null diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9SA2.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9SA2.yaml new file mode 100644 index 0000000..d0d0f0f --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9SA2.yaml @@ -0,0 +1,37 @@ +--- +- name: Multiline double quoted flow mapping key + from: '@perlpunk' + tags: double flow mapping + yaml: | + --- + - { "single line": value} + - { "multi + line": value} + tree: | + +STR + +DOC --- + +SEQ + +MAP {} + =VAL "single line + =VAL :value + -MAP + +MAP {} + =VAL "multi line + =VAL :value + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "single line": "value" + }, + { + "multi line": "value" + } + ] + dump: | + --- + - "single line": value + - "multi line": value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9SHH.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9SHH.yaml new file mode 100644 index 0000000..6f24a68 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9SHH.yaml @@ -0,0 +1,23 @@ +--- +- name: Spec Example 5.8. Quoted Scalar Indicators + from: http://www.yaml.org/spec/1.2/spec.html#id2773890 + tags: spec scalar + yaml: | + single: 'text' + double: "text" + tree: | + +STR + +DOC + +MAP + =VAL :single + =VAL 'text + =VAL :double + =VAL "text + -MAP + -DOC + -STR + json: | + { + "single": "text", + "double": "text" + } diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9TFX.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9TFX.yaml new file mode 100644 index 0000000..e9ba6b8 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9TFX.yaml @@ -0,0 +1,22 @@ +--- +- name: Spec Example 7.6. Double Quoted Lines [1.3] + from: 7A4E, modified for YAML 1.3 + tags: double spec scalar whitespace 1.3-mod + yaml: | + --- + " 1st non-empty + + 2nd non-empty␣ + 3rd non-empty " + tree: | + +STR + +DOC --- + =VAL " 1st non-empty\n2nd non-empty 3rd non-empty␣ + -DOC + -STR + json: | + " 1st non-empty\n2nd non-empty 3rd non-empty " + dump: | + " 1st non-empty\n2nd non-empty 3rd non-empty " + emit: | + --- " 1st non-empty\n2nd non-empty 3rd non-empty " diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9U5K.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9U5K.yaml new file mode 100644 index 0000000..75af536 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9U5K.yaml @@ -0,0 +1,61 @@ +--- +- name: Spec Example 2.12. Compact Nested Mapping + from: http://www.yaml.org/spec/1.2/spec.html#id2760821 + tags: spec mapping sequence + yaml: | + --- + # Products purchased + - item : Super Hoop + quantity: 1 + - item : Basketball + quantity: 4 + - item : Big Shoes + quantity: 1 + tree: | + +STR + +DOC --- + +SEQ + +MAP + =VAL :item + =VAL :Super Hoop + =VAL :quantity + =VAL :1 + -MAP + +MAP + =VAL :item + =VAL :Basketball + =VAL :quantity + =VAL :4 + -MAP + +MAP + =VAL :item + =VAL :Big Shoes + =VAL :quantity + =VAL :1 + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "item": "Super Hoop", + "quantity": 1 + }, + { + "item": "Basketball", + "quantity": 4 + }, + { + "item": "Big Shoes", + "quantity": 1 + } + ] + dump: | + --- + - item: Super Hoop + quantity: 1 + - item: Basketball + quantity: 4 + - item: Big Shoes + quantity: 1 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9WXW.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9WXW.yaml new file mode 100644 index 0000000..5ee5c16 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9WXW.yaml @@ -0,0 +1,28 @@ +--- +- name: Spec Example 6.18. Primary Tag Handle + from: http://www.yaml.org/spec/1.2/spec.html#id2782728 + tags: local-tag spec directive tag unknown-tag 1.3-err + yaml: | + # Private + !foo "bar" + ... + # Global + %TAG ! tag:example.com,2000:app/ + --- + !foo "bar" + tree: | + +STR + +DOC + =VAL "bar + -DOC ... + +DOC --- + =VAL "bar + -DOC + -STR + json: | + "bar" + "bar" + dump: | + !foo "bar" + ... + --- ! "bar" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9YRD.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9YRD.yaml new file mode 100644 index 0000000..8396a94 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/9YRD.yaml @@ -0,0 +1,23 @@ +--- +- name: Multiline Scalar at Top Level + from: NimYAML tests + tags: scalar whitespace 1.3-err + yaml: | + a + b␣␣ + c + d + + e + tree: | + +STR + +DOC + =VAL :a b c d\ne + -DOC + -STR + json: | + "a b c d\ne" + dump: | + 'a b c d + + e' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/A2M4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/A2M4.yaml new file mode 100644 index 0000000..03954d3 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/A2M4.yaml @@ -0,0 +1,39 @@ +--- +- name: Spec Example 6.2. Indentation Indicators + from: http://www.yaml.org/spec/1.2/spec.html#id2778101 + tags: explicit-key spec libyaml-err indent whitespace sequence upto-1.2 + yaml: | + ? a + : -»b + - -—»c + - d + tree: | + +STR + +DOC + +MAP + =VAL :a + +SEQ + =VAL :b + +SEQ + =VAL :c + =VAL :d + -SEQ + -SEQ + -MAP + -DOC + -STR + json: | + { + "a": [ + "b", + [ + "c", + "d" + ] + ] + } + dump: | + a: + - b + - - c + - d diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/A6F9.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/A6F9.yaml new file mode 100644 index 0000000..5b11980 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/A6F9.yaml @@ -0,0 +1,37 @@ +--- +- name: Spec Example 8.4. Chomping Final Line Break + from: http://www.yaml.org/spec/1.2/spec.html#id2795034 + tags: spec literal scalar + yaml: | + strip: |- + text + clip: | + text + keep: |+ + text + tree: | + +STR + +DOC + +MAP + =VAL :strip + =VAL |text + =VAL :clip + =VAL |text\n + =VAL :keep + =VAL |text\n + -MAP + -DOC + -STR + json: | + { + "strip": "text", + "clip": "text\n", + "keep": "text\n" + } + dump: | + strip: |- + text + clip: | + text + keep: | + text diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/A984.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/A984.yaml new file mode 100644 index 0000000..2ac0454 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/A984.yaml @@ -0,0 +1,29 @@ +--- +- name: Multiline Scalar in Mapping + from: NimYAML tests + tags: scalar + yaml: | + a: b + c + d: + e + f + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL :b c + =VAL :d + =VAL :e f + -MAP + -DOC + -STR + json: | + { + "a": "b c", + "d": "e f" + } + dump: | + a: b c + d: e f diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AB8U.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AB8U.yaml new file mode 100644 index 0000000..29cbb31 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AB8U.yaml @@ -0,0 +1,21 @@ +--- +- name: Sequence entry that looks like two with wrong indentation + from: '@perlpunk' + tags: scalar sequence + yaml: | + - single multiline + - sequence entry + tree: | + +STR + +DOC + +SEQ + =VAL :single multiline - sequence entry + -SEQ + -DOC + -STR + json: | + [ + "single multiline - sequence entry" + ] + dump: | + - single multiline - sequence entry diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AVM7.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AVM7.yaml new file mode 100644 index 0000000..7c3ce73 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AVM7.yaml @@ -0,0 +1,10 @@ +--- +- name: Empty Stream + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/misc.tml + tags: edge + yaml: | + ∎ + tree: | + +STR + -STR + json: '' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AZ63.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AZ63.yaml new file mode 100644 index 0000000..7cc4ef9 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AZ63.yaml @@ -0,0 +1,31 @@ +--- +- name: Sequence With Same Indentation as Parent Mapping + from: NimYAML tests + tags: indent mapping sequence + yaml: | + one: + - 2 + - 3 + four: 5 + tree: | + +STR + +DOC + +MAP + =VAL :one + +SEQ + =VAL :2 + =VAL :3 + -SEQ + =VAL :four + =VAL :5 + -MAP + -DOC + -STR + json: | + { + "one": [ + 2, + 3 + ], + "four": 5 + } diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AZW3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AZW3.yaml new file mode 100644 index 0000000..1acb2c4 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/AZW3.yaml @@ -0,0 +1,31 @@ +--- +- name: Lookahead test cases + from: NimYAML tests + tags: mapping edge + yaml: | + - bla"keks: foo + - bla]keks: foo + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL :bla"keks + =VAL :foo + -MAP + +MAP + =VAL :bla]keks + =VAL :foo + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "bla\"keks": "foo" + }, + { + "bla]keks": "foo" + } + ] diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/B3HG.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/B3HG.yaml new file mode 100644 index 0000000..637c562 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/B3HG.yaml @@ -0,0 +1,24 @@ +--- +- name: Spec Example 8.9. Folded Scalar [1.3] + from: G992, modified for YAML 1.3 + tags: spec folded scalar 1.3-mod + yaml: | + --- > + folded + text + ↵ + ↵ + tree: | + +STR + +DOC --- + =VAL >folded text\n + -DOC + -STR + json: | + "folded text\n" + dump: | + > + folded text + emit: | + --- > + folded text diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/B63P.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/B63P.yaml new file mode 100644 index 0000000..b89402d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/B63P.yaml @@ -0,0 +1,10 @@ +--- +- name: Directive without document + from: AdaYaml tests + tags: error directive document + fail: true + yaml: | + %YAML 1.2 + ... + tree: | + +STR diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BD7L.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BD7L.yaml new file mode 100644 index 0000000..9ccbdaf --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BD7L.yaml @@ -0,0 +1,15 @@ +--- +- name: Invalid mapping after sequence + from: '@perlpunk' + tags: error mapping sequence + fail: true + yaml: | + - item1 + - item2 + invalid: x + tree: | + +STR + +DOC + +SEQ + =VAL :item1 + =VAL :item2 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BEC7.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BEC7.yaml new file mode 100644 index 0000000..26f0ba6 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BEC7.yaml @@ -0,0 +1,19 @@ +--- +- name: Spec Example 6.14. “YAML” directive + from: http://www.yaml.org/spec/1.2/spec.html#id2781929 + tags: spec directive + yaml: | + %YAML 1.3 # Attempt parsing + # with a warning + --- + "foo" + tree: | + +STR + +DOC --- + =VAL "foo + -DOC + -STR + json: | + "foo" + dump: | + --- "foo" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BF9H.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BF9H.yaml new file mode 100644 index 0000000..fbae34a --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BF9H.yaml @@ -0,0 +1,16 @@ +--- +- name: Trailing comment in multiline plain scalar + from: '@perlpunk' + tags: comment error scalar + fail: true + yaml: | + --- + plain: a + b # end of scalar + c + tree: | + +STR + +DOC --- + +MAP + =VAL :plain + =VAL :a b diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BS4K.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BS4K.yaml new file mode 100644 index 0000000..519b9f2 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BS4K.yaml @@ -0,0 +1,13 @@ +--- +- name: Comment between plain scalar lines + from: https://gist.github.com/anonymous/269f16d582fdd30a7dcf8c9249c5da7f via @ingydotnet + tags: error scalar + fail: true + yaml: | + word1 # comment + word2 + tree: | + +STR + +DOC + =VAL :word1 + -DOC diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BU8L.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BU8L.yaml new file mode 100644 index 0000000..d126897 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/BU8L.yaml @@ -0,0 +1,29 @@ +--- +- name: Node Anchor and Tag on Seperate Lines + from: https://gist.github.com/anonymous/f192e7dab6da31831f264dbf1947cb83 via @ingydotnet + tags: anchor indent 1.3-err tag + yaml: | + key: &anchor + !!map + a: b + tree: | + +STR + +DOC + +MAP + =VAL :key + +MAP &anchor + =VAL :a + =VAL :b + -MAP + -MAP + -DOC + -STR + json: | + { + "key": { + "a": "b" + } + } + dump: | + key: &anchor !!map + a: b diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/C2DT.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/C2DT.yaml new file mode 100644 index 0000000..f9950eb --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/C2DT.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 7.18. Flow Mapping Adjacent Values + from: http://www.yaml.org/spec/1.2/spec.html#id2792073 + tags: spec flow mapping + yaml: | + { + "adjacent":value, + "readable": value, + "empty": + } + tree: | + +STR + +DOC + +MAP {} + =VAL "adjacent + =VAL :value + =VAL "readable + =VAL :value + =VAL "empty + =VAL : + -MAP + -DOC + -STR + json: | + { + "adjacent": "value", + "readable": "value", + "empty": null + } + dump: | + "adjacent": value + "readable": value + "empty": diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/C2SP.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/C2SP.yaml new file mode 100644 index 0000000..2ad9de9 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/C2SP.yaml @@ -0,0 +1,13 @@ +--- +- name: Flow Mapping Key on two lines + from: '@perlpunk' + tags: error flow mapping + fail: true + yaml: | + [23 + ]: 42 + tree: | + +STR + +DOC + +SEQ [] + =VAL :23 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/C4HZ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/C4HZ.yaml new file mode 100644 index 0000000..765040e --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/C4HZ.yaml @@ -0,0 +1,100 @@ +--- +- name: Spec Example 2.24. Global Tags + from: http://www.yaml.org/spec/1.2/spec.html#id2761719 + tags: spec tag alias directive local-tag + yaml: | + %TAG ! tag:clarkevans.com,2002: + --- !shape + # Use the ! handle for presenting + # tag:clarkevans.com,2002:circle + - !circle + center: &ORIGIN {x: 73, y: 129} + radius: 7 + - !line + start: *ORIGIN + finish: { x: 89, y: 102 } + - !label + start: *ORIGIN + color: 0xFFEEBB + text: Pretty vector drawing. + tree: | + +STR + +DOC --- + +SEQ + +MAP + =VAL :center + +MAP {} &ORIGIN + =VAL :x + =VAL :73 + =VAL :y + =VAL :129 + -MAP + =VAL :radius + =VAL :7 + -MAP + +MAP + =VAL :start + =ALI *ORIGIN + =VAL :finish + +MAP {} + =VAL :x + =VAL :89 + =VAL :y + =VAL :102 + -MAP + -MAP + +MAP + =VAL :start + =ALI *ORIGIN + =VAL :color + =VAL :0xFFEEBB + =VAL :text + =VAL :Pretty vector drawing. + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "center": { + "x": 73, + "y": 129 + }, + "radius": 7 + }, + { + "start": { + "x": 73, + "y": 129 + }, + "finish": { + "x": 89, + "y": 102 + } + }, + { + "start": { + "x": 73, + "y": 129 + }, + "color": 16772795, + "text": "Pretty vector drawing." + } + ] + dump: | + --- ! + - ! + center: &ORIGIN + x: 73 + y: 129 + radius: 7 + - ! + start: *ORIGIN + finish: + x: 89 + y: 102 + - ! + start: *ORIGIN + color: 0xFFEEBB + text: Pretty vector drawing. diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CC74.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CC74.yaml new file mode 100644 index 0000000..b5bfc0a --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CC74.yaml @@ -0,0 +1,18 @@ +--- +- name: Spec Example 6.20. Tag Handles + from: http://www.yaml.org/spec/1.2/spec.html#id2783195 + tags: spec directive tag unknown-tag + yaml: | + %TAG !e! tag:example.com,2000:app/ + --- + !e!foo "bar" + tree: | + +STR + +DOC --- + =VAL "bar + -DOC + -STR + json: | + "bar" + dump: | + --- ! "bar" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CFD4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CFD4.yaml new file mode 100644 index 0000000..5a6e7d6 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CFD4.yaml @@ -0,0 +1,29 @@ +--- +- name: Empty implicit key in single pair flow sequences + from: '@perlpunk' + tags: empty-key flow sequence + yaml: | + - [ : empty key ] + - [: another empty key] + tree: | + +STR + +DOC + +SEQ + +SEQ [] + +MAP {} + =VAL : + =VAL :empty key + -MAP + -SEQ + +SEQ [] + +MAP {} + =VAL : + =VAL :another empty key + -MAP + -SEQ + -SEQ + -DOC + -STR + dump: | + - - : empty key + - - : another empty key diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CML9.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CML9.yaml new file mode 100644 index 0000000..20ad32a --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CML9.yaml @@ -0,0 +1,16 @@ +--- +- name: Missing comma in flow + from: ihttps://gist.github.com/anonymous/4ba3365607cc14b4f656e391b45bf4f4 via @ingydotnet + tags: error flow comment + fail: true + yaml: | + key: [ word1 + # xxx + word2 ] + tree: | + +STR + +DOC + +MAP + =VAL :key + +SEQ [] + =VAL :word1 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CN3R.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CN3R.yaml new file mode 100644 index 0000000..38e6db7 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CN3R.yaml @@ -0,0 +1,56 @@ +--- +- name: Various location of anchors in flow sequence + from: '@perlpunk' + tags: anchor flow mapping sequence + yaml: | + &flowseq [ + a: b, + &c c: d, + { &e e: f }, + &g { g: h } + ] + tree: | + +STR + +DOC + +SEQ [] &flowseq + +MAP {} + =VAL :a + =VAL :b + -MAP + +MAP {} + =VAL &c :c + =VAL :d + -MAP + +MAP {} + =VAL &e :e + =VAL :f + -MAP + +MAP {} &g + =VAL :g + =VAL :h + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "a": "b" + }, + { + "c": "d" + }, + { + "e": "f" + }, + { + "g": "h" + } + ] + dump: | + &flowseq + - a: b + - &c c: d + - &e e: f + - &g + g: h diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CPZ3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CPZ3.yaml new file mode 100644 index 0000000..a0ea0a5 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CPZ3.yaml @@ -0,0 +1,23 @@ +--- +- name: Doublequoted scalar starting with a tab + from: '@perlpunk' + tags: double scalar + yaml: | + --- + tab: "\tstring" + tree: | + +STR + +DOC --- + +MAP + =VAL :tab + =VAL "\tstring + -MAP + -DOC + -STR + json: | + { + "tab": "\tstring" + } + dump: | + --- + tab: "\tstring" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CQ3W.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CQ3W.yaml new file mode 100644 index 0000000..a1e614f --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CQ3W.yaml @@ -0,0 +1,13 @@ +--- +- name: Double quoted string without closing quote + from: '@perlpunk' + tags: error double + fail: true + yaml: | + --- + key: "missing closing quote + tree: | + +STR + +DOC --- + +MAP + =VAL :key diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CT4Q.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CT4Q.yaml new file mode 100644 index 0000000..de1285f --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CT4Q.yaml @@ -0,0 +1,28 @@ +--- +- name: Spec Example 7.20. Single Pair Explicit Entry + from: http://www.yaml.org/spec/1.2/spec.html#id2792424 + tags: explicit-key spec flow mapping + yaml: | + [ + ? foo + bar : baz + ] + tree: | + +STR + +DOC + +SEQ [] + +MAP {} + =VAL :foo bar + =VAL :baz + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "foo bar": "baz" + } + ] + dump: | + - foo bar: baz diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CTN5.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CTN5.yaml new file mode 100644 index 0000000..84b0be5 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CTN5.yaml @@ -0,0 +1,15 @@ +--- +- name: Flow sequence with invalid extra comma + from: '@perlpunk' + tags: error flow sequence + fail: true + yaml: | + --- + [ a, b, c, , ] + tree: | + +STR + +DOC --- + +SEQ [] + =VAL :a + =VAL :b + =VAL :c diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CUP7.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CUP7.yaml new file mode 100644 index 0000000..10a4f88 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CUP7.yaml @@ -0,0 +1,26 @@ +--- +- name: Spec Example 5.6. Node Property Indicators + from: http://www.yaml.org/spec/1.2/spec.html#id2773402 + tags: local-tag spec tag alias + yaml: | + anchored: !local &anchor value + alias: *anchor + tree: | + +STR + +DOC + +MAP + =VAL :anchored + =VAL &anchor :value + =VAL :alias + =ALI *anchor + -MAP + -DOC + -STR + json: | + { + "anchored": "value", + "alias": "value" + } + dump: | + anchored: &anchor !local value + alias: *anchor diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CVW2.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CVW2.yaml new file mode 100644 index 0000000..786ba11 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CVW2.yaml @@ -0,0 +1,16 @@ +--- +- name: Invalid comment after comma + from: '@perlpunk' + tags: comment error flow sequence + fail: true + yaml: | + --- + [ a, b, c,#invalid + ] + tree: | + +STR + +DOC --- + +SEQ [] + =VAL :a + =VAL :b + =VAL :c diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CXX2.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CXX2.yaml new file mode 100644 index 0000000..31fda0a --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/CXX2.yaml @@ -0,0 +1,10 @@ +--- +- name: Mapping with anchor on document start line + from: '@perlpunk' + tags: anchor error header mapping + fail: true + yaml: | + --- &anchor a: b + tree: | + +STR + +DOC --- diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D49Q.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D49Q.yaml new file mode 100644 index 0000000..0c32fd1 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D49Q.yaml @@ -0,0 +1,15 @@ +--- +- name: Multiline single quoted implicit keys + from: '@perlpunk' + tags: error single mapping + fail: true + yaml: | + 'a\nb': 1 + 'c + d': 1 + tree: | + +STR + +DOC + +MAP + =VAL 'a\\nb + =VAL :1 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D83L.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D83L.yaml new file mode 100644 index 0000000..be87a1f --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D83L.yaml @@ -0,0 +1,28 @@ +--- +- name: Block scalar indicator order + from: '@perlpunk' + tags: indent literal + yaml: | + - |2- + explicit indent and chomp + - |-2 + chomp and explicit indent + tree: | + +STR + +DOC + +SEQ + =VAL |explicit indent and chomp + =VAL |chomp and explicit indent + -SEQ + -DOC + -STR + json: | + [ + "explicit indent and chomp", + "chomp and explicit indent" + ] + dump: | + - |- + explicit indent and chomp + - |- + chomp and explicit indent diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D88J.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D88J.yaml new file mode 100644 index 0000000..a69a0e2 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D88J.yaml @@ -0,0 +1,29 @@ +--- +- name: Flow Sequence in Block Mapping + from: NimYAML tests + tags: flow sequence mapping + yaml: | + a: [b, c] + tree: | + +STR + +DOC + +MAP + =VAL :a + +SEQ [] + =VAL :b + =VAL :c + -SEQ + -MAP + -DOC + -STR + json: | + { + "a": [ + "b", + "c" + ] + } + dump: | + a: + - b + - c diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D9TU.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D9TU.yaml new file mode 100644 index 0000000..21fb988 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/D9TU.yaml @@ -0,0 +1,19 @@ +--- +- name: Single Pair Block Mapping + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml + tags: simple mapping + yaml: | + foo: bar + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :bar + -MAP + -DOC + -STR + json: | + { + "foo": "bar" + } diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DBG4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DBG4.yaml new file mode 100644 index 0000000..304d834 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DBG4.yaml @@ -0,0 +1,62 @@ +--- +- name: Spec Example 7.10. Plain Characters + from: http://www.yaml.org/spec/1.2/spec.html#id2789510 + tags: spec flow sequence scalar + yaml: | + # Outside flow collection: + - ::vector + - ": - ()" + - Up, up, and away! + - -123 + - http://example.com/foo#bar + # Inside flow collection: + - [ ::vector, + ": - ()", + "Up, up and away!", + -123, + http://example.com/foo#bar ] + tree: | + +STR + +DOC + +SEQ + =VAL :::vector + =VAL ": - () + =VAL :Up, up, and away! + =VAL :-123 + =VAL :http://example.com/foo#bar + +SEQ [] + =VAL :::vector + =VAL ": - () + =VAL "Up, up and away! + =VAL :-123 + =VAL :http://example.com/foo#bar + -SEQ + -SEQ + -DOC + -STR + json: | + [ + "::vector", + ": - ()", + "Up, up, and away!", + -123, + "http://example.com/foo#bar", + [ + "::vector", + ": - ()", + "Up, up and away!", + -123, + "http://example.com/foo#bar" + ] + ] + dump: | + - ::vector + - ": - ()" + - Up, up, and away! + - -123 + - http://example.com/foo#bar + - - ::vector + - ": - ()" + - "Up, up and away!" + - -123 + - http://example.com/foo#bar diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DC7X.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DC7X.yaml new file mode 100644 index 0000000..ada199e --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DC7X.yaml @@ -0,0 +1,37 @@ +--- +- name: Various trailing tabs + from: '@perlpunk' + tags: comment whitespace + yaml: | + a: b———» + seq:———» + - a———» + c: d———»#X + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL :b + =VAL :seq + +SEQ + =VAL :a + -SEQ + =VAL :c + =VAL :d + -MAP + -DOC + -STR + json: | + { + "a": "b", + "seq": [ + "a" + ], + "c": "d" + } + dump: | + a: b + seq: + - a + c: d diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DE56.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DE56.yaml new file mode 100644 index 0000000..74f5b52 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DE56.yaml @@ -0,0 +1,87 @@ +--- +- name: Trailing tabs in double quoted + from: '@ingydotnet' + tags: double whitespace + yaml: | + "1 trailing\t + tab" + tree: | + +STR + +DOC + =VAL "1 trailing\t tab + -DOC + -STR + json: | + "1 trailing\t tab" + dump: | + "1 trailing\t tab" + +- yaml: | + "2 trailing\t␣␣ + tab" + tree: | + +STR + +DOC + =VAL "2 trailing\t tab + -DOC + -STR + json: | + "2 trailing\t tab" + dump: | + "2 trailing\t tab" + +- yaml: | + "3 trailing\————» + tab" + tree: | + +STR + +DOC + =VAL "3 trailing\t tab + -DOC + -STR + json: | + "3 trailing\t tab" + dump: | + "3 trailing\t tab" + +- yaml: | + "4 trailing\————»␣␣ + tab" + tree: | + +STR + +DOC + =VAL "4 trailing\t tab + -DOC + -STR + json: | + "4 trailing\t tab" + dump: | + "4 trailing\t tab" + +- yaml: | + "5 trailing—» + tab" + tree: | + +STR + +DOC + =VAL "5 trailing tab + -DOC + -STR + json: | + "5 trailing tab" + dump: | + "5 trailing tab" + +- yaml: | + "6 trailing—»␣␣ + tab" + tree: | + +STR + +DOC + =VAL "6 trailing tab + -DOC + -STR + json: | + "6 trailing tab" + dump: | + "6 trailing tab" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DFF7.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DFF7.yaml new file mode 100644 index 0000000..d081f31 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DFF7.yaml @@ -0,0 +1,27 @@ +--- +- name: Spec Example 7.16. Flow Mapping Entries + from: http://www.yaml.org/spec/1.2/spec.html#id2791260 + tags: explicit-key spec flow mapping + yaml: | + { + ? explicit: entry, + implicit: entry, + ? + } + tree: | + +STR + +DOC + +MAP {} + =VAL :explicit + =VAL :entry + =VAL :implicit + =VAL :entry + =VAL : + =VAL : + -MAP + -DOC + -STR + dump: | + explicit: entry + implicit: entry + : diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DHP8.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DHP8.yaml new file mode 100644 index 0000000..b3c25da --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DHP8.yaml @@ -0,0 +1,26 @@ +--- +- name: Flow Sequence + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/sequence.tml + tags: flow sequence + yaml: | + [foo, bar, 42] + tree: | + +STR + +DOC + +SEQ [] + =VAL :foo + =VAL :bar + =VAL :42 + -SEQ + -DOC + -STR + json: | + [ + "foo", + "bar", + 42 + ] + dump: | + - foo + - bar + - 42 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DK3J.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DK3J.yaml new file mode 100644 index 0000000..fc01be3 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DK3J.yaml @@ -0,0 +1,20 @@ +--- +- name: Zero indented block scalar with line that looks like a comment + from: '@perlpunk' + tags: comment folded scalar + yaml: | + --- > + line1 + # no comment + line3 + tree: | + +STR + +DOC --- + =VAL >line1 # no comment line3\n + -DOC + -STR + json: | + "line1 # no comment line3\n" + dump: | + --- > + line1 # no comment line3 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DK4H.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DK4H.yaml new file mode 100644 index 0000000..558e468 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DK4H.yaml @@ -0,0 +1,14 @@ +--- +- name: Implicit key followed by newline + from: '@perlpunk' + tags: error flow mapping sequence + fail: true + yaml: | + --- + [ key + : value ] + tree: | + +STR + +DOC --- + +SEQ [] + =VAL :key diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DK95.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DK95.yaml new file mode 100644 index 0000000..eb80249 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DK95.yaml @@ -0,0 +1,172 @@ +--- +- name: Tabs that look like indentation + from: '@ingydotnet' + tags: indent whitespace + yaml: | + foo: + ———»bar + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :bar + -MAP + -DOC + -STR + json: | + { + "foo" : "bar" + } + emit: | + --- + foo: bar + +- fail: true + yaml: | + foo: "bar + ————»baz" + tree: | + +STR + +DOC + +MAP + =VAL :foo + +- yaml: | + foo: "bar + ——»baz" + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL "bar baz + -MAP + -DOC + -STR + json: | + { + "foo" : "bar baz" + } + emit: | + --- + foo: "bar baz" + +- yaml: |2 + ———» + foo: 1 + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :1 + -MAP + -DOC + -STR + json: | + { + "foo" : 1 + } + emit: | + --- + foo: 1 + +- yaml: | + foo: 1 + ————» + bar: 2 + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :1 + =VAL :bar + =VAL :2 + -MAP + -DOC + -STR + json: | + { + "foo" : 1, + "bar" : 2 + } + emit: | + --- + foo: 1 + bar: 2 + +- yaml: | + foo: 1 + ———» + bar: 2 + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :1 + =VAL :bar + =VAL :2 + -MAP + -DOC + -STR + json: | + { + "foo" : 1, + "bar" : 2 + } + emit: | + --- + foo: 1 + bar: 2 + +- fail: true + yaml: | + foo: + a: 1 + ——»b: 2 + tree: | + +STR + +DOC + +MAP + =VAL :foo + +MAP + =VAL :a + =VAL :1 + +- yaml: | + %YAML 1.2 + ————» + --- + tree: | + +STR + +DOC --- + =VAL : + -DOC + -STR + json: | + null + emit: | + --- null + +- yaml: | + foo: "bar + ———» ——» baz ——» ——» " + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL "bar baz \t \t␣ + -MAP + -DOC + -STR + json: | + { + "foo" : "bar baz \t \t " + } + emit: | + --- + foo: "bar baz \t \t " diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DMG6.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DMG6.yaml new file mode 100644 index 0000000..8a89d28 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DMG6.yaml @@ -0,0 +1,18 @@ +--- +- name: Wrong indendation in Map + from: '@perlpunk' + tags: error mapping indent + fail: true + yaml: | + key: + ok: 1 + wrong: 2 + tree: | + +STR + +DOC + +MAP + =VAL :key + +MAP + =VAL :ok + =VAL :1 + -MAP diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DWX9.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DWX9.yaml new file mode 100644 index 0000000..672a43e --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/DWX9.yaml @@ -0,0 +1,32 @@ +--- +- name: Spec Example 8.8. Literal Content + from: http://www.yaml.org/spec/1.2/spec.html#id2796118 + tags: spec literal scalar comment whitespace 1.3-err + yaml: | + | + ␣ + ␣␣ + literal + ␣␣␣ + ␣␣ + text + + # Comment + tree: | + +STR + +DOC + =VAL |\n\nliteral\n \n\ntext\n + -DOC + -STR + json: | + "\n\nliteral\n \n\ntext\n" + dump: | + "\n\nliteral\n \n\ntext\n" + emit: | + | + + + literal + ␣␣␣ + + text diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/E76Z.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/E76Z.yaml new file mode 100644 index 0000000..06f28e3 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/E76Z.yaml @@ -0,0 +1,26 @@ +--- +- name: Aliases in Implicit Block Mapping + from: NimYAML tests + tags: mapping alias + yaml: | + &a a: &b b + *b : *a + tree: | + +STR + +DOC + +MAP + =VAL &a :a + =VAL &b :b + =ALI *b + =ALI *a + -MAP + -DOC + -STR + json: | + { + "a": "b", + "b": "a" + } + dump: | + &a a: &b b + *b : *a diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EB22.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EB22.yaml new file mode 100644 index 0000000..d96d9bb --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EB22.yaml @@ -0,0 +1,16 @@ +--- +- name: Missing document-end marker before directive + from: '@perlpunk' + tags: error directive footer + fail: true + yaml: | + --- + scalar1 # comment + %YAML 1.2 + --- + scalar2 + tree: | + +STR + +DOC --- + =VAL :scalar1 + -DOC diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EHF6.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EHF6.yaml new file mode 100644 index 0000000..b4e22fb --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EHF6.yaml @@ -0,0 +1,33 @@ +--- +- name: Tags for Flow Objects + from: NimYAML tests + tags: tag flow mapping sequence + yaml: | + !!map { + k: !!seq + [ a, !!str b] + } + tree: | + +STR + +DOC + +MAP {} + =VAL :k + +SEQ [] + =VAL :a + =VAL :b + -SEQ + -MAP + -DOC + -STR + json: | + { + "k": [ + "a", + "b" + ] + } + dump: | + !!map + k: !!seq + - a + - !!str b diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EW3V.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EW3V.yaml new file mode 100644 index 0000000..0a21a49 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EW3V.yaml @@ -0,0 +1,13 @@ +--- +- name: Wrong indendation in mapping + from: '@perlpunk' + tags: error mapping indent + fail: true + yaml: | + k1: v1 + k2: v2 + tree: | + +STR + +DOC + +MAP + =VAL :k1 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EX5H.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EX5H.yaml new file mode 100644 index 0000000..a27ba11 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EX5H.yaml @@ -0,0 +1,28 @@ +--- +- name: Multiline Scalar at Top Level [1.3] + from: 9YRD, modified for YAML 1.3 + tags: scalar whitespace 1.3-mod + yaml: | + --- + a + b␣␣ + c + d + + e + tree: | + +STR + +DOC --- + =VAL :a b c d\ne + -DOC + -STR + json: | + "a b c d\ne" + dump: | + 'a b c d + + e' + emit: | + --- a b c d + + e diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EXG3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EXG3.yaml new file mode 100644 index 0000000..18745e6 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/EXG3.yaml @@ -0,0 +1,20 @@ +--- +- name: Three dashes and content without space [1.3] + from: 82AN, modified for YAML 1.3 + tags: scalar 1.3-mod + yaml: | + --- + ---word1 + word2 + tree: | + +STR + +DOC --- + =VAL :---word1 word2 + -DOC + -STR + json: | + "---word1 word2" + dump: | + '---word1 word2' + emit: | + --- '---word1 word2' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F2C7.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F2C7.yaml new file mode 100644 index 0000000..8e46129 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F2C7.yaml @@ -0,0 +1,32 @@ +--- +- name: Anchors and Tags + from: NimYAML tests + tags: anchor tag + yaml: |2 + - &a !!str a + - !!int 2 + - !!int &c 4 + - &d d + tree: | + +STR + +DOC + +SEQ + =VAL &a :a + =VAL :2 + =VAL &c :4 + =VAL &d :d + -SEQ + -DOC + -STR + json: | + [ + "a", + 2, + 4, + "d" + ] + dump: | + - &a !!str a + - !!int 2 + - &c !!int 4 + - &d d diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F3CP.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F3CP.yaml new file mode 100644 index 0000000..71b0b89 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F3CP.yaml @@ -0,0 +1,47 @@ +--- +- name: Nested flow collections on one line + from: '@perlpunk' + tags: flow mapping sequence + yaml: | + --- + { a: [b, c, { d: [e, f] } ] } + tree: | + +STR + +DOC --- + +MAP {} + =VAL :a + +SEQ [] + =VAL :b + =VAL :c + +MAP {} + =VAL :d + +SEQ [] + =VAL :e + =VAL :f + -SEQ + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "a": [ + "b", + "c", + { + "d": [ + "e", + "f" + ] + } + ] + } + dump: | + --- + a: + - b + - c + - d: + - e + - f diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F6MC.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F6MC.yaml new file mode 100644 index 0000000..e246e85 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F6MC.yaml @@ -0,0 +1,40 @@ +--- +- name: More indented lines at the beginning of folded block scalars + from: '@perlpunk' + tags: folded indent + yaml: | + --- + a: >2 + more indented + regular + b: >2 + + + more indented + regular + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL > more indented\nregular\n + =VAL :b + =VAL >\n\n more indented\nregular\n + -MAP + -DOC + -STR + json: | + { + "a": " more indented\nregular\n", + "b": "\n\n more indented\nregular\n" + } + emit: | + --- + a: >2 + more indented + regular + b: >2 + + + more indented + regular diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F8F9.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F8F9.yaml new file mode 100644 index 0000000..8fd5f71 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/F8F9.yaml @@ -0,0 +1,52 @@ +--- +- name: Spec Example 8.5. Chomping Trailing Lines + from: http://www.yaml.org/spec/1.2/spec.html#id2795435 + tags: spec literal scalar comment + yaml: |2 + # Strip + # Comments: + strip: |- + # text + ␣␣ + # Clip + # comments: + + clip: | + # text + ␣ + # Keep + # comments: + + keep: |+ + # text + + # Trail + # comments. + tree: | + +STR + +DOC + +MAP + =VAL :strip + =VAL |# text + =VAL :clip + =VAL |# text\n + =VAL :keep + =VAL |# text\n\n + -MAP + -DOC + -STR + json: | + { + "strip": "# text", + "clip": "# text\n", + "keep": "# text\n\n" + } + dump: | + strip: |- + # text + clip: | + # text + keep: |+ + # text + + ... diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FBC9.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FBC9.yaml new file mode 100644 index 0000000..9f69b72 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FBC9.yaml @@ -0,0 +1,37 @@ +--- +- name: Allowed characters in plain scalars + from: '@perlpunk' + tags: scalar + yaml: | + safe: a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~ + !"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~ + safe question mark: ?foo + safe colon: :foo + safe dash: -foo + tree: | + +STR + +DOC + +MAP + =VAL :safe + =VAL :a!"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~ !"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~ + =VAL :safe question mark + =VAL :?foo + =VAL :safe colon + =VAL ::foo + =VAL :safe dash + =VAL :-foo + -MAP + -DOC + -STR + json: | + { + "safe": "a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~ !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~", + "safe question mark": "?foo", + "safe colon": ":foo", + "safe dash": "-foo" + } + dump: | + safe: a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~ !"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~ + safe question mark: ?foo + safe colon: :foo + safe dash: -foo diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FH7J.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FH7J.yaml new file mode 100644 index 0000000..04e887b --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FH7J.yaml @@ -0,0 +1,33 @@ +--- +- name: Tags on Empty Scalars + from: NimYAML tests + tags: tag scalar + yaml: | + - !!str + - + !!null : a + b: !!str + - !!str : !!null + tree: | + +STR + +DOC + +SEQ + =VAL : + +MAP + =VAL : + =VAL :a + =VAL :b + =VAL : + -MAP + +MAP + =VAL : + =VAL : + -MAP + -SEQ + -DOC + -STR + dump: | + - !!str + - !!null : a + b: !!str + - !!str : !!null diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FP8R.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FP8R.yaml new file mode 100644 index 0000000..9da8017 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FP8R.yaml @@ -0,0 +1,20 @@ +--- +- name: Zero indented block scalar + from: '@perlpunk' + tags: folded indent scalar + yaml: | + --- > + line1 + line2 + line3 + tree: | + +STR + +DOC --- + =VAL >line1 line2 line3\n + -DOC + -STR + json: | + "line1 line2 line3\n" + dump: | + --- > + line1 line2 line3 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FQ7F.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FQ7F.yaml new file mode 100644 index 0000000..f0afa4b --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FQ7F.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 2.1. Sequence of Scalars + from: http://www.yaml.org/spec/1.2/spec.html#id2759963 + tags: spec sequence + yaml: | + - Mark McGwire + - Sammy Sosa + - Ken Griffey + tree: | + +STR + +DOC + +SEQ + =VAL :Mark McGwire + =VAL :Sammy Sosa + =VAL :Ken Griffey + -SEQ + -DOC + -STR + json: | + [ + "Mark McGwire", + "Sammy Sosa", + "Ken Griffey" + ] + toke: | + SEQ-MARK 0 1 1 1 + WS-SPACE 1 1 1 2 + TEXT-VAL 2 12 1 3 :Mark McGwire + WS-NEWLN 14 1 1 15 + SEQ-MARK 15 1 2 1 + WS-SPACE 1 1 1 2 + TEXT-VAL 2 12 1 3 :Sammy Sosa + WS-NEWLN 14 1 1 15 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FRK4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FRK4.yaml new file mode 100644 index 0000000..a8734d0 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FRK4.yaml @@ -0,0 +1,20 @@ +--- +- name: Spec Example 7.3. Completely Empty Flow Nodes + from: http://www.yaml.org/spec/1.2/spec.html#id2786868 + tags: empty-key explicit-key spec flow mapping + yaml: | + { + ? foo :, + : bar, + } + tree: | + +STR + +DOC + +MAP {} + =VAL :foo + =VAL : + =VAL : + =VAL :bar + -MAP + -DOC + -STR diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FTA2.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FTA2.yaml new file mode 100644 index 0000000..9e0c2f7 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FTA2.yaml @@ -0,0 +1,22 @@ +--- +- name: Single block sequence with anchor and explicit document start + from: '@perlpunk' + tags: anchor header sequence + yaml: | + --- &sequence + - a + tree: | + +STR + +DOC --- + +SEQ &sequence + =VAL :a + -SEQ + -DOC + -STR + json: | + [ + "a" + ] + dump: | + --- &sequence + - a diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FUP4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FUP4.yaml new file mode 100644 index 0000000..8d84b4d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/FUP4.yaml @@ -0,0 +1,30 @@ +--- +- name: Flow Sequence in Flow Sequence + from: NimYAML tests + tags: sequence flow + yaml: | + [a, [b, c]] + tree: | + +STR + +DOC + +SEQ [] + =VAL :a + +SEQ [] + =VAL :b + =VAL :c + -SEQ + -SEQ + -DOC + -STR + json: | + [ + "a", + [ + "b", + "c" + ] + ] + dump: | + - a + - - b + - c diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G4RS.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G4RS.yaml new file mode 100644 index 0000000..c468cd5 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G4RS.yaml @@ -0,0 +1,47 @@ +--- +- name: Spec Example 2.17. Quoted Scalars + from: http://www.yaml.org/spec/1.2/spec.html#id2761245 + tags: spec scalar + yaml: | + unicode: "Sosa did fine.\u263A" + control: "\b1998\t1999\t2000\n" + hex esc: "\x0d\x0a is \r\n" + + single: '"Howdy!" he cried.' + quoted: ' # Not a ''comment''.' + tie-fighter: '|\-*-/|' + tree: | + +STR + +DOC + +MAP + =VAL :unicode + =VAL "Sosa did fine.☺ + =VAL :control + =VAL "\b1998\t1999\t2000\n + =VAL :hex esc + =VAL "\r\n is \r\n + =VAL :single + =VAL '"Howdy!" he cried. + =VAL :quoted + =VAL ' # Not a 'comment'. + =VAL :tie-fighter + =VAL '|\\-*-/| + -MAP + -DOC + -STR + json: | + { + "unicode": "Sosa did fine.☺", + "control": "\b1998\t1999\t2000\n", + "hex esc": "\r\n is \r\n", + "single": "\"Howdy!\" he cried.", + "quoted": " # Not a 'comment'.", + "tie-fighter": "|\\-*-/|" + } + dump: | + unicode: "Sosa did fine.\u263A" + control: "\b1998\t1999\t2000\n" + hex esc: "\r\n is \r\n" + single: '"Howdy!" he cried.' + quoted: ' # Not a ''comment''.' + tie-fighter: '|\-*-/|' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G5U8.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G5U8.yaml new file mode 100644 index 0000000..ad8f4b9 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G5U8.yaml @@ -0,0 +1,13 @@ +--- +- name: Plain dashes in flow sequence + from: '@ingydotnet' + tags: flow sequence + fail: true + yaml: | + --- + - [-, -] + tree: | + +STR + +DOC --- + +SEQ + +SEQ [] diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G7JE.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G7JE.yaml new file mode 100644 index 0000000..6c075a0 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G7JE.yaml @@ -0,0 +1,15 @@ +--- +- name: Multiline implicit keys + from: '@perlpunk' + tags: error mapping + fail: true + yaml: | + a\nb: 1 + c + d: 1 + tree: | + +STR + +DOC + +MAP + =VAL :a\\nb + =VAL :1 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G992.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G992.yaml new file mode 100644 index 0000000..8a57df8 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G992.yaml @@ -0,0 +1,21 @@ +--- +- name: Spec Example 8.9. Folded Scalar + from: http://www.yaml.org/spec/1.2/spec.html#id2796371 + tags: spec folded scalar 1.3-err + yaml: | + > + folded + text + ↵ + ↵ + tree: | + +STR + +DOC + =VAL >folded text\n + -DOC + -STR + json: | + "folded text\n" + dump: | + > + folded text diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G9HC.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G9HC.yaml new file mode 100644 index 0000000..227a6ed --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/G9HC.yaml @@ -0,0 +1,16 @@ +--- +- name: Invalid anchor in zero indented sequence + from: '@perlpunk' + tags: anchor error sequence + fail: true + yaml: | + --- + seq: + &anchor + - a + - b + tree: | + +STR + +DOC --- + +MAP + =VAL :seq diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/GDY7.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/GDY7.yaml new file mode 100644 index 0000000..6962ecc --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/GDY7.yaml @@ -0,0 +1,14 @@ +--- +- name: Comment that looks like a mapping key + from: '@perlpunk' + tags: comment error mapping + fail: true + yaml: | + key: value + this is #not a: key + tree: | + +STR + +DOC + +MAP + =VAL :key + =VAL :value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/GH63.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/GH63.yaml new file mode 100644 index 0000000..fda8c77 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/GH63.yaml @@ -0,0 +1,27 @@ +--- +- name: Mixed Block Mapping (explicit to implicit) + from: NimYAML tests + tags: explicit-key mapping + yaml: | + ? a + : 1.3 + fifteen: d + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL :1.3 + =VAL :fifteen + =VAL :d + -MAP + -DOC + -STR + json: | + { + "a": 1.3, + "fifteen": "d" + } + dump: | + a: 1.3 + fifteen: d diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/GT5M.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/GT5M.yaml new file mode 100644 index 0000000..9c951af --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/GT5M.yaml @@ -0,0 +1,14 @@ +--- +- name: Node anchor in sequence + from: '@perlpunk' + tags: anchor error sequence + fail: true + yaml: | + - item1 + &node + - item2 + tree: | + +STR + +DOC + +SEQ + =VAL :item1 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H2RW.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H2RW.yaml new file mode 100644 index 0000000..1a65a14 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H2RW.yaml @@ -0,0 +1,51 @@ +--- +- name: Blank lines + from: IRC discussion with leont + tags: comment literal scalar whitespace + yaml: | + foo: 1 + + bar: 2 + ␣␣␣␣ + text: | + a + ␣␣␣␣ + b + + c + ␣ + d + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :1 + =VAL :bar + =VAL :2 + =VAL :text + =VAL |a\n \nb\n\nc\n\nd\n + -MAP + -DOC + -STR + json: | + { + "foo": 1, + "bar": 2, + "text": "a\n \nb\n\nc\n\nd\n" + } + dump: | + foo: 1 + bar: 2 + text: "a\n \nb\n\nc\n\nd\n" + emit: | + foo: 1 + bar: 2 + text: | + a + ␣␣␣␣ + b + + c + + d diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H3Z8.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H3Z8.yaml new file mode 100644 index 0000000..ff988d2 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H3Z8.yaml @@ -0,0 +1,23 @@ +--- +- name: Literal unicode + from: '@perlpunk' + tags: scalar + yaml: | + --- + wanted: love ♥ and peace ☮ + tree: | + +STR + +DOC --- + +MAP + =VAL :wanted + =VAL :love ♥ and peace ☮ + -MAP + -DOC + -STR + json: | + { + "wanted": "love ♥ and peace ☮" + } + dump: | + --- + wanted: "love \u2665 and peace \u262E" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H7J7.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H7J7.yaml new file mode 100644 index 0000000..009d9e3 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H7J7.yaml @@ -0,0 +1,15 @@ +--- +- name: Node anchor not indented + from: https://gist.github.com/anonymous/f192e7dab6da31831f264dbf1947cb83 via @ingydotnet + tags: anchor error indent tag + fail: true + yaml: | + key: &x + !!map + a: b + tree: | + +STR + +DOC + +MAP + =VAL :key + =VAL &x : diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H7TQ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H7TQ.yaml new file mode 100644 index 0000000..c8d4065 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/H7TQ.yaml @@ -0,0 +1,10 @@ +--- +- name: Extra words on %YAML directive + from: '@ingydotnet' + tags: directive + fail: true + yaml: | + %YAML 1.2 foo + --- + tree: | + +STR diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HM87.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HM87.yaml new file mode 100644 index 0000000..7b54f49 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HM87.yaml @@ -0,0 +1,37 @@ +--- +- name: Scalars in flow start with syntax char + from: '@ingydotnet' + tags: flow scalar + yaml: | + [:x] + tree: | + +STR + +DOC + +SEQ [] + =VAL ::x + -SEQ + -DOC + -STR + json: | + [ + ":x" + ] + dump: | + - :x + +- yaml: | + [?x] + tree: | + +STR + +DOC + +SEQ [] + =VAL :?x + -SEQ + -DOC + -STR + json: | + [ + "?x" + ] + dump: | + - ?x diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HMK4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HMK4.yaml new file mode 100644 index 0000000..c4c248b --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HMK4.yaml @@ -0,0 +1,38 @@ +--- +- name: Spec Example 2.16. Indentation determines scope + from: http://www.yaml.org/spec/1.2/spec.html#id2761083 + tags: spec folded literal + yaml: | + name: Mark McGwire + accomplishment: > + Mark set a major league + home run record in 1998. + stats: | + 65 Home Runs + 0.278 Batting Average + tree: | + +STR + +DOC + +MAP + =VAL :name + =VAL :Mark McGwire + =VAL :accomplishment + =VAL >Mark set a major league home run record in 1998.\n + =VAL :stats + =VAL |65 Home Runs\n0.278 Batting Average\n + -MAP + -DOC + -STR + json: | + { + "name": "Mark McGwire", + "accomplishment": "Mark set a major league home run record in 1998.\n", + "stats": "65 Home Runs\n0.278 Batting Average\n" + } + dump: | + name: Mark McGwire + accomplishment: > + Mark set a major league home run record in 1998. + stats: | + 65 Home Runs + 0.278 Batting Average diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HMQ5.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HMQ5.yaml new file mode 100644 index 0000000..a645764 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HMQ5.yaml @@ -0,0 +1,27 @@ +--- +- name: Spec Example 6.23. Node Properties + from: http://www.yaml.org/spec/1.2/spec.html#id2783940 + tags: spec tag alias + yaml: | + !!str &a1 "foo": + !!str bar + &a2 baz : *a1 + tree: | + +STR + +DOC + +MAP + =VAL &a1 "foo + =VAL :bar + =VAL &a2 :baz + =ALI *a1 + -MAP + -DOC + -STR + json: | + { + "foo": "bar", + "baz": "foo" + } + dump: | + &a1 !!str "foo": !!str bar + &a2 baz: *a1 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HRE5.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HRE5.yaml new file mode 100644 index 0000000..f4d4236 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HRE5.yaml @@ -0,0 +1,13 @@ +--- +- name: Double quoted scalar with escaped single quote + from: https://github.com/yaml/libyaml/issues/68 + tags: double error single + fail: true + yaml: | + --- + double: "quoted \' scalar" + tree: | + +STR + +DOC --- + +MAP + =VAL :double diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HS5T.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HS5T.yaml new file mode 100644 index 0000000..9a24d17 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HS5T.yaml @@ -0,0 +1,21 @@ +--- +- name: Spec Example 7.12. Plain Lines + from: http://www.yaml.org/spec/1.2/spec.html#id2789986 + tags: spec scalar whitespace upto-1.2 + yaml: | + 1st non-empty + + 2nd non-empty␣ + ———»3rd non-empty + tree: | + +STR + +DOC + =VAL :1st non-empty\n2nd non-empty 3rd non-empty + -DOC + -STR + json: | + "1st non-empty\n2nd non-empty 3rd non-empty" + dump: | + '1st non-empty + + 2nd non-empty 3rd non-empty' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HU3P.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HU3P.yaml new file mode 100644 index 0000000..537d97a --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HU3P.yaml @@ -0,0 +1,14 @@ +--- +- name: Invalid Mapping in plain scalar + from: https://gist.github.com/anonymous/d305fd8e54cfe7a484088c91a8a2e533 via @ingydotnet + tags: error mapping scalar + fail: true + yaml: | + key: + word1 word2 + no: key + tree: | + +STR + +DOC + +MAP + =VAL :key diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HWV9.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HWV9.yaml new file mode 100644 index 0000000..1e8264d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/HWV9.yaml @@ -0,0 +1,11 @@ +--- +- name: Document-end marker + from: '@perlpunk' + tags: footer + yaml: | + ... + tree: | + +STR + -STR + json: '' + dump: '' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J3BT.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J3BT.yaml new file mode 100644 index 0000000..f7d766d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J3BT.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 5.12. Tabs and Spaces + from: http://www.yaml.org/spec/1.2/spec.html#id2775350 + tags: spec whitespace upto-1.2 + yaml: | + # Tabs and spaces + quoted: "Quoted ———»" + block:—»| + void main() { + —»printf("Hello, world!\n"); + } + tree: | + +STR + +DOC + +MAP + =VAL :quoted + =VAL "Quoted \t + =VAL :block + =VAL |void main() {\n\tprintf("Hello, world!\\n");\n}\n + -MAP + -DOC + -STR + json: | + { + "quoted": "Quoted \t", + "block": "void main() {\n\tprintf(\"Hello, world!\\n\");\n}\n" + } + dump: | + quoted: "Quoted \t" + block: | + void main() { + —»printf("Hello, world!\n"); + } diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J5UC.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J5UC.yaml new file mode 100644 index 0000000..6690568 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J5UC.yaml @@ -0,0 +1,27 @@ +--- +- name: Multiple Pair Block Mapping + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml + tags: mapping + yaml: | + foo: blue + bar: arrr + baz: jazz + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :blue + =VAL :bar + =VAL :arrr + =VAL :baz + =VAL :jazz + -MAP + -DOC + -STR + json: | + { + "foo": "blue", + "bar": "arrr", + "baz": "jazz" + } diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J7PZ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J7PZ.yaml new file mode 100644 index 0000000..9183bae --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J7PZ.yaml @@ -0,0 +1,52 @@ +--- +- name: Spec Example 2.26. Ordered Mappings + from: http://www.yaml.org/spec/1.2/spec.html#id2761780 + tags: spec mapping tag unknown-tag + yaml: | + # The !!omap tag is one of the optional types + # introduced for YAML 1.1. In 1.2, it is not + # part of the standard tags and should not be + # enabled by default. + # Ordered maps are represented as + # A sequence of mappings, with + # each mapping having one key + --- !!omap + - Mark McGwire: 65 + - Sammy Sosa: 63 + - Ken Griffy: 58 + tree: | + +STR + +DOC --- + +SEQ + +MAP + =VAL :Mark McGwire + =VAL :65 + -MAP + +MAP + =VAL :Sammy Sosa + =VAL :63 + -MAP + +MAP + =VAL :Ken Griffy + =VAL :58 + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "Mark McGwire": 65 + }, + { + "Sammy Sosa": 63 + }, + { + "Ken Griffy": 58 + } + ] + dump: | + --- !!omap + - Mark McGwire: 65 + - Sammy Sosa: 63 + - Ken Griffy: 58 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J7VC.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J7VC.yaml new file mode 100644 index 0000000..1676809 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J7VC.yaml @@ -0,0 +1,28 @@ +--- +- name: Empty Lines Between Mapping Elements + from: NimYAML tests + tags: whitespace mapping + yaml: | + one: 2 + + + three: 4 + tree: | + +STR + +DOC + +MAP + =VAL :one + =VAL :2 + =VAL :three + =VAL :4 + -MAP + -DOC + -STR + json: | + { + "one": 2, + "three": 4 + } + dump: | + one: 2 + three: 4 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J9HZ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J9HZ.yaml new file mode 100644 index 0000000..85ddbdf --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/J9HZ.yaml @@ -0,0 +1,49 @@ +--- +- name: Spec Example 2.9. Single Document with Two Comments + from: http://www.yaml.org/spec/1.2/spec.html#id2760633 + tags: mapping sequence spec comment + yaml: | + --- + hr: # 1998 hr ranking + - Mark McGwire + - Sammy Sosa + rbi: + # 1998 rbi ranking + - Sammy Sosa + - Ken Griffey + tree: | + +STR + +DOC --- + +MAP + =VAL :hr + +SEQ + =VAL :Mark McGwire + =VAL :Sammy Sosa + -SEQ + =VAL :rbi + +SEQ + =VAL :Sammy Sosa + =VAL :Ken Griffey + -SEQ + -MAP + -DOC + -STR + json: | + { + "hr": [ + "Mark McGwire", + "Sammy Sosa" + ], + "rbi": [ + "Sammy Sosa", + "Ken Griffey" + ] + } + dump: | + --- + hr: + - Mark McGwire + - Sammy Sosa + rbi: + - Sammy Sosa + - Ken Griffey diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JEF9.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JEF9.yaml new file mode 100644 index 0000000..9dd0d72 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JEF9.yaml @@ -0,0 +1,53 @@ +--- +- name: Trailing whitespace in streams + from: '@ingydotnet' + tags: literal + yaml: | + - |+ + ↵ + ↵ + tree: | + +STR + +DOC + +SEQ + =VAL |\n\n + -SEQ + -DOC + -STR + json: | + [ + "\n\n" + ] + dump: | + - |+ + ↵ + ↵ + ... + +- yaml: | + - |+ + ␣␣␣ + tree: | + +STR + +DOC + +SEQ + =VAL |\n + -SEQ + -DOC + -STR + json: | + [ + "\n" + ] + dump: | + - |+ + + ... + +- yaml: | + - |+ + ␣␣␣∎ + dump: | + - |+ + + ... diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JHB9.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JHB9.yaml new file mode 100644 index 0000000..c09dee0 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JHB9.yaml @@ -0,0 +1,49 @@ +--- +- name: Spec Example 2.7. Two Documents in a Stream + from: http://www.yaml.org/spec/1.2/spec.html#id2760493 + tags: spec header + yaml: | + # Ranking of 1998 home runs + --- + - Mark McGwire + - Sammy Sosa + - Ken Griffey + + # Team ranking + --- + - Chicago Cubs + - St Louis Cardinals + tree: | + +STR + +DOC --- + +SEQ + =VAL :Mark McGwire + =VAL :Sammy Sosa + =VAL :Ken Griffey + -SEQ + -DOC + +DOC --- + +SEQ + =VAL :Chicago Cubs + =VAL :St Louis Cardinals + -SEQ + -DOC + -STR + json: | + [ + "Mark McGwire", + "Sammy Sosa", + "Ken Griffey" + ] + [ + "Chicago Cubs", + "St Louis Cardinals" + ] + dump: | + --- + - Mark McGwire + - Sammy Sosa + - Ken Griffey + --- + - Chicago Cubs + - St Louis Cardinals diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JKF3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JKF3.yaml new file mode 100644 index 0000000..b387deb --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JKF3.yaml @@ -0,0 +1,13 @@ +--- +- name: Multiline unidented double quoted block key + from: '@ingydotnet' + tags: indent + fail: true + yaml: | + - - "bar + bar": x + tree: | + +STR + +DOC + +SEQ + +SEQ diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JQ4R.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JQ4R.yaml new file mode 100644 index 0000000..f14ed82 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JQ4R.yaml @@ -0,0 +1,36 @@ +--- +- name: Spec Example 8.14. Block Sequence + from: http://www.yaml.org/spec/1.2/spec.html#id2797596 + tags: mapping spec sequence + yaml: | + block sequence: + - one + - two : three + tree: | + +STR + +DOC + +MAP + =VAL :block sequence + +SEQ + =VAL :one + +MAP + =VAL :two + =VAL :three + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "block sequence": [ + "one", + { + "two": "three" + } + ] + } + dump: | + block sequence: + - one + - two: three diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JR7V.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JR7V.yaml new file mode 100644 index 0000000..3971f8b --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JR7V.yaml @@ -0,0 +1,76 @@ +--- +- name: Question marks in scalars + from: '@perlpunk' + tags: flow scalar + yaml: | + - a?string + - another ? string + - key: value? + - [a?string] + - [another ? string] + - {key: value? } + - {key: value?} + - {key?: value } + tree: | + +STR + +DOC + +SEQ + =VAL :a?string + =VAL :another ? string + +MAP + =VAL :key + =VAL :value? + -MAP + +SEQ [] + =VAL :a?string + -SEQ + +SEQ [] + =VAL :another ? string + -SEQ + +MAP {} + =VAL :key + =VAL :value? + -MAP + +MAP {} + =VAL :key + =VAL :value? + -MAP + +MAP {} + =VAL :key? + =VAL :value + -MAP + -SEQ + -DOC + -STR + json: | + [ + "a?string", + "another ? string", + { + "key": "value?" + }, + [ + "a?string" + ], + [ + "another ? string" + ], + { + "key": "value?" + }, + { + "key": "value?" + }, + { + "key?": "value" + } + ] + dump: | + - a?string + - another ? string + - key: value? + - - a?string + - - another ? string + - key: value? + - key: value? + - key?: value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JS2J.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JS2J.yaml new file mode 100644 index 0000000..3545da3 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JS2J.yaml @@ -0,0 +1,23 @@ +--- +- name: Spec Example 6.29. Node Anchors + from: http://www.yaml.org/spec/1.2/spec.html#id2785977 + tags: spec alias + yaml: | + First occurrence: &anchor Value + Second occurrence: *anchor + tree: | + +STR + +DOC + +MAP + =VAL :First occurrence + =VAL &anchor :Value + =VAL :Second occurrence + =ALI *anchor + -MAP + -DOC + -STR + json: | + { + "First occurrence": "Value", + "Second occurrence": "Value" + } diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JTV5.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JTV5.yaml new file mode 100644 index 0000000..e099a3a --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JTV5.yaml @@ -0,0 +1,30 @@ +--- +- name: Block Mapping with Multiline Scalars + from: NimYAML tests + tags: explicit-key mapping scalar + yaml: | + ? a + true + : null + d + ? e + 42 + tree: | + +STR + +DOC + +MAP + =VAL :a true + =VAL :null d + =VAL :e 42 + =VAL : + -MAP + -DOC + -STR + json: | + { + "a true": "null d", + "e 42": null + } + dump: | + a true: null d + e 42: diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JY7Z.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JY7Z.yaml new file mode 100644 index 0000000..fb4dfae --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/JY7Z.yaml @@ -0,0 +1,17 @@ +--- +- name: Trailing content that looks like a mapping + from: '@perlpunk' + tags: error mapping double + fail: true + yaml: | + key1: "quoted1" + key2: "quoted2" no key: nor value + key3: "quoted3" + tree: | + +STR + +DOC + +MAP + =VAL :key1 + =VAL "quoted1 + =VAL :key2 + =VAL "quoted2 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K3WX.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K3WX.yaml new file mode 100644 index 0000000..5de2c1c --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K3WX.yaml @@ -0,0 +1,24 @@ +--- +- name: Colon and adjacent value after comment on next line + from: + tags: comment flow mapping + yaml: | + --- + { "foo" # comment + :bar } + tree: | + +STR + +DOC --- + +MAP {} + =VAL "foo + =VAL :bar + -MAP + -DOC + -STR + json: | + { + "foo": "bar" + } + dump: | + --- + "foo": bar diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K4SU.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K4SU.yaml new file mode 100644 index 0000000..c67005a --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K4SU.yaml @@ -0,0 +1,24 @@ +--- +- name: Multiple Entry Block Sequence + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/sequence.tml + tags: sequence + yaml: | + - foo + - bar + - 42 + tree: | + +STR + +DOC + +SEQ + =VAL :foo + =VAL :bar + =VAL :42 + -SEQ + -DOC + -STR + json: | + [ + "foo", + "bar", + 42 + ] diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K527.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K527.yaml new file mode 100644 index 0000000..1fd0e8c --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K527.yaml @@ -0,0 +1,27 @@ +--- +- name: Spec Example 6.6. Line Folding + from: http://www.yaml.org/spec/1.2/spec.html#id2779289 + tags: folded spec whitespace scalar 1.3-err + yaml: | + >- + trimmed + ␣␣ + ␣ + + as + space + tree: | + +STR + +DOC + =VAL >trimmed\n\n\nas space + -DOC + -STR + json: | + "trimmed\n\n\nas space" + dump: | + >- + trimmed + + + + as space diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K54U.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K54U.yaml new file mode 100644 index 0000000..63f6da8 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K54U.yaml @@ -0,0 +1,17 @@ +--- +- name: Tab after document header + from: '@perlpunk' + tags: header whitespace + yaml: | + ---»scalar + tree: | + +STR + +DOC --- + =VAL :scalar + -DOC + -STR + json: | + "scalar" + dump: | + --- scalar + ... diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K858.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K858.yaml new file mode 100644 index 0000000..c7b077c --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/K858.yaml @@ -0,0 +1,36 @@ +--- +- name: Spec Example 8.6. Empty Scalar Chomping + from: http://www.yaml.org/spec/1.2/spec.html#id2795596 + tags: spec folded literal whitespace + yaml: | + strip: >- + + clip: > + + keep: |+ + ↵ + tree: | + +STR + +DOC + +MAP + =VAL :strip + =VAL > + =VAL :clip + =VAL > + =VAL :keep + =VAL |\n + -MAP + -DOC + -STR + json: | + { + "strip": "", + "clip": "", + "keep": "\n" + } + dump: | + strip: "" + clip: "" + keep: |2+ + + ... diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KH5V.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KH5V.yaml new file mode 100644 index 0000000..9a87698 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KH5V.yaml @@ -0,0 +1,40 @@ +--- +- name: Inline tabs in double quoted + from: '@ingydotnet' + tags: double whitespace + yaml: | + "1 inline\ttab" + tree: | + +STR + +DOC + =VAL "1 inline\ttab + -DOC + -STR + json: | + "1 inline\ttab" + +- yaml: | + "2 inline\——»tab" + tree: | + +STR + +DOC + =VAL "2 inline\ttab + -DOC + -STR + json: | + "2 inline\ttab" + dump: | + "2 inline\ttab" + +- yaml: | + "3 inline———»tab" + tree: | + +STR + +DOC + =VAL "3 inline\ttab + -DOC + -STR + json: | + "3 inline\ttab" + dump: | + "3 inline\ttab" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KK5P.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KK5P.yaml new file mode 100644 index 0000000..ff564f2 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KK5P.yaml @@ -0,0 +1,81 @@ +--- +- name: Various combinations of explicit block mappings + from: '@perlpunk' + tags: explicit-key mapping sequence + yaml: | + complex1: + ? - a + complex2: + ? - a + : b + complex3: + ? - a + : > + b + complex4: + ? > + a + : + complex5: + ? - a + : - b + tree: | + +STR + +DOC + +MAP + =VAL :complex1 + +MAP + +SEQ + =VAL :a + -SEQ + =VAL : + -MAP + =VAL :complex2 + +MAP + +SEQ + =VAL :a + -SEQ + =VAL :b + -MAP + =VAL :complex3 + +MAP + +SEQ + =VAL :a + -SEQ + =VAL >b\n + -MAP + =VAL :complex4 + +MAP + =VAL >a\n + =VAL : + -MAP + =VAL :complex5 + +MAP + +SEQ + =VAL :a + -SEQ + +SEQ + =VAL :b + -SEQ + -MAP + -MAP + -DOC + -STR + dump: | + complex1: + ? - a + : + complex2: + ? - a + : b + complex3: + ? - a + : > + b + complex4: + ? > + a + : + complex5: + ? - a + : - b diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KMK3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KMK3.yaml new file mode 100644 index 0000000..4c6b460 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KMK3.yaml @@ -0,0 +1,29 @@ +--- +- name: Block Submapping + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml + tags: mapping + yaml: | + foo: + bar: 1 + baz: 2 + tree: | + +STR + +DOC + +MAP + =VAL :foo + +MAP + =VAL :bar + =VAL :1 + -MAP + =VAL :baz + =VAL :2 + -MAP + -DOC + -STR + json: | + { + "foo": { + "bar": 1 + }, + "baz": 2 + } diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KS4U.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KS4U.yaml new file mode 100644 index 0000000..35c0a44 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KS4U.yaml @@ -0,0 +1,17 @@ +--- +- name: Invalid item after end of flow sequence + from: '@perlpunk' + tags: error flow sequence + fail: true + yaml: | + --- + [ + sequence item + ] + invalid item + tree: | + +STR + +DOC --- + +SEQ [] + =VAL :sequence item + -SEQ diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KSS4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KSS4.yaml new file mode 100644 index 0000000..518c20c --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/KSS4.yaml @@ -0,0 +1,27 @@ +--- +- name: Scalars on --- line + from: '@perlpunk' + tags: anchor header scalar 1.3-err + yaml: | + --- "quoted + string" + --- &node foo + tree: | + +STR + +DOC --- + =VAL "quoted string + -DOC + +DOC --- + =VAL &node :foo + -DOC + -STR + json: | + "quoted string" + "foo" + dump: | + --- "quoted string" + --- &node foo + ... + emit: | + --- "quoted string" + --- &node foo diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L24T.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L24T.yaml new file mode 100644 index 0000000..a58e9b2 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L24T.yaml @@ -0,0 +1,45 @@ +--- +- name: Trailing line of spaces + from: '@ingydotnet' + tags: whitespace + yaml: | + foo: | + x + ␣␣␣ + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL |x\n \n + -MAP + -DOC + -STR + json: | + { + "foo" : "x\n \n" + } + emit: | + --- + foo: "x\n \n" + +- yaml: | + foo: | + x + ␣␣␣∎ + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL |x\n \n + -MAP + -DOC + -STR + json: | + { + "foo" : "x\n \n" + } + emit: | + --- + foo: "x\n \n" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L383.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L383.yaml new file mode 100644 index 0000000..c298919 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L383.yaml @@ -0,0 +1,22 @@ +--- +- name: Two scalar docs with trailing comments + from: '@ingydotnet' + tags: comment + yaml: | + --- foo # comment + --- foo # comment + tree: | + +STR + +DOC --- + =VAL :foo + -DOC + +DOC --- + =VAL :foo + -DOC + -STR + json: | + "foo" + "foo" + dump: | + --- foo + --- foo diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L94M.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L94M.yaml new file mode 100644 index 0000000..2288c06 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L94M.yaml @@ -0,0 +1,28 @@ +--- +- name: Tags in Explicit Mapping + from: NimYAML tests + tags: explicit-key tag mapping + yaml: | + ? !!str a + : !!int 47 + ? c + : !!str d + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL :47 + =VAL :c + =VAL :d + -MAP + -DOC + -STR + json: | + { + "a": 47, + "c": "d" + } + dump: | + !!str a: !!int 47 + c: !!str d diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L9U5.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L9U5.yaml new file mode 100644 index 0000000..5e2ed0c --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/L9U5.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 7.11. Plain Implicit Keys + from: http://www.yaml.org/spec/1.2/spec.html#id2789794 + tags: spec flow mapping + yaml: | + implicit block key : [ + implicit flow key : value, + ] + tree: | + +STR + +DOC + +MAP + =VAL :implicit block key + +SEQ [] + +MAP {} + =VAL :implicit flow key + =VAL :value + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "implicit block key": [ + { + "implicit flow key": "value" + } + ] + } + dump: | + implicit block key: + - implicit flow key: value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LE5A.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LE5A.yaml new file mode 100644 index 0000000..21e1576 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LE5A.yaml @@ -0,0 +1,30 @@ +--- +- name: Spec Example 7.24. Flow Nodes + from: http://www.yaml.org/spec/1.2/spec.html#id2793490 + tags: spec tag alias + yaml: | + - !!str "a" + - 'b' + - &anchor "c" + - *anchor + - !!str + tree: | + +STR + +DOC + +SEQ + =VAL "a + =VAL 'b + =VAL &anchor "c + =ALI *anchor + =VAL : + -SEQ + -DOC + -STR + json: | + [ + "a", + "b", + "c", + "c", + "" + ] diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LHL4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LHL4.yaml new file mode 100644 index 0000000..8ecc9e0 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LHL4.yaml @@ -0,0 +1,11 @@ +--- +- name: Invalid tag + from: '@perlpunk' + tags: error tag + fail: true + yaml: | + --- + !invalid{}tag scalar + tree: | + +STR + +DOC --- diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LP6E.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LP6E.yaml new file mode 100644 index 0000000..52060f1 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LP6E.yaml @@ -0,0 +1,55 @@ +--- +- name: Whitespace After Scalars in Flow + from: NimYAML tests + tags: flow scalar whitespace + yaml: | + - [a, b , c ] + - { "a" : b + , c : 'd' , + e : "f" + } + - [ ] + tree: | + +STR + +DOC + +SEQ + +SEQ [] + =VAL :a + =VAL :b + =VAL :c + -SEQ + +MAP {} + =VAL "a + =VAL :b + =VAL :c + =VAL 'd + =VAL :e + =VAL "f + -MAP + +SEQ [] + -SEQ + -SEQ + -DOC + -STR + json: | + [ + [ + "a", + "b", + "c" + ], + { + "a": "b", + "c": "d", + "e": "f" + }, + [] + ] + dump: | + - - a + - b + - c + - "a": b + c: 'd' + e: "f" + - [] diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LQZ7.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LQZ7.yaml new file mode 100644 index 0000000..5bb7576 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LQZ7.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 7.4. Double Quoted Implicit Keys + from: http://www.yaml.org/spec/1.2/spec.html#id2787420 + tags: spec scalar flow + yaml: | + "implicit block key" : [ + "implicit flow key" : value, + ] + tree: | + +STR + +DOC + +MAP + =VAL "implicit block key + +SEQ [] + +MAP {} + =VAL "implicit flow key + =VAL :value + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "implicit block key": [ + { + "implicit flow key": "value" + } + ] + } + dump: | + "implicit block key": + - "implicit flow key": value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LX3P.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LX3P.yaml new file mode 100644 index 0000000..e5ebb6b --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/LX3P.yaml @@ -0,0 +1,20 @@ +--- +- name: Implicit Flow Mapping Key on one line + from: '@perlpunk' + tags: complex-key mapping flow sequence 1.3-err + yaml: | + [flow]: block + tree: | + +STR + +DOC + +MAP + +SEQ [] + =VAL :flow + -SEQ + =VAL :block + -MAP + -DOC + -STR + dump: | + ? - flow + : block diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M29M.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M29M.yaml new file mode 100644 index 0000000..370ff21 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M29M.yaml @@ -0,0 +1,33 @@ +--- +- name: Literal Block Scalar + from: NimYAML tests + tags: literal scalar whitespace + yaml: | + a: | + ab + ␣ + cd + ef + ␣ + + ... + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL |ab\n\ncd\nef\n + -MAP + -DOC ... + -STR + json: | + { + "a": "ab\n\ncd\nef\n" + } + dump: | + a: | + ab + + cd + ef + ... diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M2N8.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M2N8.yaml new file mode 100644 index 0000000..3df5481 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M2N8.yaml @@ -0,0 +1,42 @@ +--- +- name: Question mark edge cases + from: '@ingydotnet' + tags: edge empty-key + yaml: | + - ? : x + tree: | + +STR + +DOC + +SEQ + +MAP + +MAP + =VAL : + =VAL :x + -MAP + =VAL : + -MAP + -SEQ + -DOC + -STR + dump: | + - ? : x + : + +- yaml: | + ? []: x + tree: | + +STR + +DOC + +MAP + +MAP + +SEQ [] + -SEQ + =VAL :x + -MAP + =VAL : + -MAP + -DOC + -STR + dump: | + ? []: x + : diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M5C3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M5C3.yaml new file mode 100644 index 0000000..c0075c1 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M5C3.yaml @@ -0,0 +1,32 @@ +--- +- name: Spec Example 8.21. Block Scalar Nodes + from: http://www.yaml.org/spec/1.2/spec.html#id2799693 + tags: indent spec literal folded tag local-tag 1.3-err + yaml: | + literal: |2 + value + folded: + !foo + >1 + value + tree: | + +STR + +DOC + +MAP + =VAL :literal + =VAL |value\n + =VAL :folded + =VAL >value\n + -MAP + -DOC + -STR + json: | + { + "literal": "value\n", + "folded": "value\n" + } + dump: | + literal: | + value + folded: !foo > + value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M5DY.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M5DY.yaml new file mode 100644 index 0000000..8a97c16 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M5DY.yaml @@ -0,0 +1,46 @@ +--- +- name: Spec Example 2.11. Mapping between Sequences + from: http://www.yaml.org/spec/1.2/spec.html#id2760799 + tags: complex-key explicit-key spec mapping sequence + yaml: | + ? - Detroit Tigers + - Chicago cubs + : + - 2001-07-23 + + ? [ New York Yankees, + Atlanta Braves ] + : [ 2001-07-02, 2001-08-12, + 2001-08-14 ] + tree: | + +STR + +DOC + +MAP + +SEQ + =VAL :Detroit Tigers + =VAL :Chicago cubs + -SEQ + +SEQ + =VAL :2001-07-23 + -SEQ + +SEQ [] + =VAL :New York Yankees + =VAL :Atlanta Braves + -SEQ + +SEQ [] + =VAL :2001-07-02 + =VAL :2001-08-12 + =VAL :2001-08-14 + -SEQ + -MAP + -DOC + -STR + dump: | + ? - Detroit Tigers + - Chicago cubs + : - 2001-07-23 + ? - New York Yankees + - Atlanta Braves + : - 2001-07-02 + - 2001-08-12 + - 2001-08-14 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M6YH.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M6YH.yaml new file mode 100644 index 0000000..97f7618 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M6YH.yaml @@ -0,0 +1,41 @@ +--- +- name: Block sequence indentation + from: '@ingydotnet' + tags: indent + yaml: | + - | + x + - + foo: bar + - + - 42 + tree: | + +STR + +DOC + +SEQ + =VAL |x\n + +MAP + =VAL :foo + =VAL :bar + -MAP + +SEQ + =VAL :42 + -SEQ + -SEQ + -DOC + -STR + json: | + [ + "x\n", + { + "foo" : "bar" + }, + [ + 42 + ] + ] + dump: | + - | + x + - foo: bar + - - 42 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M7A3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M7A3.yaml new file mode 100644 index 0000000..65a7c49 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M7A3.yaml @@ -0,0 +1,29 @@ +--- +- name: Spec Example 9.3. Bare Documents + from: http://www.yaml.org/spec/1.2/spec.html#id2801226 + tags: spec footer 1.3-err + yaml: | + Bare + document + ... + # No document + ... + | + %!PS-Adobe-2.0 # Not the first line + tree: | + +STR + +DOC + =VAL :Bare document + -DOC ... + +DOC + =VAL |%!PS-Adobe-2.0 # Not the first line\n + -DOC + -STR + json: | + "Bare document" + "%!PS-Adobe-2.0 # Not the first line\n" + emit: | + Bare document + ... + | + %!PS-Adobe-2.0 # Not the first line diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M7NX.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M7NX.yaml new file mode 100644 index 0000000..fa12450 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M7NX.yaml @@ -0,0 +1,53 @@ +--- +- name: Nested flow collections + from: '@perlpunk' + tags: flow mapping sequence + yaml: | + --- + { + a: [ + b, c, { + d: [e, f] + } + ] + } + tree: | + +STR + +DOC --- + +MAP {} + =VAL :a + +SEQ [] + =VAL :b + =VAL :c + +MAP {} + =VAL :d + +SEQ [] + =VAL :e + =VAL :f + -SEQ + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "a": [ + "b", + "c", + { + "d": [ + "e", + "f" + ] + } + ] + } + dump: | + --- + a: + - b + - c + - d: + - e + - f diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M9B4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M9B4.yaml new file mode 100644 index 0000000..910b0ce --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/M9B4.yaml @@ -0,0 +1,22 @@ +--- +- name: Spec Example 8.7. Literal Scalar + from: http://www.yaml.org/spec/1.2/spec.html#id2795789 + tags: spec literal scalar whitespace 1.3-err + yaml: | + | + literal + ——»text + ↵ + ↵ + tree: | + +STR + +DOC + =VAL |literal\n\ttext\n + -DOC + -STR + json: | + "literal\n\ttext\n" + dump: | + | + literal + —»text diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MJS9.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MJS9.yaml new file mode 100644 index 0000000..d497410 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MJS9.yaml @@ -0,0 +1,21 @@ +--- +- name: Spec Example 6.7. Block Folding + from: http://www.yaml.org/spec/1.2/spec.html#id2779603 + tags: folded spec scalar whitespace 1.3-err + yaml: | + > + foo␣ + ␣ + —» bar + + baz + tree: | + +STR + +DOC + =VAL >foo \n\n\t bar\n\nbaz\n + -DOC + -STR + json: | + "foo \n\n\t bar\n\nbaz\n" + dump: | + "foo \n\n\t bar\n\nbaz\n" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MUS6.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MUS6.yaml new file mode 100644 index 0000000..9208fc7 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MUS6.yaml @@ -0,0 +1,49 @@ +- name: Directive variants + from: '@ingydotnet' + tags: directive + also: ZYU8 + fail: true + yaml: | + %YAML 1.1#... + --- + tree: | + +STR + +- fail: true + yaml: | + %YAML 1.2 + --- + %YAML 1.2 + --- + dump: null + +- yaml: | + %YAML 1.1 + --- + tree: | + +STR + +DOC --- + =VAL : + -DOC + -STR + json: | + null + dump: | + --- + +- yaml: | + %YAML ——» 1.1 + --- + +- yaml: | + %YAML 1.1 # comment + --- + +- note: These 2 are reserved directives + yaml: | + %YAM 1.1 + --- + +- yaml: | + %YAMLL 1.1 + --- diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MXS3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MXS3.yaml new file mode 100644 index 0000000..ceab9ec --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MXS3.yaml @@ -0,0 +1,25 @@ +--- +- name: Flow Mapping in Block Sequence + from: NimYAML tests + tags: mapping sequence flow + yaml: | + - {a: b} + tree: | + +STR + +DOC + +SEQ + +MAP {} + =VAL :a + =VAL :b + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "a": "b" + } + ] + dump: | + - a: b diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MYW6.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MYW6.yaml new file mode 100644 index 0000000..74fe5eb --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MYW6.yaml @@ -0,0 +1,22 @@ +--- +- name: Block Scalar Strip + from: NimYAML tests + tags: literal scalar whitespace 1.3-err + yaml: | + |- + ab + ␣ + ␣ + ... + tree: | + +STR + +DOC + =VAL |ab + -DOC ... + -STR + json: | + "ab" + dump: | + |- + ab + ... diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MZX3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MZX3.yaml new file mode 100644 index 0000000..0b985b8 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/MZX3.yaml @@ -0,0 +1,31 @@ +--- +- name: Non-Specific Tags on Scalars + from: NimYAML tests + tags: folded scalar + yaml: | + - plain + - "double quoted" + - 'single quoted' + - > + block + - plain again + tree: | + +STR + +DOC + +SEQ + =VAL :plain + =VAL "double quoted + =VAL 'single quoted + =VAL >block\n + =VAL :plain again + -SEQ + -DOC + -STR + json: | + [ + "plain", + "double quoted", + "single quoted", + "block\n", + "plain again" + ] diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/N4JP.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/N4JP.yaml new file mode 100644 index 0000000..51abed3 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/N4JP.yaml @@ -0,0 +1,18 @@ +--- +- name: Bad indentation in mapping + from: '@perlpunk' + tags: error mapping indent double + fail: true + yaml: | + map: + key1: "quoted1" + key2: "bad indentation" + tree: | + +STR + +DOC + +MAP + =VAL :map + +MAP + =VAL :key1 + =VAL "quoted1 + -MAP diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/N782.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/N782.yaml new file mode 100644 index 0000000..e08267b --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/N782.yaml @@ -0,0 +1,14 @@ +--- +- name: Invalid document markers in flow style + from: NimYAML tests + tags: flow edge header footer error + fail: true + yaml: | + [ + --- , + ... + ] + tree: | + +STR + +DOC + +SEQ [] diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NAT4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NAT4.yaml new file mode 100644 index 0000000..379c940 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NAT4.yaml @@ -0,0 +1,77 @@ +--- +- name: Various empty or newline only quoted strings + from: '@perlpunk' + tags: double scalar single whitespace + yaml: | + --- + a: ' + ' + b: '␣␣ + ' + c: " + " + d: "␣␣ + " + e: ' + + ' + f: " + + " + g: ' + + + ' + h: " + + + " + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL '␣ + =VAL :b + =VAL '␣ + =VAL :c + =VAL "␣ + =VAL :d + =VAL "␣ + =VAL :e + =VAL '\n + =VAL :f + =VAL "\n + =VAL :g + =VAL '\n\n + =VAL :h + =VAL "\n\n + -MAP + -DOC + -STR + json: | + { + "a": " ", + "b": " ", + "c": " ", + "d": " ", + "e": "\n", + "f": "\n", + "g": "\n\n", + "h": "\n\n" + } + emit: | + --- + a: ' ' + b: ' ' + c: " " + d: " " + e: ' + + ' + f: "\n" + g: ' + + + ' + h: "\n\n" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NB6Z.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NB6Z.yaml new file mode 100644 index 0000000..0bc9f1e --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NB6Z.yaml @@ -0,0 +1,27 @@ +--- +- name: Multiline plain value with tabs on empty lines + from: '@perlpunk' + tags: scalar whitespace + yaml: | + key: + value + with + —» + tabs + tree: | + +STR + +DOC + +MAP + =VAL :key + =VAL :value with\ntabs + -MAP + -DOC + -STR + json: | + { + "key": "value with\ntabs" + } + dump: | + key: 'value with + + tabs' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NHX8.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NHX8.yaml new file mode 100644 index 0000000..e8b9978 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NHX8.yaml @@ -0,0 +1,19 @@ +--- +- name: Empty Lines at End of Document + from: NimYAML tests + tags: empty-key whitespace + yaml: | + : + ↵ + ↵ + tree: | + +STR + +DOC + +MAP + =VAL : + =VAL : + -MAP + -DOC + -STR + emit: | + : diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NJ66.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NJ66.yaml new file mode 100644 index 0000000..e7d98b3 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NJ66.yaml @@ -0,0 +1,37 @@ +--- +- name: Multiline plain flow mapping key + from: '@perlpunk' + tags: flow mapping + yaml: | + --- + - { single line: value} + - { multi + line: value} + tree: | + +STR + +DOC --- + +SEQ + +MAP {} + =VAL :single line + =VAL :value + -MAP + +MAP {} + =VAL :multi line + =VAL :value + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "single line": "value" + }, + { + "multi line": "value" + } + ] + dump: | + --- + - single line: value + - multi line: value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NKF9.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NKF9.yaml new file mode 100644 index 0000000..fede8e1 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NKF9.yaml @@ -0,0 +1,60 @@ +--- +- name: Empty keys in block and flow mapping + from: '@perlpunk' + tags: empty-key mapping + yaml: | + --- + key: value + : empty key + --- + { + key: value, : empty key + } + --- + # empty key and value + : + --- + # empty key and value + { : } + tree: | + +STR + +DOC --- + +MAP + =VAL :key + =VAL :value + =VAL : + =VAL :empty key + -MAP + -DOC + +DOC --- + +MAP {} + =VAL :key + =VAL :value + =VAL : + =VAL :empty key + -MAP + -DOC + +DOC --- + +MAP + =VAL : + =VAL : + -MAP + -DOC + +DOC --- + +MAP {} + =VAL : + =VAL : + -MAP + -DOC + -STR + emit: | + --- + key: value + : empty key + --- + key: value + : empty key + --- + : + --- + : diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NP9H.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NP9H.yaml new file mode 100644 index 0000000..21d1354 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/NP9H.yaml @@ -0,0 +1,20 @@ +--- +- name: Spec Example 7.5. Double Quoted Line Breaks + from: http://www.yaml.org/spec/1.2/spec.html#id2787745 + tags: double spec scalar whitespace upto-1.2 + yaml: | + "folded␣ + to a space,» + ␣ + to a line feed, or »\ + \ »non-content" + tree: | + +STR + +DOC + =VAL "folded to a space,\nto a line feed, or \t \tnon-content + -DOC + -STR + json: | + "folded to a space,\nto a line feed, or \t \tnon-content" + dump: | + "folded to a space,\nto a line feed, or \t \tnon-content" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P2AD.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P2AD.yaml new file mode 100644 index 0000000..0034d88 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P2AD.yaml @@ -0,0 +1,42 @@ +--- +- name: Spec Example 8.1. Block Scalar Header + from: http://www.yaml.org/spec/1.2/spec.html#id2793888 + tags: spec literal folded comment scalar + yaml: | + - | # Empty header↓ + literal + - >1 # Indentation indicator↓ + folded + - |+ # Chomping indicator↓ + keep + + - >1- # Both indicators↓ + strip + tree: | + +STR + +DOC + +SEQ + =VAL |literal\n + =VAL > folded\n + =VAL |keep\n\n + =VAL > strip + -SEQ + -DOC + -STR + json: | + [ + "literal\n", + " folded\n", + "keep\n\n", + " strip" + ] + dump: | + - | + literal + - >2 + folded + - |+ + keep + + - >2- + strip diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P2EQ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P2EQ.yaml new file mode 100644 index 0000000..26e8e66 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P2EQ.yaml @@ -0,0 +1,16 @@ +--- +- name: Invalid sequene item on same line as previous item + from: '@perlpunk' + tags: error flow mapping sequence + fail: true + yaml: | + --- + - { y: z }- invalid + tree: | + +STR + +DOC --- + +SEQ + +MAP {} + =VAL :y + =VAL :z + -MAP diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P76L.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P76L.yaml new file mode 100644 index 0000000..2d36d3f --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P76L.yaml @@ -0,0 +1,18 @@ +--- +- name: Spec Example 6.19. Secondary Tag Handle + from: http://www.yaml.org/spec/1.2/spec.html#id2782940 + tags: spec header tag unknown-tag + yaml: | + %TAG !! tag:example.com,2000:app/ + --- + !!int 1 - 3 # Interval, not integer + tree: | + +STR + +DOC --- + =VAL :1 - 3 + -DOC + -STR + json: | + "1 - 3" + dump: | + --- ! 1 - 3 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P94K.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P94K.yaml new file mode 100644 index 0000000..d7ba5d9 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/P94K.yaml @@ -0,0 +1,25 @@ +--- +- name: Spec Example 6.11. Multi-Line Comments + from: http://www.yaml.org/spec/1.2/spec.html#id2780696 + tags: spec comment + yaml: | + key: # Comment + # lines + value + ↵ + ↵ + tree: | + +STR + +DOC + +MAP + =VAL :key + =VAL :value + -MAP + -DOC + -STR + json: | + { + "key": "value" + } + dump: | + key: value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PBJ2.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PBJ2.yaml new file mode 100644 index 0000000..41ece10 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PBJ2.yaml @@ -0,0 +1,54 @@ +--- +- name: Spec Example 2.3. Mapping Scalars to Sequences + from: http://www.yaml.org/spec/1.2/spec.html#id2759963 + tags: spec mapping sequence + yaml: | + american: + - Boston Red Sox + - Detroit Tigers + - New York Yankees + national: + - New York Mets + - Chicago Cubs + - Atlanta Braves + tree: | + +STR + +DOC + +MAP + =VAL :american + +SEQ + =VAL :Boston Red Sox + =VAL :Detroit Tigers + =VAL :New York Yankees + -SEQ + =VAL :national + +SEQ + =VAL :New York Mets + =VAL :Chicago Cubs + =VAL :Atlanta Braves + -SEQ + -MAP + -DOC + -STR + json: | + { + "american": [ + "Boston Red Sox", + "Detroit Tigers", + "New York Yankees" + ], + "national": [ + "New York Mets", + "Chicago Cubs", + "Atlanta Braves" + ] + } + dump: | + american: + - Boston Red Sox + - Detroit Tigers + - New York Yankees + national: + - New York Mets + - Chicago Cubs + - Atlanta Braves diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PRH3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PRH3.yaml new file mode 100644 index 0000000..5e6f914 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PRH3.yaml @@ -0,0 +1,25 @@ +--- +- name: Spec Example 7.9. Single Quoted Lines + from: http://www.yaml.org/spec/1.2/spec.html#id2788756 + tags: single spec scalar whitespace upto-1.2 + yaml: | + ' 1st non-empty + + 2nd non-empty␣ + ———»3rd non-empty ' + tree: | + +STR + +DOC + =VAL ' 1st non-empty\n2nd non-empty 3rd non-empty␣ + -DOC + -STR + json: | + " 1st non-empty\n2nd non-empty 3rd non-empty " + dump: | + ' 1st non-empty + + 2nd non-empty 3rd non-empty ' + emit: | + ' 1st non-empty + + 2nd non-empty 3rd non-empty ' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PUW8.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PUW8.yaml new file mode 100644 index 0000000..d327368 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PUW8.yaml @@ -0,0 +1,30 @@ +--- +- name: Document start on last line + from: '@perlpunk' + tags: header + yaml: | + --- + a: b + --- + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL :b + -MAP + -DOC + +DOC --- + =VAL : + -DOC + -STR + json: | + { + "a": "b" + } + null + dump: | + --- + a: b + --- + ... diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PW8X.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PW8X.yaml new file mode 100644 index 0000000..0c4f7ff --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/PW8X.yaml @@ -0,0 +1,52 @@ +--- +- name: Anchors on Empty Scalars + from: NimYAML tests + tags: anchor explicit-key + yaml: | + - &a + - a + - + &a : a + b: &b + - + &c : &a + - + ? &d + - + ? &e + : &a + tree: | + +STR + +DOC + +SEQ + =VAL &a : + =VAL :a + +MAP + =VAL &a : + =VAL :a + =VAL :b + =VAL &b : + -MAP + +MAP + =VAL &c : + =VAL &a : + -MAP + +MAP + =VAL &d : + =VAL : + -MAP + +MAP + =VAL &e : + =VAL &a : + -MAP + -SEQ + -DOC + -STR + dump: | + - &a + - a + - &a : a + b: &b + - &c : &a + - &d : + - &e : &a diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q4CL.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q4CL.yaml new file mode 100644 index 0000000..69eda79 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q4CL.yaml @@ -0,0 +1,17 @@ +--- +- name: Trailing content after quoted value + from: '@perlpunk' + tags: error mapping double + fail: true + yaml: | + key1: "quoted1" + key2: "quoted2" trailing content + key3: "quoted3" + tree: | + +STR + +DOC + +MAP + =VAL :key1 + =VAL "quoted1 + =VAL :key2 + =VAL "quoted2 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q5MG.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q5MG.yaml new file mode 100644 index 0000000..5748250 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q5MG.yaml @@ -0,0 +1,17 @@ +--- +- name: Tab at beginning of line followed by a flow mapping + from: IRC + tags: flow whitespace + yaml: | + ———»{} + tree: | + +STR + +DOC + +MAP {} + -MAP + -DOC + -STR + json: | + {} + dump: | + {} diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q88A.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q88A.yaml new file mode 100644 index 0000000..acadda8 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q88A.yaml @@ -0,0 +1,48 @@ +--- +- name: Spec Example 7.23. Flow Content + from: http://www.yaml.org/spec/1.2/spec.html#id2793163 + tags: spec flow sequence mapping + yaml: | + - [ a, b ] + - { a: b } + - "a" + - 'b' + - c + tree: | + +STR + +DOC + +SEQ + +SEQ [] + =VAL :a + =VAL :b + -SEQ + +MAP {} + =VAL :a + =VAL :b + -MAP + =VAL "a + =VAL 'b + =VAL :c + -SEQ + -DOC + -STR + json: | + [ + [ + "a", + "b" + ], + { + "a": "b" + }, + "a", + "b", + "c" + ] + dump: | + - - a + - b + - a: b + - "a" + - 'b' + - c diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q8AD.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q8AD.yaml new file mode 100644 index 0000000..2d14859 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q8AD.yaml @@ -0,0 +1,23 @@ +--- +- name: Spec Example 7.5. Double Quoted Line Breaks [1.3] + from: NP9H, modified for YAML 1.3 + tags: double spec scalar whitespace 1.3-mod + yaml: | + --- + "folded␣ + to a space, + ␣ + to a line feed, or »\ + \ »non-content" + tree: | + +STR + +DOC --- + =VAL "folded to a space,\nto a line feed, or \t \tnon-content + -DOC + -STR + json: | + "folded to a space,\nto a line feed, or \t \tnon-content" + dump: | + "folded to a space,\nto a line feed, or \t \tnon-content" + emit: | + --- "folded to a space,\nto a line feed, or \t \tnon-content" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q9WF.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q9WF.yaml new file mode 100644 index 0000000..d2d99f5 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Q9WF.yaml @@ -0,0 +1,35 @@ +--- +- name: Spec Example 6.12. Separation Spaces + from: http://www.yaml.org/spec/1.2/spec.html#id2780989 + tags: complex-key flow spec comment whitespace 1.3-err + yaml: | + { first: Sammy, last: Sosa }: + # Statistics: + hr: # Home runs + 65 + avg: # Average + 0.278 + tree: | + +STR + +DOC + +MAP + +MAP {} + =VAL :first + =VAL :Sammy + =VAL :last + =VAL :Sosa + -MAP + +MAP + =VAL :hr + =VAL :65 + =VAL :avg + =VAL :0.278 + -MAP + -MAP + -DOC + -STR + dump: | + ? first: Sammy + last: Sosa + : hr: 65 + avg: 0.278 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QB6E.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QB6E.yaml new file mode 100644 index 0000000..0f9efca --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QB6E.yaml @@ -0,0 +1,15 @@ +--- +- name: Wrong indented multiline quoted scalar + from: '@perlpunk' + tags: double error indent + fail: true + yaml: | + --- + quoted: "a + b + c" + tree: | + +STR + +DOC --- + +MAP + =VAL :quoted diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QF4Y.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QF4Y.yaml new file mode 100644 index 0000000..986849f --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QF4Y.yaml @@ -0,0 +1,27 @@ +--- +- name: Spec Example 7.19. Single Pair Flow Mappings + from: http://www.yaml.org/spec/1.2/spec.html#id2792291 + tags: spec flow mapping + yaml: | + [ + foo: bar + ] + tree: | + +STR + +DOC + +SEQ [] + +MAP {} + =VAL :foo + =VAL :bar + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "foo": "bar" + } + ] + dump: | + - foo: bar diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QLJ7.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QLJ7.yaml new file mode 100644 index 0000000..7f7c54d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QLJ7.yaml @@ -0,0 +1,22 @@ +--- +- name: Tag shorthand used in documents but only defined in the first + from: IRC + tags: error directive tag + fail: true + yaml: | + %TAG !prefix! tag:example.com,2011: + --- !prefix!A + a: b + --- !prefix!B + c: d + --- !prefix!C + e: f + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL :b + -MAP + -DOC + +DOC --- diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QT73.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QT73.yaml new file mode 100644 index 0000000..79d925a --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/QT73.yaml @@ -0,0 +1,12 @@ +--- +- name: Comment and document-end marker + from: '@perlpunk' + tags: comment footer + yaml: | + # comment + ... + tree: | + +STR + -STR + json: '' + dump: '' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/R4YG.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/R4YG.yaml new file mode 100644 index 0000000..4e45cdb --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/R4YG.yaml @@ -0,0 +1,44 @@ +--- +- name: Spec Example 8.2. Block Indentation Indicator + from: http://www.yaml.org/spec/1.2/spec.html#id2794311 + tags: spec literal folded scalar whitespace libyaml-err upto-1.2 + yaml: | + - | + detected + - > + ␣ + ␣␣ + # detected + - |1 + explicit + - > + ——» + detected + tree: | + +STR + +DOC + +SEQ + =VAL |detected\n + =VAL >\n\n# detected\n + =VAL | explicit\n + =VAL >\t\ndetected\n + -SEQ + -DOC + -STR + json: | + [ + "detected\n", + "\n\n# detected\n", + " explicit\n", + "\t\ndetected\n" + ] + dump: | + - | + detected + - >2 + + + # detected + - |2 + explicit + - "\t\ndetected\n" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/R52L.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/R52L.yaml new file mode 100644 index 0000000..e0f5edd --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/R52L.yaml @@ -0,0 +1,43 @@ +--- +- name: Nested flow mapping sequence and mappings + from: '@perlpunk' + tags: flow mapping sequence + yaml: | + --- + { top1: [item1, {key2: value2}, item3], top2: value2 } + tree: | + +STR + +DOC --- + +MAP {} + =VAL :top1 + +SEQ [] + =VAL :item1 + +MAP {} + =VAL :key2 + =VAL :value2 + -MAP + =VAL :item3 + -SEQ + =VAL :top2 + =VAL :value2 + -MAP + -DOC + -STR + json: | + { + "top1": [ + "item1", + { + "key2": "value2" + }, + "item3" + ], + "top2": "value2" + } + dump: | + --- + top1: + - item1 + - key2: value2 + - item3 + top2: value2 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RHX7.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RHX7.yaml new file mode 100644 index 0000000..f80cd86 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RHX7.yaml @@ -0,0 +1,16 @@ +--- +- name: YAML directive without document end marker + from: '@perlpunk' + tags: directive error + fail: true + yaml: | + --- + key: value + %YAML 1.2 + --- + tree: | + +STR + +DOC --- + +MAP + =VAL :key + =VAL :value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RLU9.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RLU9.yaml new file mode 100644 index 0000000..579bb1d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RLU9.yaml @@ -0,0 +1,38 @@ +--- +- name: Sequence Indent + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/indent.tml + tags: sequence indent + yaml: | + foo: + - 42 + bar: + - 44 + tree: | + +STR + +DOC + +MAP + =VAL :foo + +SEQ + =VAL :42 + -SEQ + =VAL :bar + +SEQ + =VAL :44 + -SEQ + -MAP + -DOC + -STR + json: | + { + "foo": [ + 42 + ], + "bar": [ + 44 + ] + } + dump: | + foo: + - 42 + bar: + - 44 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RR7F.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RR7F.yaml new file mode 100644 index 0000000..c6690f8 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RR7F.yaml @@ -0,0 +1,27 @@ +--- +- name: Mixed Block Mapping (implicit to explicit) + from: NimYAML tests + tags: explicit-key mapping + yaml: | + a: 4.2 + ? d + : 23 + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL :4.2 + =VAL :d + =VAL :23 + -MAP + -DOC + -STR + json: | + { + "d": 23, + "a": 4.2 + } + dump: | + a: 4.2 + d: 23 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RTP8.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RTP8.yaml new file mode 100644 index 0000000..a2ebf2f --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RTP8.yaml @@ -0,0 +1,20 @@ +--- +- name: Spec Example 9.2. Document Markers + from: http://www.yaml.org/spec/1.2/spec.html#id2800866 + tags: spec header footer + yaml: | + %YAML 1.2 + --- + Document + ... # Suffix + tree: | + +STR + +DOC --- + =VAL :Document + -DOC ... + -STR + json: | + "Document" + dump: | + --- Document + ... diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RXY3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RXY3.yaml new file mode 100644 index 0000000..e8ea24b --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RXY3.yaml @@ -0,0 +1,13 @@ +--- +- name: Invalid document-end marker in single quoted string + from: '@perlpunk' + tags: footer single error + fail: true + yaml: | + --- + ' + ... + ' + tree: | + +STR + +DOC --- diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RZP5.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RZP5.yaml new file mode 100644 index 0000000..e01e7e8 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RZP5.yaml @@ -0,0 +1,58 @@ +--- +- name: Various Trailing Comments [1.3] + from: XW4D, modified for YAML 1.3 + tags: anchor comment folded mapping 1.3-mod + yaml: | + a: "double + quotes" # lala + b: plain + value # lala + c : #lala + d + ? # lala + - seq1 + : # lala + - #lala + seq2 + e: &node # lala + - x: y + block: > # lala + abcde + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL "double quotes + =VAL :b + =VAL :plain value + =VAL :c + =VAL :d + +SEQ + =VAL :seq1 + -SEQ + +SEQ + =VAL :seq2 + -SEQ + =VAL :e + +SEQ &node + +MAP + =VAL :x + =VAL :y + -MAP + -SEQ + =VAL :block + =VAL >abcde\n + -MAP + -DOC + -STR + dump: | + a: "double quotes" + b: plain value + c: d + ? - seq1 + : - seq2 + e: &node + - x: y + block: > + abcde diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RZT7.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RZT7.yaml new file mode 100644 index 0000000..9c84722 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/RZT7.yaml @@ -0,0 +1,133 @@ +--- +- name: Spec Example 2.28. Log File + from: http://www.yaml.org/spec/1.2/spec.html#id2761866 + tags: spec header literal mapping sequence + yaml: | + --- + Time: 2001-11-23 15:01:42 -5 + User: ed + Warning: + This is an error message + for the log file + --- + Time: 2001-11-23 15:02:31 -5 + User: ed + Warning: + A slightly different error + message. + --- + Date: 2001-11-23 15:03:17 -5 + User: ed + Fatal: + Unknown variable "bar" + Stack: + - file: TopClass.py + line: 23 + code: | + x = MoreObject("345\n") + - file: MoreClass.py + line: 58 + code: |- + foo = bar + tree: | + +STR + +DOC --- + +MAP + =VAL :Time + =VAL :2001-11-23 15:01:42 -5 + =VAL :User + =VAL :ed + =VAL :Warning + =VAL :This is an error message for the log file + -MAP + -DOC + +DOC --- + +MAP + =VAL :Time + =VAL :2001-11-23 15:02:31 -5 + =VAL :User + =VAL :ed + =VAL :Warning + =VAL :A slightly different error message. + -MAP + -DOC + +DOC --- + +MAP + =VAL :Date + =VAL :2001-11-23 15:03:17 -5 + =VAL :User + =VAL :ed + =VAL :Fatal + =VAL :Unknown variable "bar" + =VAL :Stack + +SEQ + +MAP + =VAL :file + =VAL :TopClass.py + =VAL :line + =VAL :23 + =VAL :code + =VAL |x = MoreObject("345\\n")\n + -MAP + +MAP + =VAL :file + =VAL :MoreClass.py + =VAL :line + =VAL :58 + =VAL :code + =VAL |foo = bar + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "Time": "2001-11-23 15:01:42 -5", + "User": "ed", + "Warning": "This is an error message for the log file" + } + { + "Time": "2001-11-23 15:02:31 -5", + "User": "ed", + "Warning": "A slightly different error message." + } + { + "Date": "2001-11-23 15:03:17 -5", + "User": "ed", + "Fatal": "Unknown variable \"bar\"", + "Stack": [ + { + "file": "TopClass.py", + "line": 23, + "code": "x = MoreObject(\"345\\n\")\n" + }, + { + "file": "MoreClass.py", + "line": 58, + "code": "foo = bar" + } + ] + } + dump: | + --- + Time: 2001-11-23 15:01:42 -5 + User: ed + Warning: This is an error message for the log file + --- + Time: 2001-11-23 15:02:31 -5 + User: ed + Warning: A slightly different error message. + --- + Date: 2001-11-23 15:03:17 -5 + User: ed + Fatal: Unknown variable "bar" + Stack: + - file: TopClass.py + line: 23 + code: | + x = MoreObject("345\n") + - file: MoreClass.py + line: 58 + code: |- + foo = bar diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S3PD.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S3PD.yaml new file mode 100644 index 0000000..a1c2da5 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S3PD.yaml @@ -0,0 +1,29 @@ +--- +- name: Spec Example 8.18. Implicit Block Mapping Entries + from: http://www.yaml.org/spec/1.2/spec.html#id2798896 + tags: empty-key spec mapping + yaml: | + plain key: in-line value + : # Both empty + "quoted key": + - entry + tree: | + +STR + +DOC + +MAP + =VAL :plain key + =VAL :in-line value + =VAL : + =VAL : + =VAL "quoted key + +SEQ + =VAL :entry + -SEQ + -MAP + -DOC + -STR + emit: | + plain key: in-line value + : + "quoted key": + - entry diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S4GJ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S4GJ.yaml new file mode 100644 index 0000000..beb8bff --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S4GJ.yaml @@ -0,0 +1,14 @@ +--- +- name: Invalid text after block scalar indicator + from: '@perlpunk' + tags: error folded + fail: true + yaml: | + --- + folded: > first line + second line + tree: | + +STR + +DOC --- + +MAP + =VAL :folded diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S4JQ.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S4JQ.yaml new file mode 100644 index 0000000..4160abd --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S4JQ.yaml @@ -0,0 +1,29 @@ +--- +- name: Spec Example 6.28. Non-Specific Tags + from: http://www.yaml.org/spec/1.2/spec.html#id2785512 + tags: spec tag + yaml: | + # Assuming conventional resolution: + - "12" + - 12 + - ! 12 + tree: | + +STR + +DOC + +SEQ + =VAL "12 + =VAL :12 + =VAL :12 + -SEQ + -DOC + -STR + json: | + [ + "12", + 12, + "12" + ] + dump: | + - "12" + - 12 + - ! 12 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S4T7.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S4T7.yaml new file mode 100644 index 0000000..e09e55c --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S4T7.yaml @@ -0,0 +1,20 @@ +--- +- name: Document with footer + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/footer.tml + tags: mapping footer + yaml: | + aaa: bbb + ... + tree: | + +STR + +DOC + +MAP + =VAL :aaa + =VAL :bbb + -MAP + -DOC ... + -STR + json: | + { + "aaa": "bbb" + } diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S7BG.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S7BG.yaml new file mode 100644 index 0000000..3b35338 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S7BG.yaml @@ -0,0 +1,22 @@ +--- +- name: Colon followed by comma + from: '@perlpunk' + tags: scalar + yaml: | + --- + - :, + tree: | + +STR + +DOC --- + +SEQ + =VAL ::, + -SEQ + -DOC + -STR + json: | + [ + ":," + ] + dump: | + --- + - :, diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S98Z.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S98Z.yaml new file mode 100644 index 0000000..5ecb3bd --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S98Z.yaml @@ -0,0 +1,16 @@ +--- +- name: Block scalar with more spaces than first content line + from: '@perlpunk' + tags: error folded comment scalar whitespace + fail: true + yaml: | + empty block scalar: > + ␣ + ␣␣ + ␣␣␣ + # comment + tree: | + +STR + +DOC + +MAP + =VAL :empty block scalar diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S9E8.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S9E8.yaml new file mode 100644 index 0000000..57e59a9 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/S9E8.yaml @@ -0,0 +1,49 @@ +--- +- name: Spec Example 5.3. Block Structure Indicators + from: http://www.yaml.org/spec/1.2/spec.html#id2772312 + tags: explicit-key spec mapping sequence + yaml: | + sequence: + - one + - two + mapping: + ? sky + : blue + sea : green + tree: | + +STR + +DOC + +MAP + =VAL :sequence + +SEQ + =VAL :one + =VAL :two + -SEQ + =VAL :mapping + +MAP + =VAL :sky + =VAL :blue + =VAL :sea + =VAL :green + -MAP + -MAP + -DOC + -STR + json: | + { + "sequence": [ + "one", + "two" + ], + "mapping": { + "sky": "blue", + "sea": "green" + } + } + dump: | + sequence: + - one + - two + mapping: + sky: blue + sea: green diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SBG9.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SBG9.yaml new file mode 100644 index 0000000..4d0d595 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SBG9.yaml @@ -0,0 +1,30 @@ +--- +- name: Flow Sequence in Flow Mapping + from: NimYAML tests + tags: complex-key sequence mapping flow + yaml: | + {a: [b, c], [d, e]: f} + tree: | + +STR + +DOC + +MAP {} + =VAL :a + +SEQ [] + =VAL :b + =VAL :c + -SEQ + +SEQ [] + =VAL :d + =VAL :e + -SEQ + =VAL :f + -MAP + -DOC + -STR + dump: | + a: + - b + - c + ? - d + - e + : f diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SF5V.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SF5V.yaml new file mode 100644 index 0000000..0dd71d6 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SF5V.yaml @@ -0,0 +1,11 @@ +--- +- name: Duplicate YAML directive + from: '@perlpunk' + tags: directive error + fail: true + yaml: | + %YAML 1.2 + %YAML 1.2 + --- + tree: | + +STR diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SKE5.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SKE5.yaml new file mode 100644 index 0000000..f5014a5 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SKE5.yaml @@ -0,0 +1,34 @@ +--- +- name: Anchor before zero indented sequence + from: '@perlpunk' + tags: anchor indent sequence + yaml: | + --- + seq: + &anchor + - a + - b + tree: | + +STR + +DOC --- + +MAP + =VAL :seq + +SEQ &anchor + =VAL :a + =VAL :b + -SEQ + -MAP + -DOC + -STR + json: | + { + "seq": [ + "a", + "b" + ] + } + dump: | + --- + seq: &anchor + - a + - b diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SM9W.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SM9W.yaml new file mode 100644 index 0000000..238712f --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SM9W.yaml @@ -0,0 +1,34 @@ +--- +- name: Single character streams + from: '@ingydotnet' + tags: sequence + yaml: | + -∎ + tree: | + +STR + +DOC + +SEQ + =VAL : + -SEQ + -DOC + -STR + json: | + [null] + dump: | + - + +- tags: mapping + yaml: | + :∎ + tree: | + +STR + +DOC + +MAP + =VAL : + =VAL : + -MAP + -DOC + -STR + json: null + dump: | + : diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SR86.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SR86.yaml new file mode 100644 index 0000000..a28bb3c --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SR86.yaml @@ -0,0 +1,15 @@ +--- +- name: Anchor plus Alias + from: '@perlpunk' + tags: alias error + fail: true + yaml: | + key1: &a value + key2: &b *a + tree: | + +STR + +DOC + +MAP + =VAL :key1 + =VAL &a :value + =VAL :key2 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SSW6.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SSW6.yaml new file mode 100644 index 0000000..aaf31b0 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SSW6.yaml @@ -0,0 +1,17 @@ +--- +- name: Spec Example 7.7. Single Quoted Characters [1.3] + from: 4GC6, modified for YAML 1.3 + tags: spec scalar single 1.3-mod + yaml: | + --- + 'here''s to "quotes"' + tree: | + +STR + +DOC --- + =VAL 'here's to "quotes" + -DOC + -STR + json: | + "here's to \"quotes\"" + dump: | + --- 'here''s to "quotes"' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SU5Z.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SU5Z.yaml new file mode 100644 index 0000000..4b9c56d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SU5Z.yaml @@ -0,0 +1,13 @@ +--- +- name: Comment without whitespace after doublequoted scalar + from: '@perlpunk' + tags: comment error double whitespace + fail: true + yaml: | + key: "value"# invalid comment + tree: | + +STR + +DOC + +MAP + =VAL :key + =VAL "value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SU74.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SU74.yaml new file mode 100644 index 0000000..e402f1c --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SU74.yaml @@ -0,0 +1,14 @@ +--- +- name: Anchor and alias as mapping key + from: '@perlpunk' + tags: error anchor alias mapping + fail: true + yaml: | + key1: &alias value1 + &b *alias : value2 + tree: | + +STR + +DOC + +MAP + =VAL :key1 + =VAL &alias :value1 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SY6V.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SY6V.yaml new file mode 100644 index 0000000..82986e5 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SY6V.yaml @@ -0,0 +1,9 @@ +--- +- name: Anchor before sequence entry on same line + from: '@perlpunk' + tags: anchor error sequence + fail: true + yaml: | + &anchor - sequence entry + tree: | + +STR diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SYW4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SYW4.yaml new file mode 100644 index 0000000..a5a61b1 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/SYW4.yaml @@ -0,0 +1,31 @@ +--- +- name: Spec Example 2.2. Mapping Scalars to Scalars + from: http://www.yaml.org/spec/1.2/spec.html#id2759963 + tags: spec scalar comment + yaml: | + hr: 65 # Home runs + avg: 0.278 # Batting average + rbi: 147 # Runs Batted In + tree: | + +STR + +DOC + +MAP + =VAL :hr + =VAL :65 + =VAL :avg + =VAL :0.278 + =VAL :rbi + =VAL :147 + -MAP + -DOC + -STR + json: | + { + "hr": 65, + "avg": 0.278, + "rbi": 147 + } + dump: | + hr: 65 + avg: 0.278 + rbi: 147 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T26H.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T26H.yaml new file mode 100644 index 0000000..843b3be --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T26H.yaml @@ -0,0 +1,32 @@ +--- +- name: Spec Example 8.8. Literal Content [1.3] + from: DWX9, modified for YAML 1.3 + tags: spec literal scalar comment whitespace 1.3-mod + yaml: | + --- | + ␣ + ␣␣ + literal + ␣␣␣ + ␣␣ + text + + # Comment + tree: | + +STR + +DOC --- + =VAL |\n\nliteral\n \n\ntext\n + -DOC + -STR + json: | + "\n\nliteral\n \n\ntext\n" + dump: | + "\n\nliteral\n \n\ntext\n" + emit: | + --- | + + + literal + ␣␣␣ + + text diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T4YY.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T4YY.yaml new file mode 100644 index 0000000..bf230f6 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T4YY.yaml @@ -0,0 +1,26 @@ +--- +- name: Spec Example 7.9. Single Quoted Lines [1.3] + from: PRH3, modified for YAML 1.3 + tags: single spec scalar whitespace 1.3-mod + yaml: | + --- + ' 1st non-empty + + 2nd non-empty␣ + 3rd non-empty ' + tree: | + +STR + +DOC --- + =VAL ' 1st non-empty\n2nd non-empty 3rd non-empty␣ + -DOC + -STR + json: | + " 1st non-empty\n2nd non-empty 3rd non-empty " + dump: | + ' 1st non-empty + + 2nd non-empty 3rd non-empty ' + emit: | + --- ' 1st non-empty + + 2nd non-empty 3rd non-empty ' diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T5N4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T5N4.yaml new file mode 100644 index 0000000..c7b5059 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T5N4.yaml @@ -0,0 +1,24 @@ +--- +- name: Spec Example 8.7. Literal Scalar [1.3] + from: M9B4, modified for YAML 1.3 + tags: spec literal scalar whitespace 1.3-mod + yaml: | + --- | + literal + ——»text + ↵ + ↵ + tree: | + +STR + +DOC --- + =VAL |literal\n\ttext\n + -DOC + -STR + json: | + "literal\n\ttext\n" + dump: | + "literal\n\ttext\n" + emit: | + --- | + literal + —»text diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T833.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T833.yaml new file mode 100644 index 0000000..5d6638b --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/T833.yaml @@ -0,0 +1,15 @@ +--- +- name: Flow mapping missing a separating comma + from: '@perlpunk' + tags: error flow mapping + fail: true + yaml: | + --- + { + foo: 1 + bar: 2 } + tree: | + +STR + +DOC --- + +MAP + =VAL :foo diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TD5N.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TD5N.yaml new file mode 100644 index 0000000..2391b17 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TD5N.yaml @@ -0,0 +1,15 @@ +--- +- name: Invalid scalar after sequence + from: '@perlpunk' + tags: error sequence scalar + fail: true + yaml: | + - item1 + - item2 + invalid + tree: | + +STR + +DOC + +SEQ + =VAL :item1 + =VAL :item2 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TE2A.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TE2A.yaml new file mode 100644 index 0000000..34968f3 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TE2A.yaml @@ -0,0 +1,28 @@ +--- +- name: Spec Example 8.16. Block Mappings + from: http://www.yaml.org/spec/1.2/spec.html#id2798147 + tags: spec mapping + yaml: | + block mapping: + key: value + tree: | + +STR + +DOC + +MAP + =VAL :block mapping + +MAP + =VAL :key + =VAL :value + -MAP + -MAP + -DOC + -STR + json: | + { + "block mapping": { + "key": "value" + } + } + dump: | + block mapping: + key: value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TL85.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TL85.yaml new file mode 100644 index 0000000..a091d1d --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TL85.yaml @@ -0,0 +1,22 @@ +--- +- name: Spec Example 6.8. Flow Folding + from: http://www.yaml.org/spec/1.2/spec.html#id2779950 + tags: double spec whitespace scalar upto-1.2 + yaml: | + " + foo␣ + ␣ + —» bar + + baz + " + tree: | + +STR + +DOC + =VAL " foo\nbar\nbaz␣ + -DOC + -STR + json: | + " foo\nbar\nbaz " + dump: | + " foo\nbar\nbaz " diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TS54.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TS54.yaml new file mode 100644 index 0000000..d1e9928 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/TS54.yaml @@ -0,0 +1,29 @@ +--- +- name: Folded Block Scalar + from: NimYAML tests + tags: folded scalar 1.3-err + yaml: | + > + ab + cd + ␣ + ef + + + gh + tree: | + +STR + +DOC + =VAL >ab cd\nef\n\ngh\n + -DOC + -STR + json: | + "ab cd\nef\n\ngh\n" + dump: | + > + ab cd + + ef + + + gh diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U3C3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U3C3.yaml new file mode 100644 index 0000000..16988bf --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U3C3.yaml @@ -0,0 +1,18 @@ +--- +- name: Spec Example 6.16. “TAG” directive + from: http://www.yaml.org/spec/1.2/spec.html#id2782252 + tags: spec header tag + yaml: | + %TAG !yaml! tag:yaml.org,2002: + --- + !yaml!str "foo" + tree: | + +STR + +DOC --- + =VAL "foo + -DOC + -STR + json: | + "foo" + dump: | + --- !!str "foo" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U3XV.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U3XV.yaml new file mode 100644 index 0000000..761e8b4 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U3XV.yaml @@ -0,0 +1,92 @@ +--- +- name: Node and Mapping Key Anchors + from: '@perlpunk' + tags: anchor comment 1.3-err + yaml: | + --- + top1: &node1 + &k1 key1: one + top2: &node2 # comment + key2: two + top3: + &k3 key3: three + top4: + &node4 + &k4 key4: four + top5: + &node5 + key5: five + top6: &val6 + six + top7: + &val7 seven + tree: | + +STR + +DOC --- + +MAP + =VAL :top1 + +MAP &node1 + =VAL &k1 :key1 + =VAL :one + -MAP + =VAL :top2 + +MAP &node2 + =VAL :key2 + =VAL :two + -MAP + =VAL :top3 + +MAP + =VAL &k3 :key3 + =VAL :three + -MAP + =VAL :top4 + +MAP &node4 + =VAL &k4 :key4 + =VAL :four + -MAP + =VAL :top5 + +MAP &node5 + =VAL :key5 + =VAL :five + -MAP + =VAL :top6 + =VAL &val6 :six + =VAL :top7 + =VAL &val7 :seven + -MAP + -DOC + -STR + json: | + { + "top1": { + "key1": "one" + }, + "top2": { + "key2": "two" + }, + "top3": { + "key3": "three" + }, + "top4": { + "key4": "four" + }, + "top5": { + "key5": "five" + }, + "top6": "six", + "top7": "seven" + } + dump: | + --- + top1: &node1 + &k1 key1: one + top2: &node2 + key2: two + top3: + &k3 key3: three + top4: &node4 + &k4 key4: four + top5: &node5 + key5: five + top6: &val6 six + top7: &val7 seven diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U44R.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U44R.yaml new file mode 100644 index 0000000..0347d3b --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U44R.yaml @@ -0,0 +1,17 @@ +--- +- name: Bad indentation in mapping (2) + from: '@perlpunk' + tags: error mapping indent double + fail: true + yaml: | + map: + key1: "quoted1" + key2: "bad indentation" + tree: | + +STR + +DOC + +MAP + =VAL :map + +MAP + =VAL :key1 + =VAL "quoted1 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U99R.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U99R.yaml new file mode 100644 index 0000000..2de0c92 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U99R.yaml @@ -0,0 +1,11 @@ +--- +- name: Invalid comma in tag + from: '@perlpunk' + tags: error tag + fail: true + yaml: | + - !!str, xxx + tree: | + +STR + +DOC + +SEQ diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U9NS.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U9NS.yaml new file mode 100644 index 0000000..c8ed11a --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/U9NS.yaml @@ -0,0 +1,49 @@ +--- +- name: Spec Example 2.8. Play by Play Feed from a Game + from: http://www.yaml.org/spec/1.2/spec.html#id2760519 + tags: spec header + yaml: | + --- + time: 20:03:20 + player: Sammy Sosa + action: strike (miss) + ... + --- + time: 20:03:47 + player: Sammy Sosa + action: grand slam + ... + tree: | + +STR + +DOC --- + +MAP + =VAL :time + =VAL :20:03:20 + =VAL :player + =VAL :Sammy Sosa + =VAL :action + =VAL :strike (miss) + -MAP + -DOC ... + +DOC --- + +MAP + =VAL :time + =VAL :20:03:47 + =VAL :player + =VAL :Sammy Sosa + =VAL :action + =VAL :grand slam + -MAP + -DOC ... + -STR + json: | + { + "time": "20:03:20", + "player": "Sammy Sosa", + "action": "strike (miss)" + } + { + "time": "20:03:47", + "player": "Sammy Sosa", + "action": "grand slam" + } diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UDM2.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UDM2.yaml new file mode 100644 index 0000000..a07694a --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UDM2.yaml @@ -0,0 +1,25 @@ +--- +- name: Plain URL in flow mapping + from: https://github.com/yaml/libyaml/pull/28 + tags: flow scalar + yaml: | + - { url: http://example.org } + tree: | + +STR + +DOC + +SEQ + +MAP {} + =VAL :url + =VAL :http://example.org + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "url": "http://example.org" + } + ] + dump: | + - url: http://example.org diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UDR7.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UDR7.yaml new file mode 100644 index 0000000..e070842 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UDR7.yaml @@ -0,0 +1,44 @@ +--- +- name: Spec Example 5.4. Flow Collection Indicators + from: http://www.yaml.org/spec/1.2/spec.html#id2772813 + tags: spec flow sequence mapping + yaml: | + sequence: [ one, two, ] + mapping: { sky: blue, sea: green } + tree: | + +STR + +DOC + +MAP + =VAL :sequence + +SEQ [] + =VAL :one + =VAL :two + -SEQ + =VAL :mapping + +MAP {} + =VAL :sky + =VAL :blue + =VAL :sea + =VAL :green + -MAP + -MAP + -DOC + -STR + json: | + { + "sequence": [ + "one", + "two" + ], + "mapping": { + "sky": "blue", + "sea": "green" + } + } + dump: | + sequence: + - one + - two + mapping: + sky: blue + sea: green diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UGM3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UGM3.yaml new file mode 100644 index 0000000..cf46bf2 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UGM3.yaml @@ -0,0 +1,163 @@ +--- +- name: Spec Example 2.27. Invoice + from: http://www.yaml.org/spec/1.2/spec.html#id2761823 + tags: spec tag literal mapping sequence alias unknown-tag + yaml: | + --- ! + invoice: 34843 + date : 2001-01-23 + bill-to: &id001 + given : Chris + family : Dumars + address: + lines: | + 458 Walkman Dr. + Suite #292 + city : Royal Oak + state : MI + postal : 48046 + ship-to: *id001 + product: + - sku : BL394D + quantity : 4 + description : Basketball + price : 450.00 + - sku : BL4438H + quantity : 1 + description : Super Hoop + price : 2392.00 + tax : 251.42 + total: 4443.52 + comments: + Late afternoon is best. + Backup contact is Nancy + Billsmer @ 338-4338. + tree: | + +STR + +DOC --- + +MAP + =VAL :invoice + =VAL :34843 + =VAL :date + =VAL :2001-01-23 + =VAL :bill-to + +MAP &id001 + =VAL :given + =VAL :Chris + =VAL :family + =VAL :Dumars + =VAL :address + +MAP + =VAL :lines + =VAL |458 Walkman Dr.\nSuite #292\n + =VAL :city + =VAL :Royal Oak + =VAL :state + =VAL :MI + =VAL :postal + =VAL :48046 + -MAP + -MAP + =VAL :ship-to + =ALI *id001 + =VAL :product + +SEQ + +MAP + =VAL :sku + =VAL :BL394D + =VAL :quantity + =VAL :4 + =VAL :description + =VAL :Basketball + =VAL :price + =VAL :450.00 + -MAP + +MAP + =VAL :sku + =VAL :BL4438H + =VAL :quantity + =VAL :1 + =VAL :description + =VAL :Super Hoop + =VAL :price + =VAL :2392.00 + -MAP + -SEQ + =VAL :tax + =VAL :251.42 + =VAL :total + =VAL :4443.52 + =VAL :comments + =VAL :Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338. + -MAP + -DOC + -STR + json: | + { + "invoice": 34843, + "date": "2001-01-23", + "bill-to": { + "given": "Chris", + "family": "Dumars", + "address": { + "lines": "458 Walkman Dr.\nSuite #292\n", + "city": "Royal Oak", + "state": "MI", + "postal": 48046 + } + }, + "ship-to": { + "given": "Chris", + "family": "Dumars", + "address": { + "lines": "458 Walkman Dr.\nSuite #292\n", + "city": "Royal Oak", + "state": "MI", + "postal": 48046 + } + }, + "product": [ + { + "sku": "BL394D", + "quantity": 4, + "description": "Basketball", + "price": 450 + }, + { + "sku": "BL4438H", + "quantity": 1, + "description": "Super Hoop", + "price": 2392 + } + ], + "tax": 251.42, + "total": 4443.52, + "comments": "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338." + } + dump: | + --- ! + invoice: 34843 + date: 2001-01-23 + bill-to: &id001 + given: Chris + family: Dumars + address: + lines: | + 458 Walkman Dr. + Suite #292 + city: Royal Oak + state: MI + postal: 48046 + ship-to: *id001 + product: + - sku: BL394D + quantity: 4 + description: Basketball + price: 450.00 + - sku: BL4438H + quantity: 1 + description: Super Hoop + price: 2392.00 + tax: 251.42 + total: 4443.52 + comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338. diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UKK6.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UKK6.yaml new file mode 100644 index 0000000..2648ef1 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UKK6.yaml @@ -0,0 +1,43 @@ +--- +- name: Syntax character edge cases + from: '@ingydotnet' + tags: edge empty-key + yaml: | + - : + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL : + =VAL : + -MAP + -SEQ + -DOC + -STR + +- yaml: | + :: + tree: | + +STR + +DOC + +MAP + =VAL :: + =VAL : + -MAP + -DOC + -STR + json: | + { + ":": null + } + +- yaml: | + ! + tree: | + +STR + +DOC + =VAL : + -DOC + -STR + json: null diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UT92.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UT92.yaml new file mode 100644 index 0000000..4652fb0 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UT92.yaml @@ -0,0 +1,35 @@ +--- +- name: Spec Example 9.4. Explicit Documents + from: http://www.yaml.org/spec/1.2/spec.html#id2801448 + tags: flow spec header footer comment + yaml: | + --- + { matches + % : 20 } + ... + --- + # Empty + ... + tree: | + +STR + +DOC --- + +MAP {} + =VAL :matches % + =VAL :20 + -MAP + -DOC ... + +DOC --- + =VAL : + -DOC ... + -STR + json: | + { + "matches %": 20 + } + null + dump: | + --- + matches %: 20 + ... + --- + ... diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UV7Q.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UV7Q.yaml new file mode 100644 index 0000000..0caf960 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/UV7Q.yaml @@ -0,0 +1,28 @@ +--- +- name: Legal tab after indentation + from: '@ingydotnet' + tags: indent whitespace + yaml: | + x: + - x + ——»x + tree: | + +STR + +DOC + +MAP + =VAL :x + +SEQ + =VAL :x x + -SEQ + -MAP + -DOC + -STR + json: | + { + "x": [ + "x x" + ] + } + dump: | + x: + - x x diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/V55R.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/V55R.yaml new file mode 100644 index 0000000..1335d60 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/V55R.yaml @@ -0,0 +1,27 @@ +--- +- name: Aliases in Block Sequence + from: NimYAML tests + tags: alias sequence + yaml: | + - &a a + - &b b + - *a + - *b + tree: | + +STR + +DOC + +SEQ + =VAL &a :a + =VAL &b :b + =ALI *a + =ALI *b + -SEQ + -DOC + -STR + json: | + [ + "a", + "b", + "a", + "b" + ] diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/V9D5.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/V9D5.yaml new file mode 100644 index 0000000..a06fdc4 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/V9D5.yaml @@ -0,0 +1,29 @@ +--- +- name: Spec Example 8.19. Compact Block Mappings + from: http://www.yaml.org/spec/1.2/spec.html#id2799091 + tags: complex-key explicit-key spec mapping + yaml: | + - sun: yellow + - ? earth: blue + : moon: white + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL :sun + =VAL :yellow + -MAP + +MAP + +MAP + =VAL :earth + =VAL :blue + -MAP + +MAP + =VAL :moon + =VAL :white + -MAP + -MAP + -SEQ + -DOC + -STR diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/VJP3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/VJP3.yaml new file mode 100644 index 0000000..76a5c68 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/VJP3.yaml @@ -0,0 +1,49 @@ +--- +- name: Flow collections over many lines + from: '@ingydotnet' + tags: flow indent + fail: true + yaml: | + k: { + k + : + v + } + tree: | + +STR + +DOC + +MAP + =VAL :k + +MAP {} + +- yaml: | + k: { + k + : + v + } + tree: | + +STR + +DOC + +MAP + =VAL :k + +MAP {} + =VAL :k + =VAL :v + -MAP + -MAP + -DOC + -STR + json: | + { + "k" : { + "k" : "v" + } + } + dump: | + --- + k: + k: v + emit: | + k: + k: v diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W42U.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W42U.yaml new file mode 100644 index 0000000..2c52f96 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W42U.yaml @@ -0,0 +1,47 @@ +--- +- name: Spec Example 8.15. Block Sequence Entry Types + from: http://www.yaml.org/spec/1.2/spec.html#id2797944 + tags: comment spec literal sequence + yaml: | + - # Empty + - | + block node + - - one # Compact + - two # sequence + - one: two # Compact mapping + tree: | + +STR + +DOC + +SEQ + =VAL : + =VAL |block node\n + +SEQ + =VAL :one + =VAL :two + -SEQ + +MAP + =VAL :one + =VAL :two + -MAP + -SEQ + -DOC + -STR + json: | + [ + null, + "block node\n", + [ + "one", + "two" + ], + { + "one": "two" + } + ] + dump: | + - + - | + block node + - - one + - two + - one: two diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W4TN.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W4TN.yaml new file mode 100644 index 0000000..ca41ac7 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W4TN.yaml @@ -0,0 +1,31 @@ +--- +- name: Spec Example 9.5. Directives Documents + from: http://www.yaml.org/spec/1.2/spec.html#id2801606 + tags: spec header footer 1.3-err + yaml: | + %YAML 1.2 + --- | + %!PS-Adobe-2.0 + ... + %YAML 1.2 + --- + # Empty + ... + tree: | + +STR + +DOC --- + =VAL |%!PS-Adobe-2.0\n + -DOC ... + +DOC --- + =VAL : + -DOC ... + -STR + json: | + "%!PS-Adobe-2.0\n" + null + dump: | + --- | + %!PS-Adobe-2.0 + ... + --- + ... diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W5VH.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W5VH.yaml new file mode 100644 index 0000000..bcf069e --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W5VH.yaml @@ -0,0 +1,23 @@ +--- +- name: Allowed characters in alias + from: '@perlpunk' + tags: alias 1.3-err + yaml: | + a: &:@*!$": scalar a + b: *:@*!$": + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL &:@*!$": :scalar a + =VAL :b + =ALI *:@*!$": + -MAP + -DOC + -STR + json: | + { + "a": "scalar a", + "b": "scalar a" + } diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W9L4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W9L4.yaml new file mode 100644 index 0000000..016f15b --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/W9L4.yaml @@ -0,0 +1,16 @@ +--- +- name: Literal block scalar with more spaces in first line + from: '@perlpunk' + tags: error literal whitespace + fail: true + yaml: | + --- + block scalar: | + ␣␣␣␣␣ + more spaces at the beginning + are invalid + tree: | + +STR + +DOC --- + +MAP + =VAL :block scalar diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/WZ62.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/WZ62.yaml new file mode 100644 index 0000000..0af62ad --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/WZ62.yaml @@ -0,0 +1,28 @@ +--- +- name: Spec Example 7.2. Empty Content + from: http://www.yaml.org/spec/1.2/spec.html#id2786720 + tags: spec flow scalar tag + yaml: | + { + foo : !!str, + !!str : bar, + } + tree: | + +STR + +DOC + +MAP {} + =VAL :foo + =VAL : + =VAL : + =VAL :bar + -MAP + -DOC + -STR + json: | + { + "foo": "", + "": "bar" + } + dump: | + foo: !!str + !!str : bar diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/X38W.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/X38W.yaml new file mode 100644 index 0000000..c5b1910 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/X38W.yaml @@ -0,0 +1,33 @@ +--- +- name: Aliases in Flow Objects + from: NimYAML tests + tags: alias complex-key flow + yaml: | + { &a [a, &b b]: *b, *a : [c, *b, d]} + tree: | + +STR + +DOC + +MAP {} + +SEQ [] &a + =VAL :a + =VAL &b :b + -SEQ + =ALI *b + =ALI *a + +SEQ [] + =VAL :c + =ALI *b + =VAL :d + -SEQ + -MAP + -DOC + -STR + dump: | + ? &a + - a + - &b b + : *b + *a : + - c + - *b + - d diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/X4QW.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/X4QW.yaml new file mode 100644 index 0000000..69651b8 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/X4QW.yaml @@ -0,0 +1,13 @@ +--- +- name: Comment without whitespace after block scalar indicator + from: '@perlpunk' + tags: folded comment error whitespace + fail: true + yaml: | + block: ># comment + scalar + tree: | + +STR + +DOC + +MAP + =VAL :block diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/X8DW.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/X8DW.yaml new file mode 100644 index 0000000..56f36d0 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/X8DW.yaml @@ -0,0 +1,25 @@ +--- +- name: Explicit key and value seperated by comment + from: '@perlpunk' + tags: comment explicit-key mapping + yaml: | + --- + ? key + # comment + : value + tree: | + +STR + +DOC --- + +MAP + =VAL :key + =VAL :value + -MAP + -DOC + -STR + json: | + { + "key": "value" + } + dump: | + --- + key: value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/XLQ9.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/XLQ9.yaml new file mode 100644 index 0000000..d894fe8 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/XLQ9.yaml @@ -0,0 +1,19 @@ +--- +- name: Multiline scalar that looks like a YAML directive + from: '@perlpunk' + tags: directive scalar + yaml: | + --- + scalar + %YAML 1.2 + tree: | + +STR + +DOC --- + =VAL :scalar %YAML 1.2 + -DOC + -STR + json: | + "scalar %YAML 1.2" + dump: | + --- scalar %YAML 1.2 + ... diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/XV9V.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/XV9V.yaml new file mode 100644 index 0000000..57b18fb --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/XV9V.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 6.5. Empty Lines [1.3] + from: 5GBF, modified for YAML 1.3 + tags: literal spec scalar 1.3-mod + yaml: | + Folding: + "Empty line + + as a line feed" + Chomping: | + Clipped empty lines + ␣ + ↵ + tree: | + +STR + +DOC + +MAP + =VAL :Folding + =VAL "Empty line\nas a line feed + =VAL :Chomping + =VAL |Clipped empty lines\n + -MAP + -DOC + -STR + json: | + { + "Folding": "Empty line\nas a line feed", + "Chomping": "Clipped empty lines\n" + } + dump: | + Folding: "Empty line\nas a line feed" + Chomping: | + Clipped empty lines diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/XW4D.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/XW4D.yaml new file mode 100644 index 0000000..2acbdb0 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/XW4D.yaml @@ -0,0 +1,59 @@ +--- +- name: Various Trailing Comments + from: '@perlpunk' + tags: comment explicit-key folded 1.3-err + yaml: | + a: "double + quotes" # lala + b: plain + value # lala + c : #lala + d + ? # lala + - seq1 + : # lala + - #lala + seq2 + e: + &node # lala + - x: y + block: > # lala + abcde + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL "double quotes + =VAL :b + =VAL :plain value + =VAL :c + =VAL :d + +SEQ + =VAL :seq1 + -SEQ + +SEQ + =VAL :seq2 + -SEQ + =VAL :e + +SEQ &node + +MAP + =VAL :x + =VAL :y + -MAP + -SEQ + =VAL :block + =VAL >abcde\n + -MAP + -DOC + -STR + dump: | + a: "double quotes" + b: plain value + c: d + ? - seq1 + : - seq2 + e: &node + - x: y + block: > + abcde diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Y2GN.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Y2GN.yaml new file mode 100644 index 0000000..103d793 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Y2GN.yaml @@ -0,0 +1,23 @@ +--- +- name: Anchor with colon in the middle + from: '@perlpunk' + tags: anchor + yaml: | + --- + key: &an:chor value + tree: | + +STR + +DOC --- + +MAP + =VAL :key + =VAL &an:chor :value + -MAP + -DOC + -STR + json: | + { + "key": "value" + } + dump: | + --- + key: &an:chor value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Y79Y.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Y79Y.yaml new file mode 100644 index 0000000..7bd9a16 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Y79Y.yaml @@ -0,0 +1,119 @@ +--- +- name: Tabs in various contexts + from: '@ingydotnet' + tags: whitespace + fail: true + yaml: | + foo: | + ————» + bar: 1 + tree: | + +STR + +DOC + +MAP + =VAL :foo + +- yaml: | + foo: | + ———» + bar: 1 + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL |\t\n + =VAL :bar + =VAL :1 + -MAP + -DOC + -STR + json: | + { + "foo": "\t\n", + "bar": 1 + } + dump: | + foo: | + ———» + bar: 1 + +- yaml: | + - [ + ————» + foo + ] + tree: | + +STR + +DOC + +SEQ + +SEQ [] + =VAL :foo + -SEQ + -SEQ + -DOC + -STR + json: | + [ + [ + "foo" + ] + ] + dump: | + - - foo + +- fail: true + yaml: | + - [ + ————»foo, + foo + ] + tree: | + +STR + +DOC + +SEQ + +SEQ [] + json: null + +- fail: true + yaml: | + -———»- + +- fail: true + yaml: | + - ——»- + +- fail: true + yaml: | + ?———»- + +- fail: true + yaml: | + ? - + :———»- + +- fail: true + yaml: | + ?———»key: + +- fail: true + yaml: | + ? key: + :———»key: + +- yaml: | + -———»-1 + tree: | + +STR + +DOC + +SEQ + =VAL :-1 + -SEQ + -DOC + -STR + json: | + [ + -1 + ] + dump: | + - -1 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/YD5X.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/YD5X.yaml new file mode 100644 index 0000000..5dee2f0 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/YD5X.yaml @@ -0,0 +1,58 @@ +--- +- name: Spec Example 2.5. Sequence of Sequences + from: http://www.yaml.org/spec/1.2/spec.html#id2760351 + tags: spec sequence + yaml: | + - [name , hr, avg ] + - [Mark McGwire, 65, 0.278] + - [Sammy Sosa , 63, 0.288] + tree: | + +STR + +DOC + +SEQ + +SEQ [] + =VAL :name + =VAL :hr + =VAL :avg + -SEQ + +SEQ [] + =VAL :Mark McGwire + =VAL :65 + =VAL :0.278 + -SEQ + +SEQ [] + =VAL :Sammy Sosa + =VAL :63 + =VAL :0.288 + -SEQ + -SEQ + -DOC + -STR + json: | + [ + [ + "name", + "hr", + "avg" + ], + [ + "Mark McGwire", + 65, + 0.278 + ], + [ + "Sammy Sosa", + 63, + 0.288 + ] + ] + dump: | + - - name + - hr + - avg + - - Mark McGwire + - 65 + - 0.278 + - - Sammy Sosa + - 63 + - 0.288 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/YJV2.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/YJV2.yaml new file mode 100644 index 0000000..80a6c19 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/YJV2.yaml @@ -0,0 +1,11 @@ +--- +- name: Dash in flow sequence + from: '@ingydotnet' + tags: flow sequence + fail: true + yaml: | + [-] + tree: | + +STR + +DOC + +SEQ [] diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Z67P.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Z67P.yaml new file mode 100644 index 0000000..7816433 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Z67P.yaml @@ -0,0 +1,30 @@ +--- +- name: Spec Example 8.21. Block Scalar Nodes [1.3] + from: M5C3, modified for YAML 1.3 + tags: indent spec literal folded tag local-tag 1.3-mod + yaml: | + literal: |2 + value + folded: !foo >1 + value + tree: | + +STR + +DOC + +MAP + =VAL :literal + =VAL |value\n + =VAL :folded + =VAL >value\n + -MAP + -DOC + -STR + json: | + { + "literal": "value\n", + "folded": "value\n" + } + dump: | + literal: | + value + folded: !foo > + value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Z9M4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Z9M4.yaml new file mode 100644 index 0000000..27d22d6 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/Z9M4.yaml @@ -0,0 +1,23 @@ +--- +- name: Spec Example 6.22. Global Tag Prefix + from: http://www.yaml.org/spec/1.2/spec.html#id2783726 + tags: spec header tag unknown-tag + yaml: | + %TAG !e! tag:example.com,2000:app/ + --- + - !e!foo "bar" + tree: | + +STR + +DOC --- + +SEQ + =VAL "bar + -SEQ + -DOC + -STR + json: | + [ + "bar" + ] + dump: | + --- + - ! "bar" diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZCZ6.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZCZ6.yaml new file mode 100644 index 0000000..582021a --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZCZ6.yaml @@ -0,0 +1,12 @@ +--- +- name: Invalid mapping in plain single line value + from: https://gist.github.com/anonymous/0c8db51d151baf8113205ba3ce71d1b4 via @ingydotnet + tags: error mapping scalar + fail: true + yaml: | + a: b: c: d + tree: | + +STR + +DOC + +MAP + =VAL :a diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZF4X.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZF4X.yaml new file mode 100644 index 0000000..3eaaee2 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZF4X.yaml @@ -0,0 +1,49 @@ +--- +- name: Spec Example 2.6. Mapping of Mappings + from: http://www.yaml.org/spec/1.2/spec.html#id2760372 + tags: flow spec mapping + yaml: | + Mark McGwire: {hr: 65, avg: 0.278} + Sammy Sosa: { + hr: 63, + avg: 0.288 + } + tree: | + +STR + +DOC + +MAP + =VAL :Mark McGwire + +MAP {} + =VAL :hr + =VAL :65 + =VAL :avg + =VAL :0.278 + -MAP + =VAL :Sammy Sosa + +MAP {} + =VAL :hr + =VAL :63 + =VAL :avg + =VAL :0.288 + -MAP + -MAP + -DOC + -STR + json: | + { + "Mark McGwire": { + "hr": 65, + "avg": 0.278 + }, + "Sammy Sosa": { + "hr": 63, + "avg": 0.288 + } + } + dump: | + Mark McGwire: + hr: 65 + avg: 0.278 + Sammy Sosa: + hr: 63 + avg: 0.288 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZH7C.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZH7C.yaml new file mode 100644 index 0000000..ae04318 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZH7C.yaml @@ -0,0 +1,23 @@ +--- +- name: Anchors in Mapping + from: NimYAML tests + tags: anchor mapping + yaml: | + &a a: b + c: &d d + tree: | + +STR + +DOC + +MAP + =VAL &a :a + =VAL :b + =VAL :c + =VAL &d :d + -MAP + -DOC + -STR + json: | + { + "a": "b", + "c": "d" + } diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZK9H.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZK9H.yaml new file mode 100644 index 0000000..4b6b8b5 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZK9H.yaml @@ -0,0 +1,37 @@ +--- +- name: Nested top level flow mapping + from: '@perlpunk' + tags: flow indent mapping sequence + yaml: | + { key: [[[ + value + ]]] + } + tree: | + +STR + +DOC + +MAP {} + =VAL :key + +SEQ [] + +SEQ [] + +SEQ [] + =VAL :value + -SEQ + -SEQ + -SEQ + -MAP + -DOC + -STR + json: | + { + "key": [ + [ + [ + "value" + ] + ] + ] + } + dump: | + key: + - - - value diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZL4Z.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZL4Z.yaml new file mode 100644 index 0000000..9dc05a0 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZL4Z.yaml @@ -0,0 +1,14 @@ +--- +- name: Invalid nested mapping + from: '@perlpunk' + tags: error mapping + fail: true + yaml: | + --- + a: 'b': c + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL 'b diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZVH3.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZVH3.yaml new file mode 100644 index 0000000..c64c026 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZVH3.yaml @@ -0,0 +1,16 @@ +--- +- name: Wrong indented sequence item + from: '@perlpunk' + tags: error sequence indent + fail: true + yaml: | + - key: value + - item1 + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL :key + =VAL :value + -MAP diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZWK4.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZWK4.yaml new file mode 100644 index 0000000..39abebf --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZWK4.yaml @@ -0,0 +1,33 @@ +--- +- name: Key with anchor after missing explicit mapping value + from: '@perlpunk' + tags: anchor explicit-key mapping + yaml: | + --- + a: 1 + ? b + &anchor c: 3 + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL :1 + =VAL :b + =VAL : + =VAL &anchor :c + =VAL :3 + -MAP + -DOC + -STR + json: | + { + "a": 1, + "b": null, + "c": 3 + } + dump: | + --- + a: 1 + b: + &anchor c: 3 diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZXT5.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZXT5.yaml new file mode 100644 index 0000000..34e6ec9 --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZXT5.yaml @@ -0,0 +1,13 @@ +--- +- name: Implicit key followed by newline and adjacent value + from: '@perlpunk' + tags: error flow mapping sequence + fail: true + yaml: | + [ "key" + :value ] + tree: | + +STR + +DOC + +SEQ [] + =VAL "key diff --git a/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZYU8.yaml b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZYU8.yaml new file mode 100644 index 0000000..646da1b --- /dev/null +++ b/json/lexers/yaml-lexer/testdata/yaml-test-suite/src/ZYU8.yaml @@ -0,0 +1,32 @@ +--- +- skip: true + note: The following cases are valid YAML according to the 1.2 productions but + not at all usefully valid. We don't want to encourage parsers to support + them when we'll likely make them invalid later. + also: MU58 + name: Directive variants + from: '@ingydotnet' + tags: directive + yaml: | + %YAML1.1 + --- + tree: | + +STR + +DOC --- + =VAL : + -DOC + -STR + json: | + null + +- yaml: | + %*** + --- + +- yaml: | + %YAML 1.1 1.2 + --- + +- yaml: | + %YAML 1.12345 + --- From 71faf38efd3fd43cf377fce5fe663ed3f6c06bab Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Thu, 30 Jul 2026 23:41:00 +0200 Subject: [PATCH 2/5] docs(yaml-lexer): place our conformance against other implementations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The YAML Test Matrix (matrix.yaml.info) publishes a "JSON output" comparison over the same suite — is the loaded data equal to the `json` field — which is the same question our harness asks, so the numbers are meaningfully comparable. On its basis we score 289/366 = 79% (or 71% counting the 40 cases with no JSON equivalent as misses), which puts us in the same band as the mainstream loaders — PyYAML 75%, go-yaml 76%, ruby psych 76%, ruamel 78% — and clearly behind the four leaders: libfyaml 93%, JS yaml 92%, YAML::PP 92%, HsYAML 91%. Recorded with the caveats that stop it being a ranking: the matrix measures LOADERS (parse, serialize, compare) while we measure a lexer's token stream; we forfeit points by design on multi-document streams and complex keys; and our floor is goccy's, since 12 of our 54 divergences are its behavior rather than ours and goccy is not in the matrix at all (its `go-yaml` entry is a different project). The actionable part: closing group 1 alone — resolved-scalar mapping keys, 23 cases, one coherent feature — reaches 85%, above every implementation in the middle band. Groups 3 and 4 on top reach 89%. Co-Authored-By: Claude Opus 5 (1M context) Signed-off-by: Frederic BIDON --- json/lexers/yaml-lexer/CONFORMANCE.md | 50 +++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/json/lexers/yaml-lexer/CONFORMANCE.md b/json/lexers/yaml-lexer/CONFORMANCE.md index a60f69f..5dd1ce0 100644 --- a/json/lexers/yaml-lexer/CONFORMANCE.md +++ b/json/lexers/yaml-lexer/CONFORMANCE.md @@ -35,6 +35,51 @@ so there is nothing to compare — only the accept/reject verdict, which `testdata/conformance_recorded.golden` pins so out-of-scope cannot quietly become unnoticed regression. +## How that compares to other implementations + +The [YAML Test Matrix](https://matrix.yaml.info/) publishes a **JSON output** comparison +over the same suite — "is the loaded data equal to the `json` field" — which is the same +question we ask. Its denominator is 401 (308 valid + 93 invalid). + +Our comparable slice is 366 cases (272 with a single-root JSON expectation + 94 invalid), +scoring **289 → 79%**. Counting the 40 cases with no JSON equivalent as misses instead — +a stricter reading — gives **289/406 → 71%**. So we sit somewhere in **71–79%** depending +on how the out-of-scope cases are counted. + +| implementation | JSON comparison | +|---|---| +| C libfyaml | 93% | +| JS yaml | 92% | +| Perl YAML::PP | 92% | +| Haskell HsYAML | 91% | +| Python ruamel.yaml | 78% | +| Perl YAML::PP+libyaml | 78% | +| **`YL` (this lexer)** | **71–79%** | +| JS js-yaml | 76% | +| Ruby psych | 76% | +| Go go-yaml | 76% | +| Python PyYAML | 75% | +| Perl YAML::XS | 75% | +| Lua lyaml | 72% | +| C# YamlDotNet | 64% | +| Perl Syck / YAML.pm / YAML::Tiny | 52% / 44% / 31% | + +Read that carefully rather than as a ranking — three things make it not apples-to-apples: + +- **Different subject.** The matrix measures *loaders*: parse to a data structure, serialize + to JSON, compare. We measure a *lexer's token stream*. Ours is the narrower claim. +- **We forfeit points by design.** Multi-document streams and complex keys are deliberately + unsupported, and they count against us here. A loader has no such excuse. +- **Our floor is goccy's.** We are built on `goccy/go-yaml`, which the matrix does not test + (its `go-yaml` entry is a different project). 12 of our 54 divergences — the 9 + over-permissive accepts and the 3 parse failures — are goccy's behavior, not ours, and we + cannot beat it without pre-validating ourselves. + +The useful takeaway: **we are in the same band as the mainstream loaders** (PyYAML, psych, +go-yaml, ruamel, js-yaml) and clearly behind the four leaders. And the single biggest gap is +ours to close: fixing resolved-scalar keys (group 1 below, 23 cases) would put the +comparable slice at roughly **85%**, above every implementation in the middle band. + ## The 54 divergences ### 1. Non-scalar mapping keys — 23 cases @@ -118,8 +163,9 @@ header 6 indent 6 anchor 5 1.3-err 4 double 4 … In rough order of value per unit of effort: 1. **Resolved-scalar keys** (group 1) — 23 cases, one coherent feature: resolve an - alias/anchor/tag on the key side and use the resulting scalar. Would take the - accept rate from 75% to roughly 82%. + alias/anchor/tag on the key side and use the resulting scalar. Takes the comparable + slice from 79% to **85%**, above every implementation in the matrix's middle band. + Adding groups 3 and 4 on top would reach **89%**, within reach of the leaders. 2. **Over-permissiveness** (group 3) — 9 cases, and the only group where we accept documents we should reject. Worth confirming against goccy first. 3. **Scalar resolution** (group 4) — 5 cases, each needing individual reading. From 18c636a1ec3e3a4fc9808322f052fd60f564ff35 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Thu, 30 Jul 2026 23:46:57 +0200 Subject: [PATCH 3/5] test(yaml-lexer): make the conformance harness line-ending independent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Conformance fixtures are DATA: their exact bytes are the test. A checkout with core.autocrlf=true (the Windows default) rewrites every LF to CRLF and silently changes what is being measured — a YAML fixture that hinges on a trailing space or a hard tab becomes a different document, and the failure looks like a lexer bug rather than a checkout artefact. The repo-wide fix already landed on master (.gitattributes marks testdata/**, *.golden and generated *.s as -text, so git never translates them). This is the other half, for the YAML harness: a suite that arrived some other way — an unmarked clone, a zip, a copy through a Windows tool — must still yield the documents upstream wrote, so the loader normalises CRLF to LF on read. Ordering matters and is the subtle part: normalisation runs BEFORE unescaping, so the suite's "←" (an intentional carriage return) is still the only way a CR enters a case. Normalising after would have eaten it. No vendored fixture contains a raw CR byte, which is what makes the normalisation safe. Tested as a property rather than assumed: the whole suite is copied to CRLF into a temp dir, re-loaded through the real loader, and every case asserted byte-identical to its LF original — that would catch a leak anywhere in the path, including inside the YAML parser the fixtures are read with. Plus unit coverage for the narrow contract (CRLF collapses, a lone CR survives) and a guard that the committed fixtures are still stored with LF. Mutation-checked: stubbing normalizeLineEndings to the identity fails the line-ending tests, so they have teeth. Signed-off-by: Frederic BIDON Co-Authored-By: Claude Opus 5 (1M context) --- .../yaml-lexer/conformance_golden_test.go | 15 +- .../conformance_lineendings_test.go | 163 ++++++++++++++++++ .../yaml-lexer/conformance_suite_test.go | 32 +++- 3 files changed, 204 insertions(+), 6 deletions(-) create mode 100644 json/lexers/yaml-lexer/conformance_lineendings_test.go diff --git a/json/lexers/yaml-lexer/conformance_golden_test.go b/json/lexers/yaml-lexer/conformance_golden_test.go index 20135f7..289ec78 100644 --- a/json/lexers/yaml-lexer/conformance_golden_test.go +++ b/json/lexers/yaml-lexer/conformance_golden_test.go @@ -61,14 +61,19 @@ func checkRecordedGolden(t *testing.T, records map[string]string) { t.Fatalf("cannot read %s (run with -update-golden to create it): %v", golden, err) } - if string(want) == got { + // a golden checked out with CRLF must still compare equal: the file records verdicts, not bytes on a line + if normalizeLineEndings(string(want)) == got { return } - t.Errorf("recorded behavior changed for out-of-scope cases.\n"+ - "If the change is intended, re-run with -update-golden and review the diff.\n%s", - diffRecorded(strings.Split(strings.TrimRight(string(want), "\n"), "\n"), - strings.Split(strings.TrimRight(got, "\n"), "\n"))) + t.Errorf( + "recorded behavior changed for out-of-scope cases.\n"+ + "If the change is intended, re-run with -update-golden and review the diff.\n%s", + diffRecorded( + strings.Split(strings.TrimRight(normalizeLineEndings(string(want)), "\n"), "\n"), + strings.Split(strings.TrimRight(got, "\n"), "\n"), + ), + ) } func diffRecorded(want, got []string) string { diff --git a/json/lexers/yaml-lexer/conformance_lineendings_test.go b/json/lexers/yaml-lexer/conformance_lineendings_test.go new file mode 100644 index 0000000..480c74a --- /dev/null +++ b/json/lexers/yaml-lexer/conformance_lineendings_test.go @@ -0,0 +1,163 @@ +package lexer_test + +import ( + "os" + "path/filepath" + "strings" + "testing" + + "github.com/go-openapi/testify/v2/assert" + "github.com/go-openapi/testify/v2/require" +) + +// Line-ending independence. +// +// The vendored fixtures are stored with LF and .gitattributes marks them -text, but a checkout can still arrive with +// CRLF — an unmarked clone, a zip, a copy through a Windows tool. When that happens the harness must test the same +// documents, not silently different ones: a YAML fixture read as CRLF is a different document, and the failure would +// look like a lexer bug rather than a checkout artefact. +// +// These tests assert the property directly instead of trusting the .gitattributes to be present and correct. + +// TestSuiteFixturesAreStoredWithLF guards the fixtures as committed: if one ever lands with CRLF, the harness would +// still cope, but the repository would have drifted from what upstream published. +func TestSuiteFixturesAreStoredWithLF(t *testing.T) { + dir := filepath.Join(currentDir(), "testdata", "yaml-test-suite", "src") + entries, err := os.ReadDir(dir) + require.NoError(t, err) + require.NotEmpty(t, entries) + + var withCRLF []string + for _, e := range entries { + if e.IsDir() { + continue + } + data, rerr := os.ReadFile(filepath.Join(dir, e.Name())) + require.NoError(t, rerr) + if strings.Contains(string(data), "\r\n") { + withCRLF = append(withCRLF, e.Name()) + } + } + + assert.Emptyf(t, withCRLF, + "fixtures must be stored with LF (see .gitattributes); found CRLF in %v", withCRLF) +} + +// TestNormalizeLineEndings pins the narrow contract: CRLF collapses to LF, and a lone CR is left alone so the +// suite's "←" (an intentional carriage return) survives. +func TestNormalizeLineEndings(t *testing.T) { + cases := []struct { + name string + in string + want string + }{ + {name: "no CR at all", in: "a\nb\n", want: "a\nb\n"}, + {name: "CRLF", in: "a\r\nb\r\n", want: "a\nb\n"}, + {name: "mixed", in: "a\r\nb\nc\r\n", want: "a\nb\nc\n"}, + {name: "lone CR is preserved", in: "a\rb", want: "a\rb"}, + {name: "CR at end preserved", in: "a\r", want: "a\r"}, + {name: "empty", in: "", want: ""}, + } + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + assert.Equal(t, tc.want, normalizeLineEndings(tc.in)) + }) + } +} + +// TestSuiteUnescapeIsLineEndingIndependent is the property that matters: a fixture converted to CRLF must yield +// exactly the same case data as the LF original, INCLUDING the carriage returns the suite asks for explicitly. +func TestSuiteUnescapeIsLineEndingIndependent(t *testing.T) { + cases := []struct { + name string + lf string + }{ + {name: "plain", lf: "a: 1\nb: 2\n"}, + {name: "trailing space", lf: "a: 1␣\nb: 2\n"}, + {name: "hard tab", lf: "a:\t1\nfoo:———»bar\n"}, + {name: "no final newline", lf: "a: 1∎\n"}, + {name: "explicit carriage return", lf: "a: 1←\nb: 2\n"}, + {name: "byte order mark", lf: "⇔a: 1\n"}, + {name: "trailing newline marker", lf: "a: 1↵\n"}, + } + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + crlf := strings.ReplaceAll(tc.lf, "\n", "\r\n") + + fromLF := suiteUnescape(normalizeLineEndings(tc.lf)) + fromCRLF := suiteUnescape(normalizeLineEndings(crlf)) + + assert.Equalf(t, fromLF, fromCRLF, + "a CRLF fixture must yield the same case as its LF original\n LF =%q\n CRLF=%q", + fromLF, fromCRLF) + }) + } + + t.Run("an explicit CR survives normalisation", func(t *testing.T) { + // "←" is the ONLY way a carriage return should enter a case; normalising must not have eaten it + assert.Equal(t, "a: 1\r\nb\n", suiteUnescape(normalizeLineEndings("a: 1←\nb\n"))) + }) +} + +// TestLoadSuiteIsLineEndingIndependent runs the real loader over a CRLF copy of the whole vendored suite and asserts +// every case comes out byte-identical. This is the end-to-end version of the property: it would catch a CRLF leak +// anywhere in the path, including inside the YAML parser we read the fixtures with. +func TestLoadSuiteIsLineEndingIndependent(t *testing.T) { + if testing.Short() { + t.Skip("copies and re-parses the whole suite") + } + + lf := loadSuite(t) + require.NotEmpty(t, lf) + + crlf := loadSuiteFrom(t, crlfCopyOfSuite(t)) + require.Len(t, crlf, len(lf), "the CRLF copy must yield the same number of cases") + + for i := range lf { + require.Equalf(t, lf[i].label(), crlf[i].label(), "case %d", i) + assert.Equalf( + t, + lf[i].yaml, + crlf[i].yaml, + "%s: yaml input differs between LF and CRLF checkouts", + lf[i].label(), + ) + assert.Equalf( + t, + lf[i].json, + crlf[i].json, + "%s: expected JSON differs between LF and CRLF checkouts", + lf[i].label(), + ) + assert.Equalf(t, lf[i].fail, crlf[i].fail, "%s: fail flag differs", lf[i].label()) + } +} + +// crlfCopyOfSuite writes a CRLF-converted copy of the vendored fixtures into a temp dir and returns its path. +func crlfCopyOfSuite(t *testing.T) string { + t.Helper() + + src := filepath.Join(currentDir(), "testdata", "yaml-test-suite", "src") + dst := filepath.Join(t.TempDir(), "src") + require.NoError(t, os.MkdirAll(dst, 0o750)) + + entries, err := os.ReadDir(src) + require.NoError(t, err) + + for _, e := range entries { + if e.IsDir() || !strings.HasSuffix(e.Name(), ".yaml") { + continue + } + data, rerr := os.ReadFile(filepath.Join(src, e.Name())) + require.NoError(t, rerr) + + converted := strings.ReplaceAll(string(data), "\n", "\r\n") + out := filepath.Join(dst, filepath.Base(e.Name())) + //nolint:gosec // out is t.TempDir() joined with a base name from ReadDir over our own vendored fixtures + require.NoError(t, os.WriteFile(out, []byte(converted), 0o600)) + } + + return dst +} diff --git a/json/lexers/yaml-lexer/conformance_suite_test.go b/json/lexers/yaml-lexer/conformance_suite_test.go index 1aa5b67..7ecddd8 100644 --- a/json/lexers/yaml-lexer/conformance_suite_test.go +++ b/json/lexers/yaml-lexer/conformance_suite_test.go @@ -55,10 +55,29 @@ type rawCase struct { Fail *bool `yaml:"fail"` } +// normalizeLineEndings turns CRLF into LF. +// +// The fixtures are stored with LF and .gitattributes marks them -text so git never translates them, but a checkout +// can still arrive with CRLF (an unmarked clone, an archive, a copy through a Windows tool). Every fixture is +// normalised on the way in so the harness tests the document the suite wrote rather than the one the filesystem +// delivered. +// +// This cannot destroy a meaningful CR: the suite writes an intended carriage return as "←", which suiteUnescape +// turns into one AFTER this runs. No vendored fixture contains a raw CR byte. +func normalizeLineEndings(s string) string { + if !strings.Contains(s, "\r") { + return s + } + + return strings.ReplaceAll(s, "\r\n", "\n") +} + // suiteUnescape translates the suite's visible stand-ins back into the characters they represent. // // This is the Go equivalent of upstream's bin/YAMLTestSuite.pm `sub unescape`, and it is not optional: several cases // hinge on a trailing space or a hard tab that would otherwise be invisible (and would be stripped by an editor). +// +// It runs AFTER normalizeLineEndings, so "←" is the only way a CR enters a case. func suiteUnescape(s string) string { s = strings.ReplaceAll(s, "␣", " ") @@ -84,7 +103,14 @@ func suiteUnescape(s string) string { func loadSuite(t *testing.T) []suiteCase { t.Helper() - dir := filepath.Join(currentDir(), "testdata", "yaml-test-suite", "src") + return loadSuiteFrom(t, filepath.Join(currentDir(), "testdata", "yaml-test-suite", "src")) +} + +// loadSuiteFrom is [loadSuite] over an arbitrary fixture directory, so the loader itself can be exercised against a +// differently-encoded copy of the suite (see the line-ending tests). +func loadSuiteFrom(t *testing.T, dir string) []suiteCase { + t.Helper() + entries, err := os.ReadDir(dir) if err != nil { t.Fatalf("cannot read the vendored YAML test suite: %v", err) @@ -101,6 +127,10 @@ func loadSuite(t *testing.T) []suiteCase { t.Fatalf("cannot read %s: %v", e.Name(), rerr) } + // normalise before parsing: a CRLF fixture would otherwise reach goccy as a different document, and + // whether a block scalar keeps or drops the CR is not something to depend on + data = []byte(normalizeLineEndings(string(data))) + var raws []rawCase if uerr := yaml.Unmarshal(data, &raws); uerr != nil { t.Fatalf("cannot parse the suite fixture %s: %v", e.Name(), uerr) From a820b2e0a845779559c067b4aa664abd14d1e1c4 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Fri, 31 Jul 2026 07:31:55 +0200 Subject: [PATCH 4/5] doc: recalled license terms for YAML test suite Signed-off-by: Frederic BIDON --- NOTICE | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/NOTICE b/NOTICE index 8b92632..6364f57 100644 --- a/NOTICE +++ b/NOTICE @@ -42,3 +42,31 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +https://github.com/yaml/yaml-test-suite +=========================== + +// SPDX-FileCopyrightText: Copyright (c) 2016-2020 Ingy dot net +// SPDX-License-Identifier: MIT + +MIT License + +Copyright (c) 2016-2020 Ingy döt Net + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From e8fa0c7367884e0279a31a75cdd80225a12fe3cc Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Fri, 31 Jul 2026 07:59:33 +0200 Subject: [PATCH 5/5] chore: linting Signed-off-by: Frederic BIDON --- json/lexers/yaml-lexer/fuzz_test.go | 5 +++-- json/lexers/yaml-lexer/lexer.go | 20 ++++++++++---------- json/lexers/yaml-lexer/number.go | 15 +++++++++++---- json/lexers/yaml-lexer/options.go | 3 ++- json/lexers/yaml-lexer/pointer_test.go | 1 + json/lexers/yaml-lexer/walk.go | 6 ++++-- 6 files changed, 31 insertions(+), 19 deletions(-) diff --git a/json/lexers/yaml-lexer/fuzz_test.go b/json/lexers/yaml-lexer/fuzz_test.go index 0e9ed21..3f159ec 100644 --- a/json/lexers/yaml-lexer/fuzz_test.go +++ b/json/lexers/yaml-lexer/fuzz_test.go @@ -23,6 +23,7 @@ package lexer_test import ( "bytes" + "errors" "fmt" "iter" "testing" @@ -88,7 +89,7 @@ func fzValidate(toks []fzTok) error { consumeValue := func() error { if len(st) == 0 { if rootDone { - return fmt.Errorf("second root value") + return errors.New("second root value") } rootDone = true @@ -97,7 +98,7 @@ func fzValidate(toks []fzTok) error { top := &st[len(st)-1] if top.obj { if top.expectKey { - return fmt.Errorf("value where object key expected") + return errors.New("value where object key expected") } top.expectKey = true } diff --git a/json/lexers/yaml-lexer/lexer.go b/json/lexers/yaml-lexer/lexer.go index 0050e8a..abd43a8 100644 --- a/json/lexers/yaml-lexer/lexer.go +++ b/json/lexers/yaml-lexer/lexer.go @@ -90,16 +90,6 @@ func NewWithBytes(data []byte, opts ...Option) *YL { return l } -// setReader drains r into l.data. A read error is stored as the lexer error state and -// surfaced on the first token. -func (l *YL) setReader(r io.Reader) { - data, err := io.ReadAll(r) - l.data = data - if err != nil { - l.err = err - } -} - // NextToken returns the next token from the YAML input, or [token.EOFToken] once the stream // is exhausted. As with the JSON lexer, errors are not returned: they are kept in the // lexer's state (check Ok/Err). @@ -201,6 +191,16 @@ func (l *YL) ResetWithReader(r io.Reader) { l.setReader(r) } +// setReader drains r into l.data. A read error is stored as the lexer error state and +// surfaced on the first token. +func (l *YL) setReader(r io.Reader) { + data, err := io.ReadAll(r) + l.data = data + if err != nil { + l.err = err + } +} + // reset clears the per-input scanning state, preserving allocated capacity for reuse. func (l *YL) reset() { l.toks = l.toks[:0] diff --git a/json/lexers/yaml-lexer/number.go b/json/lexers/yaml-lexer/number.go index f5508c7..b0f68ab 100644 --- a/json/lexers/yaml-lexer/number.go +++ b/json/lexers/yaml-lexer/number.go @@ -80,12 +80,19 @@ func convertYAMLInt(raw string, base int) ([]byte, bool) { s = s[1:] } + const ( + baseDecimal = 10 + baseHexa = 16 + baseOctal = 8 + baseBinary = 2 + ) + switch base { - case 16: + case baseHexa: s = trimBasePrefix(s, 'x') - case 8: + case baseOctal: s = trimBasePrefix(s, 'o') - case 2: + case baseBinary: s = trimBasePrefix(s, 'b') } @@ -101,7 +108,7 @@ func convertYAMLInt(raw string, base int) ([]byte, bool) { z.Neg(&z) } - return z.Append(nil, 10), true + return z.Append(nil, baseDecimal), true } // convertYAMLFloat normalises a YAML float spelling into a canonical JSON number, purely diff --git a/json/lexers/yaml-lexer/options.go b/json/lexers/yaml-lexer/options.go index 8cf3e30..0d4f9de 100644 --- a/json/lexers/yaml-lexer/options.go +++ b/json/lexers/yaml-lexer/options.go @@ -12,8 +12,9 @@ type ( } ) -var defaultOptions = options{} +var defaultOptions = options{} //nolint:gochecknoglobals // it's okay to keep defaults as a preallocated immutable global +//nolint:staticcheck,unparam // we force defaults options here - the o parameter is only here to avoid any allocation func applyWithDefaults(o options, opts []Option) options { o = defaultOptions for _, apply := range opts { diff --git a/json/lexers/yaml-lexer/pointer_test.go b/json/lexers/yaml-lexer/pointer_test.go index 3af2086..a209216 100644 --- a/json/lexers/yaml-lexer/pointer_test.go +++ b/json/lexers/yaml-lexer/pointer_test.go @@ -149,6 +149,7 @@ func TestJSONPointerClone(t *testing.T) { // drain the rest; the clone must be unaffected for range l.Tokens() { + continue } assert.Equal(t, "/a/b", savedClone.String()) } diff --git a/json/lexers/yaml-lexer/walk.go b/json/lexers/yaml-lexer/walk.go index cef4b84..6f433d0 100644 --- a/json/lexers/yaml-lexer/walk.go +++ b/json/lexers/yaml-lexer/walk.go @@ -432,7 +432,7 @@ func (l *YL) walkInteger(n *ast.IntegerNode, lvl int) { return } - base := 10 + var base int switch n.Token.Type { case yamltoken.HexIntegerType: base = 16 @@ -440,6 +440,8 @@ func (l *YL) walkInteger(n *ast.IntegerNode, lvl int) { base = 8 case yamltoken.BinaryIntegerType: base = 2 + default: + base = 10 } b, ok := convertYAMLInt(raw, base) @@ -511,7 +513,7 @@ func (l *YL) put(tok token.T, pos *yamltoken.Position, lvl int) { e := emit{tok: tok, lvl: lvl} if pos != nil { - e.off = uint64(pos.Offset) + e.off = uint64(pos.Offset) //nolint:gosec // no overflow, no negative values e.line = pos.Line e.col = pos.Column }