├── project ├── build.properties ├── Deps.scala └── plugin.sbt ├── .scalafmt.conf ├── integration-tests ├── README.md └── src │ └── test │ ├── resources │ └── yaml │ │ └── test-suite │ │ ├── U99R.tml │ │ ├── HWV9.tml │ │ ├── LHL4.tml │ │ ├── AVM7.tml │ │ ├── B63P.tml │ │ ├── 2CMS.tml │ │ ├── 55WF.tml │ │ ├── SF5V.tml │ │ ├── SY6V.tml │ │ ├── C2SP.tml │ │ ├── 8MK2.tml │ │ ├── EW3V.tml │ │ ├── CXX2.tml │ │ ├── G7JE.tml │ │ ├── GT5M.tml │ │ ├── QT73.tml │ │ ├── ZL4Z.tml │ │ ├── 236B.tml │ │ ├── 5U3A.tml │ │ ├── 5TRB.tml │ │ ├── 7LBH.tml │ │ ├── 9MAG.tml │ │ ├── RXY3.tml │ │ ├── D49Q.tml │ │ ├── N782.tml │ │ ├── TD5N.tml │ │ ├── BD7L.tml │ │ ├── CQ3W.tml │ │ ├── DK4H.tml │ │ ├── 7MNF.tml │ │ ├── GDY7.tml │ │ ├── NHX8.tml │ │ ├── ZVH3.tml │ │ ├── ZXT5.tml │ │ ├── 4UYU.tml │ │ ├── 98YD.tml │ │ ├── CTN5.tml │ │ ├── QB6E.tml │ │ ├── T833.tml │ │ ├── X4QW.tml │ │ ├── 2JQS.tml │ │ ├── DMG6.tml │ │ ├── Q5MG.tml │ │ ├── S4GJ.tml │ │ ├── SU5Z.tml │ │ ├── SU74.tml │ │ ├── CVW2.tml │ │ ├── 9C9N.tml │ │ ├── G9HC.tml │ │ ├── 6JTT.tml │ │ ├── 6S55.tml │ │ ├── RHX7.tml │ │ ├── ZCZ6.tml │ │ ├── 3HFZ.tml │ │ ├── 4H7K.tml │ │ ├── 8G76.tml │ │ ├── 9HCY.tml │ │ ├── 9JBA.tml │ │ ├── 9KBC.tml │ │ ├── BS4K.tml │ │ ├── 4HVU.tml │ │ ├── 52DL.tml │ │ ├── HRE5.tml │ │ ├── P2EQ.tml │ │ ├── SR86.tml │ │ ├── 9CWY.tml │ │ ├── K54U.tml │ │ ├── KS4U.tml │ │ ├── 5LLU.tml │ │ ├── 62EZ.tml │ │ ├── 65WH.tml │ │ ├── EB22.tml │ │ ├── HU3P.tml │ │ ├── U44R.tml │ │ ├── 4EJS.tml │ │ ├── BF9H.tml │ │ ├── N4JP.tml │ │ ├── S7BG.tml │ │ ├── MYW6.tml │ │ ├── 3R3P.tml │ │ ├── 4GC6.tml │ │ ├── 6XDY.tml │ │ ├── 82AN.tml │ │ ├── Q4CL.tml │ │ ├── LX3P.tml │ │ ├── 8XDJ.tml │ │ ├── CML9.tml │ │ ├── D9TU.tml │ │ ├── JY7Z.tml │ │ ├── S98Z.tml │ │ ├── S4T7.tml │ │ ├── 27NA.tml │ │ ├── 3UYS.tml │ │ ├── 6H3V.tml │ │ ├── MXS3.tml │ │ ├── G992.tml │ │ ├── W9L4.tml │ │ ├── FP8R.tml │ │ ├── XLQ9.tml │ │ ├── 4V8U.tml │ │ ├── TS54.tml │ │ ├── 3ALJ.tml │ │ ├── 753E.tml │ │ ├── K4SU.tml │ │ ├── Y2GN.tml │ │ ├── 5MUD.tml │ │ ├── 5NYZ.tml │ │ ├── A984.tml │ │ ├── CPZ3.tml │ │ ├── E76Z.tml │ │ ├── FRK4.tml │ │ ├── FTA2.tml │ │ ├── W5VH.tml │ │ ├── ZH7C.tml │ │ ├── D88J.tml │ │ ├── SSW6.tml │ │ ├── 4MUZ.tml │ │ ├── BEC7.tml │ │ ├── RR7F.tml │ │ ├── FUP4.tml │ │ ├── H7J7.tml │ │ ├── J7VC.tml │ │ ├── M9B4.tml │ │ ├── 8XYN.tml │ │ ├── 9J7A.tml │ │ ├── U3C3.tml │ │ ├── V55R.tml │ │ ├── 9SHH.tml │ │ ├── 9YRD.tml │ │ ├── DHP8.tml │ │ ├── G5U8.tml │ │ ├── P94K.tml │ │ ├── PUW8.tml │ │ ├── TL85.tml │ │ ├── EXG3.tml │ │ ├── GH63.tml │ │ ├── H3Z8.tml │ │ ├── 3MYT.tml │ │ ├── 7W2P.tml │ │ ├── QF4Y.tml │ │ ├── SBG9.tml │ │ ├── X8DW.tml │ │ ├── 36F6.tml │ │ ├── 6LVF.tml │ │ ├── K3WX.tml │ │ ├── 54T7.tml │ │ ├── 7TMG.tml │ │ ├── AB8U.tml │ │ ├── AZ63.tml │ │ ├── B3HG.tml │ │ ├── DK3J.tml │ │ ├── KMK3.tml │ │ ├── M29M.tml │ │ ├── 8QBE.tml │ │ ├── QLJ7.tml │ │ ├── UDM2.tml │ │ ├── AZW3.tml │ │ ├── RTP8.tml │ │ ├── 6FWR.tml │ │ ├── CC74.tml │ │ ├── JTV5.tml │ │ ├── K527.tml │ │ ├── MJS9.tml │ │ ├── 7FWL.tml │ │ ├── 8CWC.tml │ │ ├── CT4Q.tml │ │ ├── NB6Z.tml │ │ ├── 4Q9F.tml │ │ ├── J5UC.tml │ │ ├── 6KGN.tml │ │ ├── 7Z25.tml │ │ ├── DFF7.tml │ │ ├── 2AUY.tml │ │ ├── 2LFX.tml │ │ ├── S4JQ.tml │ │ ├── TE2A.tml │ │ ├── 4JVG.tml │ │ ├── JS2J.tml │ │ ├── V9D5.tml │ │ ├── 6PBE.tml │ │ ├── L94M.tml │ │ ├── P76L.tml │ │ ├── 6JQW.tml │ │ ├── 6WPF.tml │ │ ├── 93WF.tml │ │ ├── 7A4E.tml │ │ ├── CFD4.tml │ │ ├── DC7X.tml │ │ ├── WZ62.tml │ │ ├── 4ABK.tml │ │ ├── LE5A.tml │ │ ├── T5N4.tml │ │ ├── 6BFJ.tml │ │ ├── SKE5.tml │ │ ├── X38W.tml │ │ ├── Z9M4.tml │ │ ├── MZX3.tml │ │ ├── 6M2F.tml │ │ ├── EHF6.tml │ │ ├── HS5T.tml │ │ ├── ZWK4.tml │ │ ├── 33X3.tml │ │ ├── 5TYM.tml │ │ ├── EX5H.tml │ │ ├── RLU9.tml │ │ ├── ZK9H.tml │ │ ├── HMQ5.tml │ │ ├── S3PD.tml │ │ ├── CUP7.tml │ │ ├── D83L.tml │ │ ├── 6CK3.tml │ │ ├── Z67P.tml │ │ ├── 6SLA.tml │ │ ├── SYW4.tml │ │ ├── NP9H.tml │ │ ├── 5KJE.tml │ │ ├── FH7J.tml │ │ ├── 96L6.tml │ │ ├── DWX9.tml │ │ ├── M5C3.tml │ │ ├── 5BVJ.tml │ │ ├── UT92.tml │ │ ├── JQ4R.tml │ │ ├── C2DT.tml │ │ ├── F2C7.tml │ │ ├── 9TFX.tml │ │ ├── PRH3.tml │ │ ├── A6F9.tml │ │ ├── 93JH.tml │ │ ├── NJ66.tml │ │ ├── 5T43.tml │ │ ├── L9U5.tml │ │ ├── 4FJ6.tml │ │ ├── T4YY.tml │ │ ├── 9WXW.tml │ │ ├── LQZ7.tml │ │ ├── T26H.tml │ │ ├── 9FMG.tml │ │ ├── 9SA2.tml │ │ ├── 2SXE.tml │ │ ├── 6BCT.tml │ │ ├── 87E4.tml │ │ ├── W4TN.tml │ │ ├── K858.tml │ │ ├── 6JWB.tml │ │ ├── 6ZKB.tml │ │ ├── Q88A.tml │ │ ├── A2M4.tml │ │ ├── BU8L.tml │ │ ├── Q9WF.tml │ │ ├── F3CP.tml │ │ ├── FQ7F.tml │ │ ├── KSS4.tml │ │ ├── XV9V.tml │ │ ├── Q8AD.tml │ │ ├── 735Y.tml │ │ ├── 3GZX.tml │ │ ├── 9MMW.tml │ │ ├── 5GBF.tml │ │ ├── 5WE3.tml │ │ ├── 5C5M.tml │ │ ├── 8KB6.tml │ │ ├── 4CQQ.tml │ │ ├── 9DXL.tml │ │ ├── M7NX.tml │ │ ├── PW8X.tml │ │ ├── P2AD.tml │ │ ├── 35KP.tml │ │ ├── R52L.tml │ │ ├── 4QFQ.tml │ │ ├── 74H7.tml │ │ ├── 9BXH.tml │ │ ├── F6MC.tml │ │ ├── LP6E.tml │ │ ├── UDR7.tml │ │ ├── W42U.tml │ │ ├── 6WLZ.tml │ │ ├── CN3R.tml │ │ ├── J3BT.tml │ │ ├── M7A3.tml │ │ ├── 7T8X.tml │ │ ├── R4YG.tml │ │ ├── S9E8.tml │ │ ├── 2XXW.tml │ │ ├── H2RW.tml │ │ ├── 8UDB.tml │ │ ├── 4ZYM.tml │ │ ├── F8F9.tml │ │ ├── ZF4X.tml │ │ ├── 57H4.tml │ │ ├── 6VJK.tml │ │ ├── XW4D.tml │ │ ├── RZP5.tml │ │ ├── 7ZZ5.tml │ │ ├── M5DY.tml │ │ ├── NKF9.tml │ │ ├── YD5X.tml │ │ ├── J9HZ.tml │ │ ├── 2EBW.tml │ │ ├── JHB9.tml │ │ ├── 229Q.tml │ │ ├── 7BUB.tml │ │ ├── U9NS.tml │ │ ├── FBC9.tml │ │ └── HMK4.tml │ └── scala │ └── org │ └── virtuslab │ └── yaml │ ├── OfficialTestSuiteSpec.scala │ └── K8sConfigSpec.scala ├── core ├── shared │ └── src │ │ ├── main │ │ ├── scala-2 │ │ │ └── org │ │ │ │ └── virtuslab │ │ │ │ └── yaml │ │ │ │ ├── YamlCodecCrossCompat.scala │ │ │ │ ├── YamlDecoderCrossCompat.scala │ │ │ │ ├── YamlEncoderCrossCompat.scala │ │ │ │ └── syntax │ │ │ │ └── YamlPrimitiveCrossCompat.scala │ │ ├── scala │ │ │ └── org │ │ │ │ └── virtuslab │ │ │ │ └── yaml │ │ │ │ ├── LoadSettings.scala │ │ │ │ ├── internal │ │ │ │ ├── dump │ │ │ │ │ ├── present │ │ │ │ │ │ └── Presenter.scala │ │ │ │ │ └── serialize │ │ │ │ │ │ └── Serializer.scala │ │ │ │ └── load │ │ │ │ │ ├── parse │ │ │ │ │ └── Parser.scala │ │ │ │ │ └── TagHandle.scala │ │ │ │ ├── syntax │ │ │ │ ├── YamlPrimitive.scala │ │ │ │ └── NodeSelector.scala │ │ │ │ └── Range.scala │ │ └── scala-3 │ │ │ └── org │ │ │ └── virtuslab │ │ │ └── yaml │ │ │ ├── derivers.scala │ │ │ ├── YamlCodecCrossCompat.scala │ │ │ └── syntax │ │ │ └── YamlPrimitiveCrossCompat.scala │ │ └── test │ │ ├── scala │ │ └── org │ │ │ └── virtuslab │ │ │ └── yaml │ │ │ ├── TestOps.scala │ │ │ └── decoder │ │ │ └── BaseDecoderErrorSuite.scala │ │ └── scala-3 │ │ └── org │ │ └── virtuslab │ │ └── yaml │ │ └── decoder │ │ └── DecoderErrorsSuite.scala ├── jvm │ └── src │ │ └── test │ │ └── org │ │ └── virtuslab │ │ └── yaml │ │ └── YamlEncoderSuite.scala └── js │ └── src │ └── test │ └── org │ └── virtuslab │ └── yaml │ └── YamlEncoderSuite.scala ├── .github ├── dependabot.yml └── workflows │ └── release-drafter.yml ├── docs ├── _docs │ └── contributing.md └── sidebar.yml ├── .scalafix.conf └── .gitignore /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.11.7 2 | -------------------------------------------------------------------------------- /.scalafmt.conf: -------------------------------------------------------------------------------- 1 | version = "3.5.8" 2 | runner.dialect = scala3 3 | 4 | align.preset = more 5 | maxColumn = 100 6 | docstrings.style=keep 7 | -------------------------------------------------------------------------------- /integration-tests/README.md: -------------------------------------------------------------------------------- 1 | ### Test suite 2 | 3 | Yaml test suite are used in integration testing - https://github.com/yaml/yaml-test-suite -------------------------------------------------------------------------------- /core/shared/src/main/scala-2/org/virtuslab/yaml/YamlCodecCrossCompat.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml 2 | 3 | private[yaml] trait YamlCodecCompanionCrossCompat 4 | -------------------------------------------------------------------------------- /core/shared/src/main/scala-2/org/virtuslab/yaml/YamlDecoderCrossCompat.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml 2 | 3 | private[yaml] trait YamlDecoderCompanionCrossCompat 4 | -------------------------------------------------------------------------------- /core/shared/src/main/scala-2/org/virtuslab/yaml/YamlEncoderCrossCompat.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml 2 | 3 | private[yaml] trait YamlEncoderCrossCompanionCompat 4 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | -------------------------------------------------------------------------------- /docs/_docs/contributing.md: -------------------------------------------------------------------------------- 1 | # Run unit tests 2 | 3 | ``` 4 | $ sbt test 5 | ``` 6 | 7 | # Run integration tests 8 | 9 | ``` 10 | $ sbt IntegrationTest/test 11 | ``` -------------------------------------------------------------------------------- /docs/sidebar.yml: -------------------------------------------------------------------------------- 1 | index: index.md 2 | subsection: 3 | - title: Quick start 4 | page: quickstart.md 5 | - title: Examples 6 | page: examples.md 7 | - title: Contributing guide 8 | page: contributing.md 9 | -------------------------------------------------------------------------------- /core/shared/src/main/scala/org/virtuslab/yaml/LoadSettings.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml 2 | 3 | case class LoadSettings(constructors: Map[Tag, YamlDecoder[_]]) 4 | object LoadSettings { 5 | val empty = LoadSettings(Map.empty) 6 | } 7 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/U99R.tml: -------------------------------------------------------------------------------- 1 | === Invalid comma in tag 2 | --- from: @perlpunk 3 | --- tags: error tag 4 | 5 | --- in-yaml(<) 6 | - !!str, xxx 7 | 8 | --- error 9 | 10 | --- test-event 11 | +STR 12 | +DOC 13 | +SEQ 14 | -------------------------------------------------------------------------------- /project/Deps.scala: -------------------------------------------------------------------------------- 1 | import sbt._ 2 | 3 | object Deps { 4 | lazy val munit = "org.scalameta" %% "munit" % "1.2.1" 5 | 6 | lazy val osLib = "com.lihaoyi" %% "os-lib" % "0.11.6" 7 | 8 | lazy val pprint = "com.lihaoyi" %% "pprint" % "0.9.6" 9 | } 10 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/HWV9.tml: -------------------------------------------------------------------------------- 1 | === Document-end marker 2 | --- from: @perlpunk 3 | --- tags: footer 4 | 5 | --- in-yaml(<) 6 | ... 7 | 8 | --- out-yaml(<) 9 | 10 | --- in-json 11 | 12 | --- test-event 13 | +STR 14 | -STR 15 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/LHL4.tml: -------------------------------------------------------------------------------- 1 | === Invalid tag 2 | --- from: @perlpunk 3 | --- tags: error tag 4 | 5 | --- in-yaml(<) 6 | --- 7 | !invalid{}tag scalar 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC --- 14 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/AVM7.tml: -------------------------------------------------------------------------------- 1 | === Empty Stream 2 | --- from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/misc.tml 3 | --- tags: edge 4 | 5 | --- in-yaml 6 | 7 | --- in-json 8 | 9 | --- test-event 10 | +STR 11 | -STR 12 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/B63P.tml: -------------------------------------------------------------------------------- 1 | === Directive without document 2 | --- from: AdaYaml tests 3 | --- tags: error directive document 4 | 5 | --- in-yaml(<) 6 | %YAML 1.2 7 | ... 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | -------------------------------------------------------------------------------- /core/shared/src/main/scala/org/virtuslab/yaml/internal/dump/present/Presenter.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml.internal.dump.present 2 | 3 | import org.virtuslab.yaml.internal.load.parse.EventKind 4 | 5 | trait Presenter { 6 | def asString(events: Seq[EventKind]): String 7 | } 8 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/2CMS.tml: -------------------------------------------------------------------------------- 1 | === Invalid mapping in plain multiline 2 | --- from: @perlpunk 3 | --- tags: error mapping 4 | 5 | --- in-yaml 6 | this 7 | is 8 | invalid: x 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/55WF.tml: -------------------------------------------------------------------------------- 1 | === Invalid escape in double quoted string 2 | --- from: @perlpunk 3 | --- tags: error double 4 | 5 | --- in-yaml(<) 6 | --- 7 | "\." 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC --- 14 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/SF5V.tml: -------------------------------------------------------------------------------- 1 | === Duplicate YAML directive 2 | --- from: @perlpunk 3 | --- tags: directive error 4 | 5 | --- in-yaml(<) 6 | %YAML 1.2 7 | %YAML 1.2 8 | --- 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/SY6V.tml: -------------------------------------------------------------------------------- 1 | === Anchor before sequence entry on same line 2 | --- from: @perlpunk 3 | --- tags: anchor error sequence 4 | 5 | --- in-yaml 6 | &anchor - sequence entry 7 | 8 | --- error 9 | 10 | --- test-event 11 | +STR 12 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/C2SP.tml: -------------------------------------------------------------------------------- 1 | === Flow Mapping Key on two lines 2 | --- from: @perlpunk 3 | --- tags: error flow mapping 4 | 5 | --- in-yaml 6 | [23 7 | ]: 42 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC 14 | +SEQ 15 | =VAL :23 16 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/8MK2.tml: -------------------------------------------------------------------------------- 1 | === Explicit Non-Specific Tag 2 | --- from: NimYAML tests 3 | --- tags: tag 1.3-err 4 | 5 | --- in-yaml 6 | ! a 7 | 8 | --- in-json 9 | "a" 10 | 11 | --- test-event 12 | +STR 13 | +DOC 14 | =VAL :a 15 | -DOC 16 | -STR 17 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/EW3V.tml: -------------------------------------------------------------------------------- 1 | === Wrong indendation in mapping 2 | --- from: @perlpunk 3 | --- tags: error mapping indent 4 | 5 | --- in-yaml 6 | k1: v1 7 | k2: v2 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC 14 | +MAP 15 | =VAL :k1 16 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/CXX2.tml: -------------------------------------------------------------------------------- 1 | === Mapping with anchor on document start line 2 | --- from: @perlpunk 3 | --- tags: anchor error header mapping 4 | 5 | --- in-yaml(<) 6 | --- &anchor a: b 7 | 8 | --- error 9 | 10 | --- test-event 11 | +STR 12 | +DOC --- 13 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/G7JE.tml: -------------------------------------------------------------------------------- 1 | === Multiline implicit keys 2 | --- from: @perlpunk 3 | --- tags: error mapping 4 | 5 | --- in-yaml 6 | a\nb: 1 7 | c 8 | d: 1 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL :a\\nb 17 | =VAL :1 18 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/GT5M.tml: -------------------------------------------------------------------------------- 1 | === Node anchor in sequence 2 | --- from: @perlpunk 3 | --- tags: anchor error sequence 4 | 5 | --- in-yaml 6 | - item1 7 | &node 8 | - item2 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +SEQ 16 | =VAL :item1 17 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/QT73.tml: -------------------------------------------------------------------------------- 1 | === Comment and document-end marker 2 | --- from: @perlpunk 3 | --- tags: comment footer 4 | 5 | --- in-yaml(<) 6 | # comment 7 | ... 8 | 9 | --- out-yaml(<) 10 | 11 | --- in-json 12 | 13 | --- test-event 14 | +STR 15 | -STR 16 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/ZL4Z.tml: -------------------------------------------------------------------------------- 1 | === Invalid nested mapping 2 | --- from: @perlpunk 3 | --- tags: error mapping 4 | 5 | --- in-yaml(<) 6 | --- 7 | a: 'b': c 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC --- 14 | +MAP 15 | =VAL :a 16 | =VAL 'b 17 | -------------------------------------------------------------------------------- /core/shared/src/main/scala/org/virtuslab/yaml/internal/load/parse/Parser.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml.internal.load.parse 2 | 3 | import org.virtuslab.yaml.YamlError 4 | import org.virtuslab.yaml.internal.load.reader.Tokenizer 5 | 6 | trait Parser { 7 | def getNextEvent(): Either[YamlError, Event] 8 | } 9 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/236B.tml: -------------------------------------------------------------------------------- 1 | === Invalid value after mapping 2 | --- from: @perlpunk 3 | --- tags: error mapping 4 | 5 | --- in-yaml 6 | foo: 7 | bar 8 | invalid 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL :foo 17 | =VAL :bar 18 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/5U3A.tml: -------------------------------------------------------------------------------- 1 | === Sequence on same Line as Mapping Key 2 | --- from: @perlpunk 3 | --- tags: error sequence mapping 4 | 5 | --- in-yaml 6 | key: - a 7 | - b 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC 14 | +MAP 15 | =VAL :key 16 | -------------------------------------------------------------------------------- /core/shared/src/main/scala/org/virtuslab/yaml/internal/dump/serialize/Serializer.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml.internal.dump.serialize 2 | 3 | import org.virtuslab.yaml.Node 4 | import org.virtuslab.yaml.internal.load.parse.EventKind 5 | 6 | trait Serializer { 7 | def toEvents(node: Node): Seq[EventKind] 8 | } 9 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/5TRB.tml: -------------------------------------------------------------------------------- 1 | === Invalid document-start marker in doublequoted tring 2 | --- from: @perlpunk 3 | --- tags: header double error 4 | 5 | --- in-yaml(<) 6 | --- 7 | " 8 | --- 9 | " 10 | 11 | --- error 12 | 13 | --- test-event 14 | +STR 15 | +DOC --- 16 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/7LBH.tml: -------------------------------------------------------------------------------- 1 | === Multiline double quoted implicit keys 2 | --- from: @perlpunk 3 | --- tags: error double 4 | 5 | --- in-yaml 6 | "a\nb": 1 7 | "c 8 | d": 1 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL "a\nb 17 | =VAL :1 18 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9MAG.tml: -------------------------------------------------------------------------------- 1 | === Flow sequence with invalid comma at the beginning 2 | --- from: @perlpunk 3 | --- tags: error flow sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | [ , a, b, c ] 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC --- 14 | +SEQ 15 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/RXY3.tml: -------------------------------------------------------------------------------- 1 | === Invalid document-end marker in single quoted string 2 | --- from: @perlpunk 3 | --- tags: footer single error 4 | 5 | --- in-yaml(<) 6 | --- 7 | ' 8 | ... 9 | ' 10 | 11 | --- error 12 | 13 | --- test-event 14 | +STR 15 | +DOC --- 16 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/D49Q.tml: -------------------------------------------------------------------------------- 1 | === Multiline single quoted implicit keys 2 | --- from: @perlpunk 3 | --- tags: error single mapping 4 | 5 | --- in-yaml 6 | 'a\nb': 1 7 | 'c 8 | d': 1 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL 'a\\nb 17 | =VAL :1 18 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/N782.tml: -------------------------------------------------------------------------------- 1 | === Invalid document markers in flow style 2 | --- from: NimYAML tests 3 | --- tags: flow edge header footer error 4 | 5 | --- in-yaml(<) 6 | [ 7 | --- , 8 | ... 9 | ] 10 | 11 | --- error 12 | 13 | --- test-event 14 | +STR 15 | +DOC 16 | +SEQ 17 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/TD5N.tml: -------------------------------------------------------------------------------- 1 | === Invalid scalar after sequence 2 | --- from: @perlpunk 3 | --- tags: error sequence scalar 4 | 5 | --- in-yaml 6 | - item1 7 | - item2 8 | invalid 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +SEQ 16 | =VAL :item1 17 | =VAL :item2 18 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/BD7L.tml: -------------------------------------------------------------------------------- 1 | === Invalid mapping after sequence 2 | --- from: @perlpunk 3 | --- tags: error mapping sequence 4 | 5 | --- in-yaml 6 | - item1 7 | - item2 8 | invalid: x 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +SEQ 16 | =VAL :item1 17 | =VAL :item2 18 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/CQ3W.tml: -------------------------------------------------------------------------------- 1 | === Double quoted string without closing quote 2 | --- from: @perlpunk 3 | --- tags: error double 4 | 5 | --- in-yaml(<) 6 | --- 7 | key: "missing closing quote 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC --- 14 | +MAP 15 | =VAL :key 16 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/DK4H.tml: -------------------------------------------------------------------------------- 1 | === Implicit key followed by newline 2 | --- from: @perlpunk 3 | --- tags: error flow mapping sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | [ key 8 | : value ] 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC --- 15 | +SEQ 16 | =VAL :key 17 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/7MNF.tml: -------------------------------------------------------------------------------- 1 | === Missing colon 2 | --- from: @perlpunk 3 | --- tags: error mapping 4 | 5 | --- in-yaml 6 | top1: 7 | key1: val1 8 | top2 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL :top1 17 | +MAP 18 | =VAL :key1 19 | =VAL :val1 20 | -MAP 21 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/GDY7.tml: -------------------------------------------------------------------------------- 1 | === Comment that looks like a mapping key 2 | --- from: @perlpunk 3 | --- tags: comment error mapping 4 | 5 | --- in-yaml 6 | key: value 7 | this is #not a: key 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC 14 | +MAP 15 | =VAL :key 16 | =VAL :value 17 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/NHX8.tml: -------------------------------------------------------------------------------- 1 | === Empty Lines at End of Document 2 | --- from: NimYAML tests 3 | --- tags: empty-key whitespace 4 | 5 | --- in-yaml(+) 6 | : 7 | 8 | 9 | --- emit-yaml 10 | : 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL : 17 | =VAL : 18 | -MAP 19 | -DOC 20 | -STR 21 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/ZVH3.tml: -------------------------------------------------------------------------------- 1 | === Wrong indented sequence item 2 | --- from: @perlpunk 3 | --- tags: error sequence indent 4 | 5 | --- in-yaml 6 | - key: value 7 | - item1 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC 14 | +SEQ 15 | +MAP 16 | =VAL :key 17 | =VAL :value 18 | -MAP 19 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/ZXT5.tml: -------------------------------------------------------------------------------- 1 | === Implicit key followed by newline and adjacent value 2 | --- from: @perlpunk 3 | --- tags: error flow mapping sequence 4 | 5 | --- in-yaml(<) 6 | [ "key" 7 | :value ] 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC 14 | +SEQ 15 | =VAL "key 16 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/4UYU.tml: -------------------------------------------------------------------------------- 1 | === Colon in Double Quoted String 2 | --- from: NimYAML tests 3 | --- tags: mapping scalar 1.3-err 4 | 5 | --- in-yaml 6 | "foo: bar\": baz" 7 | 8 | --- in-json 9 | "foo: bar\": baz" 10 | 11 | --- test-event 12 | +STR 13 | +DOC 14 | =VAL "foo: bar": baz 15 | -DOC 16 | -STR 17 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/98YD.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 5.5. Comment Indicator 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2773032 3 | --- tags: spec comment empty 4 | 5 | --- in-yaml(<) 6 | # Comment only. 7 | 8 | --- in-json 9 | 10 | --- out-yaml 11 | 12 | --- test-event 13 | +STR 14 | -STR 15 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/CTN5.tml: -------------------------------------------------------------------------------- 1 | === Flow sequence with invalid extra comma 2 | --- from: @perlpunk 3 | --- tags: error flow sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | [ a, b, c, , ] 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC --- 14 | +SEQ 15 | =VAL :a 16 | =VAL :b 17 | =VAL :c 18 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/QB6E.tml: -------------------------------------------------------------------------------- 1 | === Wrong indented multiline quoted scalar 2 | --- from: @perlpunk 3 | --- tags: double error indent 4 | 5 | --- in-yaml(<) 6 | --- 7 | quoted: "a 8 | b 9 | c" 10 | 11 | --- error 12 | 13 | --- test-event 14 | +STR 15 | +DOC --- 16 | +MAP 17 | =VAL :quoted 18 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/T833.tml: -------------------------------------------------------------------------------- 1 | === Flow mapping missing a separating comma 2 | --- from: @perlpunk 3 | --- tags: error flow mapping 4 | 5 | --- in-yaml(<) 6 | --- 7 | { 8 | foo: 1 9 | bar: 2 } 10 | 11 | --- error 12 | 13 | --- test-event 14 | +STR 15 | +DOC --- 16 | +MAP 17 | =VAL :foo 18 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/X4QW.tml: -------------------------------------------------------------------------------- 1 | === Comment without whitespace after block scalar indicator 2 | --- from: @perlpunk 3 | --- tags: folded comment error whitespace 4 | 5 | --- in-yaml 6 | block: ># comment 7 | scalar 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC 14 | +MAP 15 | =VAL :block 16 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/2JQS.tml: -------------------------------------------------------------------------------- 1 | === Block Mapping with Missing Keys 2 | --- from: NimYAML tests 3 | --- tags: duplicate-key mapping empty-key 4 | 5 | --- in-yaml 6 | : a 7 | : b 8 | 9 | --- test-event 10 | +STR 11 | +DOC 12 | +MAP 13 | =VAL : 14 | =VAL :a 15 | =VAL : 16 | =VAL :b 17 | -MAP 18 | -DOC 19 | -STR 20 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/DMG6.tml: -------------------------------------------------------------------------------- 1 | === Wrong indendation in Map 2 | --- from: @perlpunk 3 | --- tags: error mapping indent 4 | 5 | --- in-yaml 6 | key: 7 | ok: 1 8 | wrong: 2 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL :key 17 | +MAP 18 | =VAL :ok 19 | =VAL :1 20 | -MAP 21 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/Q5MG.tml: -------------------------------------------------------------------------------- 1 | === Tab at beginning of line followed by a flow mapping 2 | --- from: IRC 3 | --- tags: flow whitespace 4 | 5 | --- in-yaml 6 | {} 7 | 8 | --- in-json 9 | {} 10 | 11 | --- out-yaml 12 | {} 13 | 14 | --- test-event 15 | +STR 16 | +DOC 17 | +MAP 18 | -MAP 19 | -DOC 20 | -STR 21 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/S4GJ.tml: -------------------------------------------------------------------------------- 1 | === Invalid text after block scalar indicator 2 | --- from: @perlpunk 3 | --- tags: error folded 4 | 5 | --- in-yaml(<) 6 | --- 7 | folded: > first line 8 | second line 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC --- 15 | +MAP 16 | =VAL :folded 17 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/SU5Z.tml: -------------------------------------------------------------------------------- 1 | === Comment without whitespace after doublequoted scalar 2 | --- from: @perlpunk 3 | --- tags: comment error double whitespace 4 | 5 | --- in-yaml 6 | key: "value"# invalid comment 7 | 8 | --- error 9 | 10 | --- test-event 11 | +STR 12 | +DOC 13 | +MAP 14 | =VAL :key 15 | =VAL "value 16 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/SU74.tml: -------------------------------------------------------------------------------- 1 | === Anchor and alias as mapping key 2 | --- from: @perlpunk 3 | --- tags: error anchor alias mapping 4 | 5 | --- in-yaml 6 | key1: &alias value1 7 | &b *alias : value2 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC 14 | +MAP 15 | =VAL :key1 16 | =VAL &alias :value1 17 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/CVW2.tml: -------------------------------------------------------------------------------- 1 | === Invalid comment after comma 2 | --- from: @perlpunk 3 | --- tags: comment error flow sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | [ a, b, c,#invalid 8 | ] 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC --- 15 | +SEQ 16 | =VAL :a 17 | =VAL :b 18 | =VAL :c 19 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9C9N.tml: -------------------------------------------------------------------------------- 1 | === Wrong indented flow sequence 2 | --- from: @perlpunk 3 | --- tags: error flow indent sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | flow: [a, 8 | b, 9 | c] 10 | 11 | --- error 12 | 13 | --- test-event 14 | +STR 15 | +DOC --- 16 | +MAP 17 | =VAL :flow 18 | +SEQ 19 | =VAL :a 20 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/G9HC.tml: -------------------------------------------------------------------------------- 1 | === Invalid anchor in zero indented sequence 2 | --- from: @perlpunk 3 | --- tags: anchor error sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | seq: 8 | &anchor 9 | - a 10 | - b 11 | 12 | 13 | --- error 14 | 15 | --- test-event 16 | +STR 17 | +DOC --- 18 | +MAP 19 | =VAL :seq 20 | -------------------------------------------------------------------------------- /integration-tests/src/test/scala/org/virtuslab/yaml/OfficialTestSuiteSpec.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml 2 | 3 | class OfficialTestSuiteSpec extends YamlRunnerSpec { 4 | 5 | override def resourcePath: String = "/yaml/test-suite" 6 | override def createTestRunner(yamlPath: os.Path): TestRunner = YamlSuiteTestRunner(yamlPath) 7 | } 8 | -------------------------------------------------------------------------------- /core/shared/src/main/scala/org/virtuslab/yaml/syntax/YamlPrimitive.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml.syntax 2 | 3 | import scala.language.implicitConversions 4 | 5 | import org.virtuslab.yaml.Node 6 | import org.virtuslab.yaml.Node.ScalarNode 7 | 8 | final case class YamlPrimitive(node: Node) 9 | object YamlPrimitive extends YamlPrimitiveCompanionCrossCompat 10 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6JTT.tml: -------------------------------------------------------------------------------- 1 | === Flow sequence without closing bracket 2 | --- from: @perlpunk 3 | --- tags: error flow sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | [ [ a, b, c ] 8 | 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC --- 15 | +SEQ 16 | +SEQ 17 | =VAL :a 18 | =VAL :b 19 | =VAL :c 20 | -SEQ 21 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6S55.tml: -------------------------------------------------------------------------------- 1 | === Invalid scalar at the end of sequence 2 | --- from: @perlpunk 3 | --- tags: error mapping sequence 4 | 5 | --- in-yaml 6 | key: 7 | - bar 8 | - baz 9 | invalid 10 | 11 | --- error 12 | 13 | --- test-event 14 | +STR 15 | +DOC 16 | +MAP 17 | =VAL :key 18 | +SEQ 19 | =VAL :bar 20 | =VAL :baz 21 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/RHX7.tml: -------------------------------------------------------------------------------- 1 | === YAML directive without document end marker 2 | --- from: @perlpunk 3 | --- tags: directive error 4 | 5 | --- in-yaml(<) 6 | --- 7 | key: value 8 | %YAML 1.2 9 | --- 10 | 11 | --- error 12 | 13 | --- test-event 14 | +STR 15 | +DOC --- 16 | +MAP 17 | =VAL :key 18 | =VAL :value 19 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/ZCZ6.tml: -------------------------------------------------------------------------------- 1 | === Invalid mapping in plain single line value 2 | --- from: https://gist.github.com/anonymous/0c8db51d151baf8113205ba3ce71d1b4 via @ingydotnet 3 | --- tags: error mapping scalar 4 | 5 | --- in-yaml 6 | a: b: c: d 7 | 8 | --- error 9 | 10 | --- test-event 11 | +STR 12 | +DOC 13 | +MAP 14 | =VAL :a 15 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/3HFZ.tml: -------------------------------------------------------------------------------- 1 | === Invalid content after document end marker 2 | --- from: @perlpunk 3 | --- tags: error footer 4 | 5 | --- in-yaml(<) 6 | --- 7 | key: value 8 | ... invalid 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC --- 15 | +MAP 16 | =VAL :key 17 | =VAL :value 18 | -MAP 19 | -DOC ... 20 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/4H7K.tml: -------------------------------------------------------------------------------- 1 | === Flow sequence with invalid extra closing bracket 2 | --- from: @perlpunk 3 | --- tags: error flow sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | [ a, b, c ] ] 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC --- 14 | +SEQ 15 | =VAL :a 16 | =VAL :b 17 | =VAL :c 18 | -SEQ 19 | -DOC 20 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/8G76.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.10. Comment Lines 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2780544 3 | --- tags: spec comment empty scalar whitespace 4 | 5 | --- in-yaml(+) 6 | # Comment 7 | 8 | 9 | 10 | --- in-json 11 | 12 | --- out-yaml 13 | 14 | --- test-event 15 | +STR 16 | -STR 17 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9HCY.tml: -------------------------------------------------------------------------------- 1 | === Need document footer before directives 2 | --- from: @ingydotnet 3 | --- tags: directive error footer tag unknown-tag 4 | --- error 5 | --- in-yaml(<) 6 | !foo "bar" 7 | %TAG ! tag:example.com,2000:app/ 8 | --- 9 | !foo "bar" 10 | --- test-event 11 | +STR 12 | +DOC 13 | =VAL "bar 14 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9JBA.tml: -------------------------------------------------------------------------------- 1 | === Invalid comment after end of flow sequence 2 | --- from: @perlpunk 3 | --- tags: comment error flow sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | [ a, b, c, ]#invalid 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC --- 14 | +SEQ 15 | =VAL :a 16 | =VAL :b 17 | =VAL :c 18 | -SEQ 19 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9KBC.tml: -------------------------------------------------------------------------------- 1 | === Mapping starting at --- line 2 | --- from: https://gist.github.com/anonymous/c728390e92ec93fb371ac77f21435cca via @ingydotnet 3 | --- tags: error header mapping 4 | 5 | --- in-yaml(<) 6 | --- key1: value1 7 | key2: value2 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC --- 14 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/BS4K.tml: -------------------------------------------------------------------------------- 1 | === Comment between plain scalar lines 2 | --- from: https://gist.github.com/anonymous/269f16d582fdd30a7dcf8c9249c5da7f via @ingydotnet 3 | --- tags: error scalar 4 | 5 | --- in-yaml 6 | word1 # comment 7 | word2 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC 14 | =VAL :word1 15 | -DOC 16 | -------------------------------------------------------------------------------- /core/shared/src/test/scala/org/virtuslab/yaml/TestOps.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml 2 | 3 | object TestOps { 4 | 5 | implicit class EitherOps[E <: YamlError, T](val either: Either[E, T]) { 6 | def orThrow: T = 7 | either match { 8 | case Left(e) => throw new RuntimeException(e.msg) 9 | case Right(t) => t 10 | } 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/4HVU.tml: -------------------------------------------------------------------------------- 1 | === Wrong indendation in Sequence 2 | --- from: @perlpunk 3 | --- tags: error sequence indent 4 | 5 | --- in-yaml 6 | key: 7 | - ok 8 | - also ok 9 | - wrong 10 | 11 | --- error 12 | 13 | --- test-event 14 | +STR 15 | +DOC 16 | +MAP 17 | =VAL :key 18 | +SEQ 19 | =VAL :ok 20 | =VAL :also ok 21 | -SEQ 22 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/52DL.tml: -------------------------------------------------------------------------------- 1 | === Explicit Non-Specific Tag [1.3] 2 | --- from: 8MK2, modified for YAML 1.3 3 | --- tags: tag 1.3-mod 4 | 5 | --- in-yaml(<) 6 | --- 7 | ! a 8 | 9 | --- in-json 10 | "a" 11 | 12 | --- out-yaml(<) 13 | --- ! a 14 | 15 | --- test-event 16 | +STR 17 | +DOC --- 18 | =VAL :a 19 | -DOC 20 | -STR 21 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/HRE5.tml: -------------------------------------------------------------------------------- 1 | === Double quoted scalar with escaped single quote 2 | --- from: https://github.com/yaml/libyaml/issues/68 3 | --- tags: double error single 4 | 5 | --- in-yaml(<) 6 | --- 7 | double: "quoted \' scalar" 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC --- 14 | +MAP 15 | =VAL :double 16 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/P2EQ.tml: -------------------------------------------------------------------------------- 1 | === Invalid sequene item on same line as previous item 2 | --- from: @perlpunk 3 | --- tags: error flow mapping sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | - { y: z }- invalid 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC --- 14 | +SEQ 15 | +MAP 16 | =VAL :y 17 | =VAL :z 18 | -MAP 19 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/SR86.tml: -------------------------------------------------------------------------------- 1 | === Anchor plus Alias 2 | --- from: @perlpunk 3 | --- tags: alias error 4 | 5 | Showing that an alias cannot have an anchor. 6 | 7 | --- in-yaml 8 | key1: &a value 9 | key2: &b *a 10 | 11 | --- error 12 | 13 | --- test-event 14 | +STR 15 | +DOC 16 | +MAP 17 | =VAL :key1 18 | =VAL &a :value 19 | =VAL :key2 20 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9CWY.tml: -------------------------------------------------------------------------------- 1 | === Invalid scalar at the end of mapping 2 | --- from: @perlpunk 3 | --- tags: error mapping sequence 4 | 5 | --- in-yaml 6 | key: 7 | - item1 8 | - item2 9 | invalid 10 | 11 | --- error 12 | 13 | --- test-event 14 | +STR 15 | +DOC 16 | +MAP 17 | =VAL :key 18 | +SEQ 19 | =VAL :item1 20 | =VAL :item2 21 | -SEQ 22 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/K54U.tml: -------------------------------------------------------------------------------- 1 | === Tab after document header 2 | --- from: @perlpunk 3 | --- tags: header whitespace 4 | 5 | --- in-yaml(<) 6 | ---scalar 7 | 8 | --- in-json 9 | "scalar" 10 | 11 | --- out-yaml(<) 12 | --- scalar 13 | ... 14 | 15 | --- test-event 16 | +STR 17 | +DOC --- 18 | =VAL :scalar 19 | -DOC 20 | -STR 21 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/KS4U.tml: -------------------------------------------------------------------------------- 1 | === Invalid item after end of flow sequence 2 | --- from: @perlpunk 3 | --- tags: error flow sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | [ 8 | sequence item 9 | ] 10 | invalid item 11 | 12 | --- error 13 | 14 | --- test-event 15 | +STR 16 | +DOC --- 17 | +SEQ 18 | =VAL :sequence item 19 | -SEQ 20 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/5LLU.tml: -------------------------------------------------------------------------------- 1 | === Block scalar with wrong indented line after spaces only 2 | --- from: @perlpunk 3 | --- tags: error folded whitespace 4 | 5 | --- in-yaml 6 | block scalar: > 7 | 8 | 9 | 10 | invalid 11 | 12 | --- error 13 | 14 | --- test-event 15 | +STR 16 | +DOC 17 | +MAP 18 | =VAL :block scalar 19 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/62EZ.tml: -------------------------------------------------------------------------------- 1 | === Invalid block mapping key on same line as previous key 2 | --- from: @perlpunk 3 | --- tags: error flow mapping 4 | 5 | --- in-yaml(<) 6 | --- 7 | x: { y: z }in: valid 8 | 9 | --- error 10 | 11 | --- test-event 12 | +STR 13 | +DOC --- 14 | +MAP 15 | =VAL :x 16 | +MAP 17 | =VAL :y 18 | =VAL :z 19 | -MAP 20 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/65WH.tml: -------------------------------------------------------------------------------- 1 | === Single Entry Block Sequence 2 | --- from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/sequence.tml 3 | --- tags: sequence 4 | 5 | --- in-yaml 6 | - foo 7 | 8 | --- in-json 9 | [ 10 | "foo" 11 | ] 12 | 13 | --- test-event 14 | +STR 15 | +DOC 16 | +SEQ 17 | =VAL :foo 18 | -SEQ 19 | -DOC 20 | -STR 21 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/EB22.tml: -------------------------------------------------------------------------------- 1 | === Missing document-end marker before directive 2 | --- from: @perlpunk 3 | --- tags: error directive footer 4 | 5 | --- in-yaml(<) 6 | --- 7 | scalar1 # comment 8 | %YAML 1.2 9 | --- 10 | scalar2 11 | 12 | --- error 13 | 14 | --- test-event 15 | +STR 16 | +DOC --- 17 | =VAL :scalar1 18 | -DOC 19 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/HU3P.tml: -------------------------------------------------------------------------------- 1 | === Invalid Mapping in plain scalar 2 | --- from: https://gist.github.com/anonymous/d305fd8e54cfe7a484088c91a8a2e533 via @ingydotnet 3 | --- tags: error mapping scalar 4 | 5 | --- in-yaml 6 | key: 7 | word1 word2 8 | no: key 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL :key 17 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/U44R.tml: -------------------------------------------------------------------------------- 1 | === Bad indentation in mapping (2) 2 | --- from: @perlpunk 3 | --- tags: error mapping indent double 4 | 5 | --- in-yaml 6 | map: 7 | key1: "quoted1" 8 | key2: "bad indentation" 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL :map 17 | +MAP 18 | =VAL :key1 19 | =VAL "quoted1 20 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/4EJS.tml: -------------------------------------------------------------------------------- 1 | === Invalid tabs as indendation in a mapping 2 | --- from: https://github.com/nodeca/js-yaml/issues/80 3 | --- tags: error mapping whitespace 4 | 5 | --- in-yaml(<) 6 | --- 7 | a: 8 | b: 9 | c: value 10 | 11 | --- error 12 | 13 | --- test-event 14 | +STR 15 | +DOC --- 16 | +MAP 17 | =VAL :a 18 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/BF9H.tml: -------------------------------------------------------------------------------- 1 | === Trailing comment in multiline plain scalar 2 | --- from: @perlpunk 3 | --- tags: comment error scalar 4 | 5 | --- in-yaml(<) 6 | --- 7 | plain: a 8 | b # end of scalar 9 | c 10 | 11 | 12 | --- error 13 | 14 | --- test-event 15 | +STR 16 | +DOC --- 17 | +MAP 18 | =VAL :plain 19 | =VAL :a b 20 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/N4JP.tml: -------------------------------------------------------------------------------- 1 | === Bad indentation in mapping 2 | --- from: @perlpunk 3 | --- tags: error mapping indent double 4 | 5 | --- in-yaml 6 | map: 7 | key1: "quoted1" 8 | key2: "bad indentation" 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL :map 17 | +MAP 18 | =VAL :key1 19 | =VAL "quoted1 20 | -MAP 21 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/S7BG.tml: -------------------------------------------------------------------------------- 1 | === Colon followed by comma 2 | --- from: @perlpunk 3 | --- tags: scalar 4 | 5 | --- in-yaml(<) 6 | --- 7 | - :, 8 | 9 | --- out-yaml(<) 10 | --- 11 | - :, 12 | 13 | --- in-json 14 | [ 15 | ":," 16 | ] 17 | 18 | --- test-event 19 | +STR 20 | +DOC --- 21 | +SEQ 22 | =VAL ::, 23 | -SEQ 24 | -DOC 25 | -STR 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/MYW6.tml: -------------------------------------------------------------------------------- 1 | === Block Scalar Strip 2 | --- from: NimYAML tests 3 | --- tags: literal scalar whitespace 1.3-err 4 | 5 | --- in-yaml 6 | |- 7 | ab 8 | 9 | 10 | ... 11 | 12 | --- in-json 13 | "ab" 14 | 15 | --- out-yaml 16 | |- 17 | ab 18 | ... 19 | 20 | --- test-event 21 | +STR 22 | +DOC 23 | =VAL |ab 24 | -DOC ... 25 | -STR 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/3R3P.tml: -------------------------------------------------------------------------------- 1 | === Single block sequence with anchor 2 | --- from: @perlpunk 3 | --- tags: anchor sequence 4 | 5 | --- in-yaml 6 | &sequence 7 | - a 8 | 9 | --- out-yaml 10 | &sequence 11 | - a 12 | 13 | --- in-json 14 | [ 15 | "a" 16 | ] 17 | 18 | --- test-event 19 | +STR 20 | +DOC 21 | +SEQ &sequence 22 | =VAL :a 23 | -SEQ 24 | -DOC 25 | -STR 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/4GC6.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.7. Single Quoted Characters 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2788307 3 | --- tags: spec scalar 1.3-err 4 | 5 | --- in-yaml 6 | 'here''s to "quotes"' 7 | 8 | --- in-json 9 | "here's to \"quotes\"" 10 | 11 | --- test-event 12 | +STR 13 | +DOC 14 | =VAL 'here's to "quotes" 15 | -DOC 16 | -STR 17 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6XDY.tml: -------------------------------------------------------------------------------- 1 | === Two document start markers 2 | --- from: @perlpunk 3 | --- tags: header 4 | 5 | --- in-yaml(<) 6 | --- 7 | --- 8 | 9 | --- out-yaml(<) 10 | --- 11 | --- 12 | 13 | --- in-json 14 | null 15 | null 16 | 17 | --- test-event 18 | +STR 19 | +DOC --- 20 | =VAL : 21 | -DOC 22 | +DOC --- 23 | =VAL : 24 | -DOC 25 | -STR 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/82AN.tml: -------------------------------------------------------------------------------- 1 | === Three dashes and content without space 2 | --- from: @perlpunk 3 | --- tags: scalar 1.3-err 4 | 5 | --- in-yaml(<) 6 | ---word1 7 | word2 8 | 9 | --- in-json 10 | "---word1 word2" 11 | 12 | --- out-yaml 13 | '---word1 word2' 14 | 15 | --- test-event 16 | +STR 17 | +DOC 18 | =VAL :---word1 word2 19 | -DOC 20 | -STR 21 | 22 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/Q4CL.tml: -------------------------------------------------------------------------------- 1 | === Trailing content after quoted value 2 | --- from: @perlpunk 3 | --- tags: error mapping double 4 | 5 | --- in-yaml 6 | key1: "quoted1" 7 | key2: "quoted2" trailing content 8 | key3: "quoted3" 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL :key1 17 | =VAL "quoted1 18 | =VAL :key2 19 | =VAL "quoted2 20 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/LX3P.tml: -------------------------------------------------------------------------------- 1 | === Implicit Flow Mapping Key on one line 2 | --- from: @perlpunk 3 | --- tags: complex-key mapping flow sequence 1.3-err 4 | 5 | --- in-yaml 6 | [flow]: block 7 | 8 | --- out-yaml 9 | ? - flow 10 | : block 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | +SEQ 17 | =VAL :flow 18 | -SEQ 19 | =VAL :block 20 | -MAP 21 | -DOC 22 | -STR 23 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/8XDJ.tml: -------------------------------------------------------------------------------- 1 | === Comment in plain multiline value 2 | --- from: https://gist.github.com/anonymous/deeb1ace28d5bf21fb56d80c13e2dc69 via @ingydotnet 3 | --- tags: error comment scalar 4 | 5 | --- in-yaml(<) 6 | key: word1 7 | # xxx 8 | word2 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL :key 17 | =VAL :word1 18 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/CML9.tml: -------------------------------------------------------------------------------- 1 | === Missing comma in flow 2 | --- from: ihttps://gist.github.com/anonymous/4ba3365607cc14b4f656e391b45bf4f4 via @ingydotnet 3 | --- tags: error flow comment 4 | 5 | --- in-yaml(<) 6 | key: [ word1 7 | # xxx 8 | word2 ] 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL :key 17 | +SEQ 18 | =VAL :word1 19 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/D9TU.tml: -------------------------------------------------------------------------------- 1 | === Single Pair Block Mapping 2 | --- from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml 3 | --- tags: simple mapping 4 | 5 | --- in-yaml 6 | foo: bar 7 | 8 | --- in-json 9 | { 10 | "foo": "bar" 11 | } 12 | 13 | --- test-event 14 | +STR 15 | +DOC 16 | +MAP 17 | =VAL :foo 18 | =VAL :bar 19 | -MAP 20 | -DOC 21 | -STR 22 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/JY7Z.tml: -------------------------------------------------------------------------------- 1 | === Trailing content that looks like a mapping 2 | --- from: @perlpunk 3 | --- tags: error mapping double 4 | 5 | --- in-yaml 6 | key1: "quoted1" 7 | key2: "quoted2" no key: nor value 8 | key3: "quoted3" 9 | 10 | --- error 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL :key1 17 | =VAL "quoted1 18 | =VAL :key2 19 | =VAL "quoted2 20 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/S98Z.tml: -------------------------------------------------------------------------------- 1 | === Block scalar with more spaces than first content line 2 | --- from: @perlpunk 3 | --- tags: error folded comment scalar whitespace 4 | 5 | --- in-yaml 6 | empty block scalar: > 7 | 8 | 9 | 10 | # comment 11 | 12 | --- error 13 | 14 | --- test-event 15 | +STR 16 | +DOC 17 | +MAP 18 | =VAL :empty block scalar 19 | -------------------------------------------------------------------------------- /.scalafix.conf: -------------------------------------------------------------------------------- 1 | rules = [ 2 | DisableSyntax, 3 | OrganizeImports, 4 | NoValInForComprehension, 5 | ] 6 | 7 | DisableSyntax.noFinalize = true 8 | DisableSyntax.noReturns = true 9 | 10 | OrganizeImports.groupedImports = Explode 11 | OrganizeImports.expandRelative = true 12 | OrganizeImports.removeUnused = false 13 | OrganizeImports.groups = [ 14 | "re:javax?\\." 15 | "scala." 16 | "org.virtuslab." 17 | ] 18 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/S4T7.tml: -------------------------------------------------------------------------------- 1 | === Document with footer 2 | --- from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/footer.tml 3 | --- tags: mapping footer 4 | 5 | --- in-yaml 6 | aaa: bbb 7 | ... 8 | 9 | --- in-json 10 | { 11 | "aaa": "bbb" 12 | } 13 | 14 | --- test-event 15 | +STR 16 | +DOC 17 | +MAP 18 | =VAL :aaa 19 | =VAL :bbb 20 | -MAP 21 | -DOC ... 22 | -STR 23 | -------------------------------------------------------------------------------- /integration-tests/src/test/scala/org/virtuslab/yaml/K8sConfigSpec.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml 2 | 3 | class K8sConfigSpec extends YamlRunnerSpec { 4 | 5 | val libYamlPath = os.Path(System.getenv("LIB_YAML_PATH")) 6 | 7 | override def resourcePath: String = "/yaml/configs" 8 | def createTestRunner(yamlPath: os.Path): TestRunner = K8sYamlTestRunner(yamlPath, libYamlPath) 9 | 10 | } 11 | -------------------------------------------------------------------------------- /core/shared/src/main/scala-3/org/virtuslab/yaml/derivers.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml 2 | 3 | import scala.deriving.Mirror 4 | 5 | inline def deriveYamlEncoder[T](using m: Mirror.Of[T]): YamlEncoder[T] = YamlEncoder.derived[T] 6 | inline def deriveYamlDecoder[T](using m: Mirror.Of[T]): YamlDecoder[T] = YamlDecoder.derived[T] 7 | inline def deriveYamlCodec[T](using m: Mirror.Of[T]): YamlCodec[T] = YamlCodec.derived[T] 8 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/27NA.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 5.9. Directive Indicator 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2774058 3 | --- tags: spec directive 1.3-err 4 | 5 | --- in-yaml(<) 6 | %YAML 1.2 7 | --- text 8 | 9 | --- in-json 10 | "text" 11 | 12 | --- out-yaml(<) 13 | --- text 14 | 15 | --- test-event 16 | +STR 17 | +DOC --- 18 | =VAL :text 19 | -DOC 20 | -STR 21 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/3UYS.tml: -------------------------------------------------------------------------------- 1 | === Escaped slash in double quotes 2 | --- from: @perlpunk 3 | --- tags: double 4 | 5 | --- in-yaml 6 | escaped slash: "a\/b" 7 | 8 | --- in-json 9 | { 10 | "escaped slash": "a/b" 11 | } 12 | 13 | --- out-yaml 14 | escaped slash: "a/b" 15 | 16 | --- test-event 17 | +STR 18 | +DOC 19 | +MAP 20 | =VAL :escaped slash 21 | =VAL "a/b 22 | -MAP 23 | -DOC 24 | -STR 25 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6H3V.tml: -------------------------------------------------------------------------------- 1 | === Backslashes in singlequotes 2 | --- from: @perlpunk 3 | --- tags: scalar single 4 | 5 | --- in-yaml 6 | 'foo: bar\': baz' 7 | 8 | --- in-json 9 | { 10 | "foo: bar\\": "baz'" 11 | } 12 | 13 | --- out-yaml 14 | 'foo: bar\': baz' 15 | 16 | --- test-event 17 | +STR 18 | +DOC 19 | +MAP 20 | =VAL 'foo: bar\\ 21 | =VAL :baz' 22 | -MAP 23 | -DOC 24 | -STR 25 | 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/MXS3.tml: -------------------------------------------------------------------------------- 1 | === Flow Mapping in Block Sequence 2 | --- from: NimYAML tests 3 | --- tags: mapping sequence flow 4 | 5 | --- in-yaml 6 | - {a: b} 7 | 8 | --- in-json 9 | [ 10 | { 11 | "a": "b" 12 | } 13 | ] 14 | 15 | --- out-yaml 16 | - a: b 17 | 18 | --- test-event 19 | +STR 20 | +DOC 21 | +SEQ 22 | +MAP 23 | =VAL :a 24 | =VAL :b 25 | -MAP 26 | -SEQ 27 | -DOC 28 | -STR 29 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/G992.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.9. Folded Scalar 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2796371 3 | --- tags: spec folded scalar 1.3-err 4 | 5 | --- in-yaml(+) 6 | > 7 | folded 8 | text 9 | 10 | 11 | --- in-json 12 | "folded text\n" 13 | 14 | --- out-yaml 15 | > 16 | folded text 17 | 18 | --- test-event 19 | +STR 20 | +DOC 21 | =VAL >folded text\n 22 | -DOC 23 | -STR 24 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/W9L4.tml: -------------------------------------------------------------------------------- 1 | === Literal block scalar with more spaces in first line 2 | --- from: @perlpunk 3 | --- tags: error literal whitespace 4 | 5 | --- in-yaml(<) 6 | --- 7 | block scalar: | 8 | 9 | more spaces at the beginning 10 | are invalid 11 | 12 | --- error 13 | 14 | --- test-event 15 | +STR 16 | +DOC --- 17 | +MAP 18 | =VAL :block scalar 19 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/FP8R.tml: -------------------------------------------------------------------------------- 1 | === Zero indented block scalar 2 | --- from: @perlpunk 3 | --- tags: folded indent scalar 4 | 5 | --- in-yaml(<) 6 | --- > 7 | line1 8 | line2 9 | line3 10 | 11 | --- in-json 12 | "line1 line2 line3\n" 13 | 14 | --- out-yaml(<) 15 | --- > 16 | line1 line2 line3 17 | 18 | --- test-event 19 | +STR 20 | +DOC --- 21 | =VAL >line1 line2 line3\n 22 | -DOC 23 | -STR 24 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/XLQ9.tml: -------------------------------------------------------------------------------- 1 | === Multiline scalar that looks like a YAML directive 2 | --- from: @perlpunk 3 | --- tags: directive scalar 4 | 5 | --- in-yaml(<) 6 | --- 7 | scalar 8 | %YAML 1.2 9 | 10 | --- in-json 11 | "scalar %YAML 1.2" 12 | 13 | --- out-yaml(<) 14 | --- scalar %YAML 1.2 15 | ... 16 | 17 | --- test-event 18 | +STR 19 | +DOC --- 20 | =VAL :scalar %YAML 1.2 21 | -DOC 22 | -STR 23 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/4V8U.tml: -------------------------------------------------------------------------------- 1 | === Plain scalar with backslashes 2 | --- from: @perlpunk 3 | --- tags: scalar 4 | 5 | --- in-yaml(<) 6 | --- 7 | plain\value\with\backslashes 8 | 9 | --- in-json 10 | "plain\\value\\with\\backslashes" 11 | 12 | --- out-yaml(<) 13 | --- plain\value\with\backslashes 14 | 15 | --- test-event 16 | +STR 17 | +DOC --- 18 | =VAL :plain\\value\\with\\backslashes 19 | -DOC 20 | -STR 21 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/TS54.tml: -------------------------------------------------------------------------------- 1 | === Folded Block Scalar 2 | --- from: NimYAML tests 3 | --- tags: folded scalar 1.3-err 4 | 5 | --- in-yaml 6 | > 7 | ab 8 | cd 9 | 10 | ef 11 | 12 | 13 | gh 14 | 15 | --- in-json 16 | "ab cd\nef\n\ngh\n" 17 | 18 | --- out-yaml 19 | > 20 | ab cd 21 | 22 | ef 23 | 24 | 25 | gh 26 | 27 | --- test-event 28 | +STR 29 | +DOC 30 | =VAL >ab cd\nef\n\ngh\n 31 | -DOC 32 | -STR 33 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/3ALJ.tml: -------------------------------------------------------------------------------- 1 | === Block Sequence in Block Sequence 2 | --- from: NimYAML tests 3 | --- tags: sequence 4 | 5 | --- in-yaml 6 | - - s1_i1 7 | - s1_i2 8 | - s2 9 | 10 | --- in-json 11 | [ 12 | [ 13 | "s1_i1", 14 | "s1_i2" 15 | ], 16 | "s2" 17 | ] 18 | 19 | --- test-event 20 | +STR 21 | +DOC 22 | +SEQ 23 | +SEQ 24 | =VAL :s1_i1 25 | =VAL :s1_i2 26 | -SEQ 27 | =VAL :s2 28 | -SEQ 29 | -DOC 30 | -STR 31 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/753E.tml: -------------------------------------------------------------------------------- 1 | === Block Scalar Strip [1.3] 2 | --- from: MYW6, modified for YAML 1.3 3 | --- tags: literal scalar 1.3-mod whitespace 4 | 5 | --- in-yaml(<) 6 | --- |- 7 | ab 8 | 9 | 10 | ... 11 | 12 | --- in-json 13 | "ab" 14 | 15 | --- out-yaml(<) 16 | --- |- 17 | ab 18 | ... 19 | 20 | --- test-event 21 | +STR 22 | +DOC --- 23 | =VAL |ab 24 | -DOC ... 25 | -STR 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/K4SU.tml: -------------------------------------------------------------------------------- 1 | === Multiple Entry Block Sequence 2 | --- from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/sequence.tml 3 | --- tags: sequence 4 | 5 | --- in-yaml 6 | - foo 7 | - bar 8 | - 42 9 | 10 | --- in-json 11 | [ 12 | "foo", 13 | "bar", 14 | 42 15 | ] 16 | 17 | --- test-event 18 | +STR 19 | +DOC 20 | +SEQ 21 | =VAL :foo 22 | =VAL :bar 23 | =VAL :42 24 | -SEQ 25 | -DOC 26 | -STR 27 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/Y2GN.tml: -------------------------------------------------------------------------------- 1 | === Anchor with colon in the middle 2 | --- from: @perlpunk 3 | --- tags: anchor 4 | 5 | --- in-yaml(<) 6 | --- 7 | key: &an:chor value 8 | 9 | --- out-yaml(<) 10 | --- 11 | key: &an:chor value 12 | 13 | --- in-json 14 | { 15 | "key": "value" 16 | } 17 | 18 | --- test-event 19 | +STR 20 | +DOC --- 21 | +MAP 22 | =VAL :key 23 | =VAL &an:chor :value 24 | -MAP 25 | -DOC 26 | -STR 27 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/5MUD.tml: -------------------------------------------------------------------------------- 1 | === Colon and adjacent value on next line 2 | --- from: @perlpunk 3 | --- tags: double flow mapping 4 | 5 | --- in-yaml(<) 6 | --- 7 | { "foo" 8 | :bar } 9 | 10 | --- out-yaml(<) 11 | --- 12 | "foo": bar 13 | 14 | --- in-json 15 | { 16 | "foo": "bar" 17 | } 18 | 19 | --- test-event 20 | +STR 21 | +DOC --- 22 | +MAP 23 | =VAL "foo 24 | =VAL :bar 25 | -MAP 26 | -DOC 27 | -STR 28 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/5NYZ.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.9. Separated Comment 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2780342 3 | --- tags: mapping spec comment 4 | 5 | --- in-yaml 6 | key: # Comment 7 | value 8 | 9 | --- in-json 10 | { 11 | "key": "value" 12 | } 13 | 14 | --- out-yaml 15 | key: value 16 | 17 | --- test-event 18 | +STR 19 | +DOC 20 | +MAP 21 | =VAL :key 22 | =VAL :value 23 | -MAP 24 | -DOC 25 | -STR 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/A984.tml: -------------------------------------------------------------------------------- 1 | === Multiline Scalar in Mapping 2 | --- from: NimYAML tests 3 | --- tags: scalar 4 | 5 | --- in-yaml 6 | a: b 7 | c 8 | d: 9 | e 10 | f 11 | 12 | --- in-json 13 | { 14 | "a": "b c", 15 | "d": "e f" 16 | } 17 | 18 | --- out-yaml 19 | a: b c 20 | d: e f 21 | 22 | --- test-event 23 | +STR 24 | +DOC 25 | +MAP 26 | =VAL :a 27 | =VAL :b c 28 | =VAL :d 29 | =VAL :e f 30 | -MAP 31 | -DOC 32 | -STR 33 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/CPZ3.tml: -------------------------------------------------------------------------------- 1 | === Doublequoted scalar starting with a tab 2 | --- from: @perlpunk 3 | --- tags: double scalar 4 | 5 | --- in-yaml(<) 6 | --- 7 | tab: "\tstring" 8 | 9 | --- out-yaml(<) 10 | --- 11 | tab: "\tstring" 12 | 13 | --- in-json 14 | { 15 | "tab": "\tstring" 16 | } 17 | 18 | --- test-event 19 | +STR 20 | +DOC --- 21 | +MAP 22 | =VAL :tab 23 | =VAL "\tstring 24 | -MAP 25 | -DOC 26 | -STR 27 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/E76Z.tml: -------------------------------------------------------------------------------- 1 | === Aliases in Implicit Block Mapping 2 | --- from: NimYAML tests 3 | --- tags: mapping alias 4 | 5 | --- in-yaml 6 | &a a: &b b 7 | *b : *a 8 | 9 | --- in-json 10 | { 11 | "a": "b", 12 | "b": "a" 13 | } 14 | 15 | --- out-yaml 16 | &a a: &b b 17 | *b : *a 18 | 19 | --- test-event 20 | +STR 21 | +DOC 22 | +MAP 23 | =VAL &a :a 24 | =VAL &b :b 25 | =ALI *b 26 | =ALI *a 27 | -MAP 28 | -DOC 29 | -STR 30 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/FRK4.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.3. Completely Empty Flow Nodes 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2786868 3 | --- tags: empty-key explicit-key spec flow mapping 4 | 5 | --- in-yaml 6 | # XXX Why is ? supported in flow? 7 | { 8 | ? foo :, 9 | : bar, 10 | } 11 | 12 | --- test-event 13 | +STR 14 | +DOC 15 | +MAP 16 | =VAL :foo 17 | =VAL : 18 | =VAL : 19 | =VAL :bar 20 | -MAP 21 | -DOC 22 | -STR 23 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/FTA2.tml: -------------------------------------------------------------------------------- 1 | === Single block sequence with anchor and explicit document start 2 | --- from: @perlpunk 3 | --- tags: anchor header sequence 4 | 5 | --- in-yaml(<) 6 | --- &sequence 7 | - a 8 | 9 | --- out-yaml(<) 10 | --- &sequence 11 | - a 12 | 13 | --- in-json 14 | [ 15 | "a" 16 | ] 17 | 18 | --- test-event 19 | +STR 20 | +DOC --- 21 | +SEQ &sequence 22 | =VAL :a 23 | -SEQ 24 | -DOC 25 | -STR 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/W5VH.tml: -------------------------------------------------------------------------------- 1 | === Allowed characters in alias 2 | --- from: @perlpunk 3 | --- tags: alias 1.3-err 4 | 5 | --- in-yaml 6 | a: &:@*!$": scalar a 7 | b: *:@*!$": 8 | 9 | --- in-json 10 | { 11 | "a": "scalar a", 12 | "b": "scalar a" 13 | } 14 | 15 | --- test-event 16 | +STR 17 | +DOC 18 | +MAP 19 | =VAL :a 20 | =VAL &:@*!$": :scalar a 21 | =VAL :b 22 | =ALI *:@*!$": 23 | -MAP 24 | -DOC 25 | -STR 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/ZH7C.tml: -------------------------------------------------------------------------------- 1 | === Anchors in Mapping 2 | --- from: NimYAML tests 3 | --- tags: jayt anchor mapping 4 | 5 | This came from an edge case in NimYAML development. 6 | 7 | --- in-yaml 8 | &a a: b 9 | c: &d d 10 | 11 | --- in-json 12 | { 13 | "a": "b", 14 | "c": "d" 15 | } 16 | 17 | --- test-event 18 | +STR 19 | +DOC 20 | +MAP 21 | =VAL &a :a 22 | =VAL :b 23 | =VAL :c 24 | =VAL &d :d 25 | -MAP 26 | -DOC 27 | -STR 28 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/D88J.tml: -------------------------------------------------------------------------------- 1 | === Flow Sequence in Block Mapping 2 | --- from: NimYAML tests 3 | --- tags: flow sequence mapping 4 | 5 | --- in-yaml 6 | a: [b, c] 7 | 8 | --- in-json 9 | { 10 | "a": [ 11 | "b", 12 | "c" 13 | ] 14 | } 15 | 16 | --- out-yaml 17 | a: 18 | - b 19 | - c 20 | 21 | --- test-event 22 | +STR 23 | +DOC 24 | +MAP 25 | =VAL :a 26 | +SEQ 27 | =VAL :b 28 | =VAL :c 29 | -SEQ 30 | -MAP 31 | -DOC 32 | -STR 33 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/SSW6.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.7. Single Quoted Characters [1.3] 2 | --- from: 4GC6, modified for YAML 1.3 3 | --- tags: spec scalar single 1.3-mod 4 | 5 | --- in-yaml(<) 6 | --- 7 | 'here''s to "quotes"' 8 | 9 | --- in-json 10 | "here's to \"quotes\"" 11 | 12 | --- out-yaml(<) 13 | --- 'here''s to "quotes"' 14 | 15 | --- test-event 16 | +STR 17 | +DOC --- 18 | =VAL 'here's to "quotes" 19 | -DOC 20 | -STR 21 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/4MUZ.tml: -------------------------------------------------------------------------------- 1 | === Flow mapping colon on line after key 2 | --- from: @ingydotnet 3 | --- tags: flow mapping 4 | 5 | This is valid JSON but fails many existing parsers. 6 | 7 | --- in-yaml 8 | {"foo" 9 | : "bar"} 10 | 11 | --- emit-yaml 12 | "foo": "bar" 13 | 14 | --- in-json 15 | { 16 | "foo": "bar" 17 | } 18 | 19 | --- test-event 20 | +STR 21 | +DOC 22 | +MAP 23 | =VAL "foo 24 | =VAL "bar 25 | -MAP 26 | -DOC 27 | -STR 28 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/BEC7.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.14. “YAML” directive 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2781929 3 | --- tags: spec directive 4 | 5 | --- in-yaml(<) 6 | %YAML 1.3 # Attempt parsing 7 | # with a warning 8 | --- 9 | "foo" 10 | 11 | --- in-json 12 | "foo" 13 | 14 | --- out-yaml(<) 15 | --- "foo" 16 | 17 | --- test-event 18 | +STR 19 | +DOC --- 20 | =VAL "foo 21 | -DOC 22 | -STR 23 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/RR7F.tml: -------------------------------------------------------------------------------- 1 | === Mixed Block Mapping (implicit to explicit) 2 | --- from: NimYAML tests 3 | --- tags: explicit-key mapping 4 | 5 | --- in-yaml 6 | a: 4.2 7 | ? d 8 | : 23 9 | 10 | --- in-json 11 | { 12 | "d": 23, 13 | "a": 4.2 14 | } 15 | 16 | --- out-yaml 17 | a: 4.2 18 | d: 23 19 | 20 | --- test-event 21 | +STR 22 | +DOC 23 | +MAP 24 | =VAL :a 25 | =VAL :4.2 26 | =VAL :d 27 | =VAL :23 28 | -MAP 29 | -DOC 30 | -STR 31 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/FUP4.tml: -------------------------------------------------------------------------------- 1 | === Flow Sequence in Flow Sequence 2 | --- from: NimYAML tests 3 | --- tags: sequence flow 4 | 5 | --- in-yaml 6 | [a, [b, c]] 7 | 8 | --- in-json 9 | [ 10 | "a", 11 | [ 12 | "b", 13 | "c" 14 | ] 15 | ] 16 | 17 | --- out-yaml 18 | - a 19 | - - b 20 | - c 21 | 22 | --- test-event 23 | +STR 24 | +DOC 25 | +SEQ 26 | =VAL :a 27 | +SEQ 28 | =VAL :b 29 | =VAL :c 30 | -SEQ 31 | -SEQ 32 | -DOC 33 | -STR 34 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/H7J7.tml: -------------------------------------------------------------------------------- 1 | === Node anchor not indented 2 | --- from: https://gist.github.com/anonymous/f192e7dab6da31831f264dbf1947cb83 via @ingydotnet 3 | --- tags: anchor error indent tag 4 | 5 | This is an error because the property that is on its own line is not properly indented. 6 | 7 | --- in-yaml 8 | key: &x 9 | !!map 10 | a: b 11 | 12 | --- error 13 | 14 | --- test-event 15 | +STR 16 | +DOC 17 | +MAP 18 | =VAL :key 19 | =VAL &x : 20 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/J7VC.tml: -------------------------------------------------------------------------------- 1 | === Empty Lines Between Mapping Elements 2 | --- from: NimYAML tests 3 | --- tags: whitespace mapping 4 | 5 | --- in-yaml 6 | one: 2 7 | 8 | 9 | three: 4 10 | 11 | --- in-json 12 | { 13 | "one": 2, 14 | "three": 4 15 | } 16 | 17 | --- out-yaml 18 | one: 2 19 | three: 4 20 | 21 | --- test-event 22 | +STR 23 | +DOC 24 | +MAP 25 | =VAL :one 26 | =VAL :2 27 | =VAL :three 28 | =VAL :4 29 | -MAP 30 | -DOC 31 | -STR 32 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/M9B4.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.7. Literal Scalar 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2795789 3 | --- tags: spec literal scalar whitespace 1.3-err 4 | 5 | --- in-yaml(+) 6 | | 7 | literal 8 | text 9 | 10 | 11 | --- in-json 12 | "literal\n\ttext\n" 13 | 14 | --- out-yaml 15 | | 16 | literal 17 | text 18 | 19 | --- test-event 20 | +STR 21 | +DOC 22 | =VAL |literal\n\ttext\n 23 | -DOC 24 | -STR 25 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/8XYN.tml: -------------------------------------------------------------------------------- 1 | === Anchor with unicode character 2 | --- from: https://github.com/yaml/pyyaml/issues/94 3 | --- tags: anchor 4 | 5 | --- in-yaml(<) 6 | --- 7 | - &😁 unicode anchor 8 | 9 | --- in-json 10 | [ 11 | "unicode anchor" 12 | ] 13 | 14 | --- out-yaml(<) 15 | --- 16 | - &😁 unicode anchor 17 | 18 | --- test-event 19 | +STR 20 | +DOC --- 21 | +SEQ 22 | =VAL &😁 :unicode anchor 23 | -SEQ 24 | -DOC 25 | -STR 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9J7A.tml: -------------------------------------------------------------------------------- 1 | === Simple Mapping Indent 2 | --- from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/indent.tml 3 | --- tags: simple mapping indent 4 | 5 | --- in-yaml 6 | foo: 7 | bar: baz 8 | 9 | --- in-json 10 | { 11 | "foo": { 12 | "bar": "baz" 13 | } 14 | } 15 | 16 | --- test-event 17 | +STR 18 | +DOC 19 | +MAP 20 | =VAL :foo 21 | +MAP 22 | =VAL :bar 23 | =VAL :baz 24 | -MAP 25 | -MAP 26 | -DOC 27 | -STR 28 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/U3C3.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.16. “TAG” directive 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2782252 3 | --- tags: spec header tag 4 | 5 | --- in-yaml(<) 6 | %TAG !yaml! tag:yaml.org,2002: 7 | --- 8 | !yaml!str "foo" 9 | 10 | --- in-json 11 | "foo" 12 | 13 | --- out-yaml(<) 14 | --- !!str "foo" 15 | 16 | --- test-event 17 | +STR 18 | +DOC --- 19 | =VAL "foo 20 | -DOC 21 | -STR 22 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/V55R.tml: -------------------------------------------------------------------------------- 1 | === Aliases in Block Sequence 2 | --- from: NimYAML tests 3 | --- tags: alias sequence 4 | 5 | Anchors and aliases in a block sequence. 6 | 7 | --- in-yaml 8 | - &a a 9 | - &b b 10 | - *a 11 | - *b 12 | 13 | --- in-json 14 | [ 15 | "a", 16 | "b", 17 | "a", 18 | "b" 19 | ] 20 | 21 | --- test-event 22 | +STR 23 | +DOC 24 | +SEQ 25 | =VAL &a :a 26 | =VAL &b :b 27 | =ALI *a 28 | =ALI *b 29 | -SEQ 30 | -DOC 31 | -STR 32 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9SHH.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 5.8. Quoted Scalar Indicators 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2773890 3 | --- tags: spec scalar 4 | 5 | --- in-yaml 6 | single: 'text' 7 | double: "text" 8 | 9 | --- in-json 10 | { 11 | "single": "text", 12 | "double": "text" 13 | } 14 | 15 | --- test-event 16 | +STR 17 | +DOC 18 | +MAP 19 | =VAL :single 20 | =VAL 'text 21 | =VAL :double 22 | =VAL "text 23 | -MAP 24 | -DOC 25 | -STR 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9YRD.tml: -------------------------------------------------------------------------------- 1 | === Multiline Scalar at Top Level 2 | --- from: NimYAML tests 3 | --- tags: scalar whitespace 1.3-err 4 | 5 | --- in-yaml 6 | a 7 | b 8 | c 9 | d 10 | 11 | e 12 | 13 | --- in-json 14 | "a b c d\ne" 15 | 16 | --- out-yaml 17 | # XXX This should emit as double quoted (opinion) 18 | # "a b c d\ne" 19 | 'a b c d 20 | 21 | e' 22 | 23 | --- test-event 24 | +STR 25 | +DOC 26 | =VAL :a b c d\ne 27 | -DOC 28 | -STR 29 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/DHP8.tml: -------------------------------------------------------------------------------- 1 | === Flow Sequence 2 | --- from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/sequence.tml 3 | --- tags: flow sequence 4 | 5 | --- in-yaml 6 | [foo, bar, 42] 7 | 8 | --- in-json 9 | [ 10 | "foo", 11 | "bar", 12 | 42 13 | ] 14 | 15 | --- out-yaml 16 | - foo 17 | - bar 18 | - 42 19 | 20 | --- test-event 21 | +STR 22 | +DOC 23 | +SEQ 24 | =VAL :foo 25 | =VAL :bar 26 | =VAL :42 27 | -SEQ 28 | -DOC 29 | -STR 30 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/G5U8.tml: -------------------------------------------------------------------------------- 1 | === Plain dashes in flow sequence 2 | --- from: @ingydotnet 3 | --- tags: flow sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | - [-, -] 8 | 9 | --- out-yaml(<) 10 | --- 11 | - - '-' 12 | - '-' 13 | 14 | --- in-json 15 | [ 16 | [ 17 | "-", 18 | "-" 19 | ] 20 | ] 21 | 22 | --- test-event 23 | +STR 24 | +DOC --- 25 | +SEQ 26 | +SEQ 27 | =VAL :- 28 | =VAL :- 29 | -SEQ 30 | -SEQ 31 | -DOC 32 | -STR 33 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/P94K.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.11. Multi-Line Comments 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2780696 3 | --- tags: spec comment 4 | 5 | --- in-yaml(+) 6 | key: # Comment 7 | # lines 8 | value 9 | 10 | 11 | --- in-json 12 | { 13 | "key": "value" 14 | } 15 | 16 | --- out-yaml 17 | key: value 18 | 19 | --- test-event 20 | +STR 21 | +DOC 22 | +MAP 23 | =VAL :key 24 | =VAL :value 25 | -MAP 26 | -DOC 27 | -STR 28 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/PUW8.tml: -------------------------------------------------------------------------------- 1 | === Document start on last line 2 | --- from: @perlpunk 3 | --- tags: header 4 | 5 | --- in-yaml(<) 6 | --- 7 | a: b 8 | --- 9 | 10 | --- in-json 11 | { 12 | "a": "b" 13 | } 14 | null 15 | 16 | --- out-yaml(<) 17 | --- 18 | a: b 19 | --- 20 | ... 21 | 22 | --- test-event 23 | +STR 24 | +DOC --- 25 | +MAP 26 | =VAL :a 27 | =VAL :b 28 | -MAP 29 | -DOC 30 | +DOC --- 31 | =VAL : 32 | -DOC 33 | -STR 34 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/TL85.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.8. Flow Folding 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2779950 3 | --- tags: double spec whitespace scalar upto-1.2 4 | 5 | --- in-yaml 6 | " 7 | foo 8 | 9 | bar 10 | 11 | baz 12 | " 13 | 14 | --- in-json 15 | " foo\nbar\nbaz " 16 | 17 | --- out-yaml 18 | " foo\nbar\nbaz " 19 | 20 | --- test-event 21 | +STR 22 | +DOC 23 | =VAL " foo\nbar\nbaz 24 | -DOC 25 | -STR 26 | -------------------------------------------------------------------------------- /core/shared/src/main/scala-3/org/virtuslab/yaml/YamlCodecCrossCompat.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml 2 | 3 | import scala.deriving.Mirror 4 | 5 | private[yaml] trait YamlCodecCompanionCrossCompat { 6 | 7 | def make[A](implicit decoder: YamlDecoder[A], encoder: YamlEncoder[A]): YamlCodec[A] 8 | 9 | inline def derived[T](using m: Mirror.Of[T]): YamlCodec[T] = 10 | val decoder = YamlDecoder.derived[T] 11 | val encoder = YamlEncoder.derived[T] 12 | make(decoder, encoder) 13 | } 14 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/EXG3.tml: -------------------------------------------------------------------------------- 1 | === Three dashes and content without space [1.3] 2 | --- from: 82AN, modified for YAML 1.3 3 | --- tags: scalar 1.3-mod 4 | 5 | --- in-yaml(<) 6 | --- 7 | ---word1 8 | word2 9 | 10 | --- emit-yaml(<) 11 | --- '---word1 word2' 12 | 13 | --- in-json 14 | "---word1 word2" 15 | 16 | --- out-yaml 17 | '---word1 word2' 18 | 19 | --- test-event 20 | +STR 21 | +DOC --- 22 | =VAL :---word1 word2 23 | -DOC 24 | -STR 25 | 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/GH63.tml: -------------------------------------------------------------------------------- 1 | === Mixed Block Mapping (explicit to implicit) 2 | --- from: NimYAML tests 3 | --- tags: explicit-key mapping 4 | 5 | --- in-yaml 6 | ? a 7 | : 1.3 8 | fifteen: d 9 | 10 | --- in-json 11 | { 12 | "a": 1.3, 13 | "fifteen": "d" 14 | } 15 | 16 | --- out-yaml 17 | a: 1.3 18 | fifteen: d 19 | 20 | --- test-event 21 | +STR 22 | +DOC 23 | +MAP 24 | =VAL :a 25 | =VAL :1.3 26 | =VAL :fifteen 27 | =VAL :d 28 | -MAP 29 | -DOC 30 | -STR 31 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/H3Z8.tml: -------------------------------------------------------------------------------- 1 | === Literal unicode 2 | --- from: @perlpunk 3 | --- tags: scalar 4 | 5 | --- in-yaml(<) 6 | --- 7 | wanted: love ♥ and peace ☮ 8 | 9 | --- in-json 10 | { 11 | "wanted": "love ♥ and peace ☮" 12 | } 13 | 14 | --- out-yaml(<) 15 | --- 16 | wanted: "love \u2665 and peace \u262E" 17 | 18 | --- test-event 19 | +STR 20 | +DOC --- 21 | +MAP 22 | =VAL :wanted 23 | =VAL :love ♥ and peace ☮ 24 | -MAP 25 | -DOC 26 | -STR 27 | -------------------------------------------------------------------------------- /core/shared/src/main/scala/org/virtuslab/yaml/syntax/NodeSelector.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml.syntax 2 | 3 | import org.virtuslab.yaml.Node 4 | 5 | sealed trait NodeSelector { 6 | def show: String 7 | } 8 | 9 | object NodeSelector { 10 | 11 | case class IntSelector(index: Int) extends NodeSelector { 12 | override def show: String = index.toString 13 | } 14 | case class StringSelector(field: String) extends NodeSelector { 15 | override def show: String = field 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/3MYT.tml: -------------------------------------------------------------------------------- 1 | === Plain Scalar looking like key, comment, anchor and tag 2 | --- from: https://gist.github.com/anonymous/a98d50ce42a59b1e999552bea7a31f57 via @ingydotnet 3 | --- tags: scalar 4 | 5 | --- in-yaml(<) 6 | --- 7 | k:#foo 8 | &a !t s 9 | 10 | --- in-json 11 | "k:#foo &a !t s" 12 | 13 | --- out-yaml(<) 14 | --- k:#foo &a !t s 15 | 16 | --- test-event 17 | +STR 18 | +DOC --- 19 | =VAL :k:#foo &a !t s 20 | -DOC 21 | -STR 22 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/7W2P.tml: -------------------------------------------------------------------------------- 1 | === Block Mapping with Missing Values 2 | --- from: NimYAML tests 3 | --- tags: explicit-key mapping 4 | 5 | --- in-yaml 6 | ? a 7 | ? b 8 | c: 9 | 10 | --- in-json 11 | { 12 | "a": null, 13 | "b": null, 14 | "c": null 15 | } 16 | 17 | --- out-yaml 18 | a: 19 | b: 20 | c: 21 | 22 | --- test-event 23 | +STR 24 | +DOC 25 | +MAP 26 | =VAL :a 27 | =VAL : 28 | =VAL :b 29 | =VAL : 30 | =VAL :c 31 | =VAL : 32 | -MAP 33 | -DOC 34 | -STR 35 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/QF4Y.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.19. Single Pair Flow Mappings 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2792291 3 | --- tags: spec flow mapping 4 | 5 | --- in-yaml 6 | [ 7 | foo: bar 8 | ] 9 | 10 | --- in-json 11 | [ 12 | { 13 | "foo": "bar" 14 | } 15 | ] 16 | 17 | --- out-yaml 18 | - foo: bar 19 | 20 | --- test-event 21 | +STR 22 | +DOC 23 | +SEQ 24 | +MAP 25 | =VAL :foo 26 | =VAL :bar 27 | -MAP 28 | -SEQ 29 | -DOC 30 | -STR 31 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/SBG9.tml: -------------------------------------------------------------------------------- 1 | === Flow Sequence in Flow Mapping 2 | --- from: NimYAML tests 3 | --- tags: complex-key sequence mapping flow 4 | 5 | --- in-yaml 6 | {a: [b, c], [d, e]: f} 7 | 8 | --- out-yaml 9 | a: 10 | - b 11 | - c 12 | ? - d 13 | - e 14 | : f 15 | 16 | --- test-event 17 | +STR 18 | +DOC 19 | +MAP 20 | =VAL :a 21 | +SEQ 22 | =VAL :b 23 | =VAL :c 24 | -SEQ 25 | +SEQ 26 | =VAL :d 27 | =VAL :e 28 | -SEQ 29 | =VAL :f 30 | -MAP 31 | -DOC 32 | -STR 33 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/X8DW.tml: -------------------------------------------------------------------------------- 1 | === Explicit key and value seperated by comment 2 | --- from: @perlpunk 3 | --- tags: comment explicit-key mapping 4 | 5 | --- in-yaml(<) 6 | --- 7 | ? key 8 | # comment 9 | : value 10 | 11 | --- out-yaml(<) 12 | --- 13 | key: value 14 | 15 | --- in-json 16 | { 17 | "key": "value" 18 | } 19 | 20 | --- test-event 21 | +STR 22 | +DOC --- 23 | +MAP 24 | =VAL :key 25 | =VAL :value 26 | -MAP 27 | -DOC 28 | -STR 29 | -------------------------------------------------------------------------------- /core/shared/src/test/scala/org/virtuslab/yaml/decoder/BaseDecoderErrorSuite.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml.decoder 2 | 3 | import org.virtuslab.yaml.YamlError 4 | 5 | class BaseDecoderErrorSuite extends munit.FunSuite { 6 | 7 | def assertError[T](obtained: Either[YamlError, T], expected: String): Unit = 8 | obtained match { 9 | case r @ Right(value) => fail(s"Get $r, expected Left") 10 | case Left(error: YamlError) => assertNoDiff(error.msg, expected) 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/36F6.tml: -------------------------------------------------------------------------------- 1 | === Multiline plain scalar with empty line 2 | --- from: @perlpunk 3 | --- tags: mapping scalar 4 | 5 | --- in-yaml(<) 6 | --- 7 | plain: a 8 | b 9 | 10 | c 11 | 12 | --- in-json 13 | { 14 | "plain": "a b\nc" 15 | } 16 | 17 | --- out-yaml(<) 18 | --- 19 | plain: 'a b 20 | 21 | c' 22 | 23 | --- test-event 24 | +STR 25 | +DOC --- 26 | +MAP 27 | =VAL :plain 28 | =VAL :a b\nc 29 | -MAP 30 | -DOC 31 | -STR 32 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6LVF.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.13. Reserved Directives 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2781445 3 | --- tags: spec directive header double 1.3-err 4 | 5 | --- in-yaml(<) 6 | %FOO bar baz # Should be ignored 7 | # with a warning. 8 | --- "foo" 9 | 10 | --- in-json 11 | "foo" 12 | 13 | --- out-yaml(<) 14 | --- "foo" 15 | 16 | --- test-event 17 | +STR 18 | +DOC --- 19 | =VAL "foo 20 | -DOC 21 | -STR 22 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/K3WX.tml: -------------------------------------------------------------------------------- 1 | === Colon and adjacent value after comment on next line 2 | --- from: 3 | --- tags: comment flow mapping 4 | 5 | --- in-yaml(<) 6 | --- 7 | { "foo" # comment 8 | :bar } 9 | 10 | --- out-yaml(<) 11 | --- 12 | "foo": bar 13 | 14 | --- in-json 15 | { 16 | "foo": "bar" 17 | } 18 | 19 | --- test-event 20 | +STR 21 | +DOC --- 22 | +MAP 23 | =VAL "foo 24 | =VAL :bar 25 | -MAP 26 | -DOC 27 | -STR 28 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/54T7.tml: -------------------------------------------------------------------------------- 1 | === Flow Mapping 2 | --- from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml 3 | --- tags: flow mapping 4 | 5 | --- in-yaml 6 | {foo: you, bar: far} 7 | 8 | --- in-json 9 | { 10 | "foo": "you", 11 | "bar": "far" 12 | } 13 | 14 | --- out-yaml 15 | foo: you 16 | bar: far 17 | 18 | --- test-event 19 | +STR 20 | +DOC 21 | +MAP 22 | =VAL :foo 23 | =VAL :you 24 | =VAL :bar 25 | =VAL :far 26 | -MAP 27 | -DOC 28 | -STR 29 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/7TMG.tml: -------------------------------------------------------------------------------- 1 | === Comment in flow sequence before comma 2 | --- from: @perlpunk 3 | --- tags: comment flow sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | [ word1 8 | # comment 9 | , word2] 10 | 11 | --- in-json 12 | [ 13 | "word1", 14 | "word2" 15 | ] 16 | 17 | --- out-yaml(<) 18 | --- 19 | - word1 20 | - word2 21 | 22 | --- test-event 23 | +STR 24 | +DOC --- 25 | +SEQ 26 | =VAL :word1 27 | =VAL :word2 28 | -SEQ 29 | -DOC 30 | -STR 31 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/AB8U.tml: -------------------------------------------------------------------------------- 1 | === Sequence entry that looks like two with wrong indentation 2 | --- from: @perlpunk 3 | --- tags: scalar sequence 4 | 5 | --- in-yaml 6 | - single multiline 7 | - sequence entry 8 | 9 | --- in-json 10 | [ 11 | "single multiline - sequence entry" 12 | ] 13 | 14 | --- out-yaml 15 | - single multiline - sequence entry 16 | 17 | --- test-event 18 | +STR 19 | +DOC 20 | +SEQ 21 | =VAL :single multiline - sequence entry 22 | -SEQ 23 | -DOC 24 | -STR 25 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/AZ63.tml: -------------------------------------------------------------------------------- 1 | === Sequence With Same Indentation as Parent Mapping 2 | --- from: NimYAML tests 3 | --- tags: indent mapping sequence 4 | 5 | --- in-yaml 6 | one: 7 | - 2 8 | - 3 9 | four: 5 10 | 11 | --- in-json 12 | { 13 | "one": [ 14 | 2, 15 | 3 16 | ], 17 | "four": 5 18 | } 19 | 20 | --- test-event 21 | +STR 22 | +DOC 23 | +MAP 24 | =VAL :one 25 | +SEQ 26 | =VAL :2 27 | =VAL :3 28 | -SEQ 29 | =VAL :four 30 | =VAL :5 31 | -MAP 32 | -DOC 33 | -STR 34 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/B3HG.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.9. Folded Scalar [1.3] 2 | --- from: G992, modified for YAML 1.3 3 | --- tags: spec folded scalar 1.3-mod 4 | 5 | --- in-yaml(<+) 6 | --- > 7 | folded 8 | text 9 | 10 | 11 | --- in-json 12 | "folded text\n" 13 | 14 | --- out-yaml 15 | > 16 | folded text 17 | 18 | --- emit-yaml(<) 19 | --- > 20 | folded text 21 | 22 | --- test-event 23 | +STR 24 | +DOC --- 25 | =VAL >folded text\n 26 | -DOC 27 | -STR 28 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/DK3J.tml: -------------------------------------------------------------------------------- 1 | === Zero indented block scalar with line that looks like a comment 2 | --- from: @perlpunk 3 | --- tags: comment folded scalar 4 | 5 | --- in-yaml(<) 6 | --- > 7 | line1 8 | # no comment 9 | line3 10 | 11 | --- in-json 12 | "line1 # no comment line3\n" 13 | 14 | --- out-yaml(<) 15 | --- > 16 | line1 # no comment line3 17 | 18 | --- test-event 19 | +STR 20 | +DOC --- 21 | =VAL >line1 # no comment line3\n 22 | -DOC 23 | -STR 24 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/KMK3.tml: -------------------------------------------------------------------------------- 1 | === Block Submapping 2 | --- from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml 3 | --- tags: mapping 4 | 5 | --- in-yaml 6 | foo: 7 | bar: 1 8 | baz: 2 9 | 10 | --- in-json 11 | { 12 | "foo": { 13 | "bar": 1 14 | }, 15 | "baz": 2 16 | } 17 | 18 | --- test-event 19 | +STR 20 | +DOC 21 | +MAP 22 | =VAL :foo 23 | +MAP 24 | =VAL :bar 25 | =VAL :1 26 | -MAP 27 | =VAL :baz 28 | =VAL :2 29 | -MAP 30 | -DOC 31 | -STR 32 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/M29M.tml: -------------------------------------------------------------------------------- 1 | === Literal Block Scalar 2 | --- from: NimYAML tests 3 | --- tags: literal scalar whitespace 4 | 5 | --- in-yaml 6 | a: | 7 | ab 8 | 9 | cd 10 | ef 11 | 12 | 13 | ... 14 | 15 | --- in-json 16 | { 17 | "a": "ab\n\ncd\nef\n" 18 | } 19 | 20 | --- out-yaml 21 | a: | 22 | ab 23 | 24 | cd 25 | ef 26 | ... 27 | 28 | --- test-event 29 | +STR 30 | +DOC 31 | +MAP 32 | =VAL :a 33 | =VAL |ab\n\ncd\nef\n 34 | -MAP 35 | -DOC ... 36 | -STR 37 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/8QBE.tml: -------------------------------------------------------------------------------- 1 | === Block Sequence in Block Mapping 2 | --- from: NimYAML tests 3 | --- tags: mapping sequence 4 | 5 | --- in-yaml 6 | key: 7 | - item1 8 | - item2 9 | 10 | --- in-json 11 | { 12 | "key": [ 13 | "item1", 14 | "item2" 15 | ] 16 | } 17 | 18 | --- out-yaml 19 | key: 20 | - item1 21 | - item2 22 | 23 | --- test-event 24 | +STR 25 | +DOC 26 | +MAP 27 | =VAL :key 28 | +SEQ 29 | =VAL :item1 30 | =VAL :item2 31 | -SEQ 32 | -MAP 33 | -DOC 34 | -STR 35 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/QLJ7.tml: -------------------------------------------------------------------------------- 1 | === Tag shorthand used in documents but only defined in the first 2 | --- from: IRC 3 | --- tags: error directive tag 4 | 5 | --- in-yaml(<) 6 | %TAG !prefix! tag:example.com,2011: 7 | --- !prefix!A 8 | a: b 9 | --- !prefix!B 10 | c: d 11 | --- !prefix!C 12 | e: f 13 | 14 | --- error 15 | 16 | --- test-event 17 | +STR 18 | +DOC --- 19 | +MAP 20 | =VAL :a 21 | =VAL :b 22 | -MAP 23 | -DOC 24 | +DOC --- 25 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/UDM2.tml: -------------------------------------------------------------------------------- 1 | === Plain URL in flow mapping 2 | --- from: https://github.com/yaml/libyaml/pull/28 3 | --- tags: flow scalar 4 | 5 | --- in-yaml 6 | - { url: http://example.org } 7 | 8 | --- in-json 9 | [ 10 | { 11 | "url": "http://example.org" 12 | } 13 | ] 14 | 15 | --- out-yaml 16 | - url: http://example.org 17 | 18 | --- test-event 19 | +STR 20 | +DOC 21 | +SEQ 22 | +MAP 23 | =VAL :url 24 | =VAL :http://example.org 25 | -MAP 26 | -SEQ 27 | -DOC 28 | -STR 29 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/AZW3.tml: -------------------------------------------------------------------------------- 1 | === Lookahead test cases 2 | --- from: NimYAML tests 3 | --- tags: mapping edge 4 | 5 | --- in-yaml 6 | - bla"keks: foo 7 | - bla]keks: foo 8 | 9 | --- in-json 10 | [ 11 | { 12 | "bla\"keks": "foo" 13 | }, 14 | { 15 | "bla]keks": "foo" 16 | } 17 | ] 18 | 19 | --- test-event 20 | +STR 21 | +DOC 22 | +SEQ 23 | +MAP 24 | =VAL :bla"keks 25 | =VAL :foo 26 | -MAP 27 | +MAP 28 | =VAL :bla]keks 29 | =VAL :foo 30 | -MAP 31 | -SEQ 32 | -DOC 33 | -STR 34 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/RTP8.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 9.2. Document Markers 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2800866 3 | --- tags: spec header footer 4 | 5 | --- in-yaml(<) 6 | # XXX Why is a comment allowed on ...? 7 | %YAML 1.2 8 | --- 9 | Document 10 | ... # Suffix 11 | 12 | --- in-json 13 | "Document" 14 | 15 | --- out-yaml(<) 16 | --- Document 17 | ... 18 | 19 | --- test-event 20 | +STR 21 | +DOC --- 22 | =VAL :Document 23 | -DOC ... 24 | -STR 25 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6FWR.tml: -------------------------------------------------------------------------------- 1 | === Block Scalar Keep 2 | --- from: NimYAML tests 3 | --- tags: literal scalar whitespace 4 | 5 | --- in-yaml(<) 6 | --- |+ 7 | ab 8 | 9 | 10 | ... 11 | 12 | --- in-json 13 | "ab\n\n \n" 14 | 15 | --- out-yaml 16 | "ab\n\n \n" 17 | ... 18 | 19 | --- emit-yaml(<) 20 | --- | 21 | ab 22 | 23 | 24 | ... 25 | 26 | --- test-event 27 | +STR 28 | +DOC --- 29 | =VAL |ab\n\n \n 30 | -DOC ... 31 | -STR 32 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/CC74.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.20. Tag Handles 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2783195 3 | --- tags: spec directive tag unknown-tag 4 | 5 | --- in-yaml(<) 6 | %TAG !e! tag:example.com,2000:app/ 7 | --- 8 | !e!foo "bar" 9 | 10 | --- out-yaml(<) 11 | --- ! "bar" 12 | 13 | --- in-json(<) 14 | "bar" 15 | 16 | --- test-event 17 | +STR 18 | +DOC --- 19 | =VAL "bar 20 | -DOC 21 | -STR 22 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/JTV5.tml: -------------------------------------------------------------------------------- 1 | === Block Mapping with Multiline Scalars 2 | --- from: NimYAML tests 3 | --- tags: explicit-key mapping scalar 4 | 5 | --- in-yaml 6 | ? a 7 | true 8 | : null 9 | d 10 | ? e 11 | 42 12 | 13 | --- in-json 14 | { 15 | "a true": "null d", 16 | "e 42": null 17 | } 18 | 19 | --- out-yaml 20 | a true: null d 21 | e 42: 22 | 23 | --- test-event 24 | +STR 25 | +DOC 26 | +MAP 27 | =VAL :a true 28 | =VAL :null d 29 | =VAL :e 42 30 | =VAL : 31 | -MAP 32 | -DOC 33 | -STR 34 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/K527.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.6. Line Folding 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2779289 3 | --- tags: folded spec whitespace scalar 1.3-err 4 | 5 | --- in-yaml 6 | >- 7 | trimmed 8 | 9 | 10 | 11 | as 12 | space 13 | 14 | --- in-json 15 | "trimmed\n\n\nas space" 16 | 17 | --- out-yaml 18 | >- 19 | trimmed 20 | 21 | 22 | 23 | as space 24 | 25 | --- test-event 26 | +STR 27 | +DOC 28 | =VAL >trimmed\n\n\nas space 29 | -DOC 30 | -STR 31 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/MJS9.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.7. Block Folding 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2779603 3 | --- tags: folded spec scalar whitespace 1.3-err 4 | 5 | --- in-yaml 6 | > 7 | foo 8 | 9 | bar 10 | 11 | baz 12 | 13 | --- in-json 14 | "foo \n\n\t bar\n\nbaz\n" 15 | 16 | --- out-yaml 17 | # XXX Should be folded? 18 | "foo \n\n\t bar\n\nbaz\n" 19 | 20 | --- test-event 21 | +STR 22 | +DOC 23 | =VAL >foo \n\n\t bar\n\nbaz\n 24 | -DOC 25 | -STR 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/7FWL.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.24. Verbatim Tags 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2784370 3 | --- tags: mapping spec tag unknown-tag 4 | 5 | --- in-yaml 6 | ! foo : 7 | ! baz 8 | 9 | --- out-yaml 10 | !!str foo: !bar baz 11 | 12 | --- in-json(<) 13 | { 14 | "foo": "baz" 15 | } 16 | 17 | --- test-event 18 | +STR 19 | +DOC 20 | +MAP 21 | =VAL :foo 22 | =VAL :baz 23 | -MAP 24 | -DOC 25 | -STR 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/8CWC.tml: -------------------------------------------------------------------------------- 1 | === Plain mapping key ending with colon 2 | --- from: @perlpunk 3 | --- tags: mapping scalar 4 | 5 | --- in-yaml(<) 6 | --- 7 | key ends with two colons::: value 8 | 9 | --- in-json 10 | { 11 | "key ends with two colons::": "value" 12 | } 13 | 14 | --- out-yaml(<) 15 | --- 16 | 'key ends with two colons::': value 17 | 18 | --- test-event 19 | +STR 20 | +DOC --- 21 | +MAP 22 | =VAL :key ends with two colons:: 23 | =VAL :value 24 | -MAP 25 | -DOC 26 | -STR 27 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/CT4Q.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.20. Single Pair Explicit Entry 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2792424 3 | --- tags: explicit-key spec flow mapping 4 | 5 | --- in-yaml 6 | [ 7 | ? foo 8 | bar : baz 9 | ] 10 | 11 | --- in-json 12 | [ 13 | { 14 | "foo bar": "baz" 15 | } 16 | ] 17 | 18 | --- out-yaml 19 | - foo bar: baz 20 | 21 | --- test-event 22 | +STR 23 | +DOC 24 | +SEQ 25 | +MAP 26 | =VAL :foo bar 27 | =VAL :baz 28 | -MAP 29 | -SEQ 30 | -DOC 31 | -STR 32 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/NB6Z.tml: -------------------------------------------------------------------------------- 1 | === Multiline plain value with tabs on empty lines 2 | --- from: @perlpunk 3 | --- tags: scalar whitespace 4 | 5 | --- in-yaml(<) 6 | key: 7 | value 8 | with 9 | 10 | tabs 11 | 12 | --- out-yaml(<) 13 | key: 'value with 14 | 15 | tabs' 16 | 17 | --- in-json 18 | { 19 | "key": "value with\ntabs" 20 | } 21 | 22 | --- test-event 23 | +STR 24 | +DOC 25 | +MAP 26 | =VAL :key 27 | =VAL :value with\ntabs 28 | -MAP 29 | -DOC 30 | -STR 31 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/4Q9F.tml: -------------------------------------------------------------------------------- 1 | === Folded Block Scalar [1.3] 2 | --- from: TS54, modified for YAML 1.3 3 | --- tags: folded scalar 1.3-mod whitespace 4 | 5 | --- in-yaml(<) 6 | --- > 7 | ab 8 | cd 9 | 10 | ef 11 | 12 | 13 | gh 14 | 15 | --- in-json 16 | "ab cd\nef\n\ngh\n" 17 | 18 | --- out-yaml(<) 19 | --- > 20 | ab cd 21 | 22 | ef 23 | 24 | 25 | gh 26 | 27 | --- test-event 28 | +STR 29 | +DOC --- 30 | =VAL >ab cd\nef\n\ngh\n 31 | -DOC 32 | -STR 33 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/J5UC.tml: -------------------------------------------------------------------------------- 1 | === Multiple Pair Block Mapping 2 | --- from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml 3 | --- tags: mapping 4 | 5 | --- in-yaml 6 | foo: blue 7 | bar: arrr 8 | baz: jazz 9 | 10 | --- in-json 11 | { 12 | "foo": "blue", 13 | "bar": "arrr", 14 | "baz": "jazz" 15 | } 16 | 17 | --- test-event 18 | +STR 19 | +DOC 20 | +MAP 21 | =VAL :foo 22 | =VAL :blue 23 | =VAL :bar 24 | =VAL :arrr 25 | =VAL :baz 26 | =VAL :jazz 27 | -MAP 28 | -DOC 29 | -STR 30 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6KGN.tml: -------------------------------------------------------------------------------- 1 | === Anchor for empty node 2 | --- from: https://github.com/nodeca/js-yaml/issues/301 3 | --- tags: alias anchor 4 | 5 | --- in-yaml(<) 6 | --- 7 | a: &anchor 8 | b: *anchor 9 | 10 | --- out-yaml(<) 11 | --- 12 | a: &anchor 13 | b: *anchor 14 | 15 | --- in-json 16 | { 17 | "a": null, 18 | "b": null 19 | } 20 | 21 | --- test-event 22 | +STR 23 | +DOC --- 24 | +MAP 25 | =VAL :a 26 | =VAL &anchor : 27 | =VAL :b 28 | =ALI *anchor 29 | -MAP 30 | -DOC 31 | -STR 32 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/7Z25.tml: -------------------------------------------------------------------------------- 1 | === Bare document after document end marker 2 | --- from: @perlpunk 3 | --- tags: footer 4 | 5 | --- in-yaml(<) 6 | --- 7 | scalar1 8 | ... 9 | key: value 10 | 11 | --- in-json 12 | "scalar1" 13 | { 14 | "key": "value" 15 | } 16 | 17 | --- out-yaml(<) 18 | --- scalar1 19 | ... 20 | key: value 21 | 22 | --- test-event 23 | +STR 24 | +DOC --- 25 | =VAL :scalar1 26 | -DOC ... 27 | +DOC 28 | +MAP 29 | =VAL :key 30 | =VAL :value 31 | -MAP 32 | -DOC 33 | -STR 34 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/DFF7.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.16. Flow Mapping Entries 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2791260 3 | --- tags: explicit-key spec flow mapping 4 | 5 | --- in-yaml 6 | { 7 | ? explicit: entry, 8 | implicit: entry, 9 | ? 10 | } 11 | 12 | --- out-yaml 13 | explicit: entry 14 | implicit: entry 15 | : 16 | 17 | --- test-event 18 | +STR 19 | +DOC 20 | +MAP 21 | =VAL :explicit 22 | =VAL :entry 23 | =VAL :implicit 24 | =VAL :entry 25 | =VAL : 26 | =VAL : 27 | -MAP 28 | -DOC 29 | -STR 30 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/2AUY.tml: -------------------------------------------------------------------------------- 1 | === Tags in Block Sequence 2 | --- from: NimYAML tests 3 | --- tags: tag sequence 4 | 5 | --- in-yaml 6 | - !!str a 7 | - b 8 | - !!int 42 9 | - d 10 | 11 | --- in-json 12 | [ 13 | "a", 14 | "b", 15 | 42, 16 | "d" 17 | ] 18 | 19 | --- out-yaml 20 | - !!str a 21 | - b 22 | - !!int 42 23 | - d 24 | 25 | --- test-event 26 | +STR 27 | +DOC 28 | +SEQ 29 | =VAL :a 30 | =VAL :b 31 | =VAL :42 32 | =VAL :d 33 | -SEQ 34 | -DOC 35 | -STR 36 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/2LFX.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.13. Reserved Directives [1.3] 2 | --- from: 6LVF, modified for YAML 1.3 3 | --- tags: spec directive header double 1.3-mod 4 | 5 | --- in-yaml(<) 6 | %FOO bar baz # Should be ignored 7 | # with a warning. 8 | --- 9 | "foo" 10 | 11 | --- in-json 12 | "foo" 13 | 14 | --- out-yaml(<) 15 | --- 16 | "foo" 17 | 18 | --- emit-yaml(<) 19 | --- "foo" 20 | 21 | --- test-event 22 | +STR 23 | +DOC --- 24 | =VAL "foo 25 | -DOC 26 | -STR 27 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/S4JQ.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.28. Non-Specific Tags 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2785512 3 | --- tags: spec tag 4 | 5 | --- in-yaml(<) 6 | # Assuming conventional resolution: 7 | - "12" 8 | - 12 9 | - ! 12 10 | 11 | --- in-json 12 | [ 13 | "12", 14 | 12, 15 | "12" 16 | ] 17 | 18 | --- out-yaml 19 | - "12" 20 | - 12 21 | - ! 12 22 | 23 | --- test-event 24 | +STR 25 | +DOC 26 | +SEQ 27 | =VAL "12 28 | =VAL :12 29 | =VAL :12 30 | -SEQ 31 | -DOC 32 | -STR 33 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/TE2A.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.16. Block Mappings 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2798147 3 | --- tags: spec mapping 4 | 5 | --- in-yaml 6 | block mapping: 7 | key: value 8 | 9 | --- in-json 10 | { 11 | "block mapping": { 12 | "key": "value" 13 | } 14 | } 15 | 16 | --- out-yaml 17 | block mapping: 18 | key: value 19 | 20 | --- test-event 21 | +STR 22 | +DOC 23 | +MAP 24 | =VAL :block mapping 25 | +MAP 26 | =VAL :key 27 | =VAL :value 28 | -MAP 29 | -MAP 30 | -DOC 31 | -STR 32 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/4JVG.tml: -------------------------------------------------------------------------------- 1 | === Scalar value with two anchors 2 | --- from: @perlpunk 3 | --- tags: anchor error mapping 4 | 5 | This test shows a valid structure in the first pair but the second pair is 6 | invalid because it has two anchors for the scalar value. 7 | 8 | --- in-yaml 9 | top1: &node1 10 | &k1 key1: val1 11 | top2: &node2 12 | &v2 val2 13 | 14 | --- error 15 | 16 | --- test-event 17 | +STR 18 | +DOC 19 | +MAP 20 | =VAL :top1 21 | +MAP &node1 22 | =VAL &k1 :key1 23 | =VAL :val1 24 | -MAP 25 | =VAL :top2 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/JS2J.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.29. Node Anchors 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2785977 3 | --- tags: spec alias 4 | 5 | --- in-yaml 6 | First occurrence: &anchor Value 7 | Second occurrence: *anchor 8 | 9 | --- in-json 10 | { 11 | "First occurrence": "Value", 12 | "Second occurrence": "Value" 13 | } 14 | 15 | --- test-event 16 | +STR 17 | +DOC 18 | +MAP 19 | =VAL :First occurrence 20 | =VAL &anchor :Value 21 | =VAL :Second occurrence 22 | =ALI *anchor 23 | -MAP 24 | -DOC 25 | -STR 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/V9D5.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.19. Compact Block Mappings 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2799091 3 | --- tags: complex-key explicit-key spec mapping 4 | 5 | --- in-yaml 6 | - sun: yellow 7 | - ? earth: blue 8 | : moon: white 9 | 10 | --- test-event 11 | +STR 12 | +DOC 13 | +SEQ 14 | +MAP 15 | =VAL :sun 16 | =VAL :yellow 17 | -MAP 18 | +MAP 19 | +MAP 20 | =VAL :earth 21 | =VAL :blue 22 | -MAP 23 | +MAP 24 | =VAL :moon 25 | =VAL :white 26 | -MAP 27 | -MAP 28 | -SEQ 29 | -DOC 30 | -STR 31 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6PBE.tml: -------------------------------------------------------------------------------- 1 | === Zero-indented sequences in explicit mapping keys 2 | --- from: @perlpunk 3 | --- tags: explicit-key mapping sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | ? 8 | - a 9 | - b 10 | : 11 | - c 12 | - d 13 | 14 | --- emit-yaml(<) 15 | --- 16 | ? - a 17 | - b 18 | : - c 19 | - d 20 | 21 | --- test-event 22 | +STR 23 | +DOC --- 24 | +MAP 25 | +SEQ 26 | =VAL :a 27 | =VAL :b 28 | -SEQ 29 | +SEQ 30 | =VAL :c 31 | =VAL :d 32 | -SEQ 33 | -MAP 34 | -DOC 35 | -STR 36 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/L94M.tml: -------------------------------------------------------------------------------- 1 | === Tags in Explicit Mapping 2 | --- from: NimYAML tests 3 | --- tags: explicit-key tag mapping 4 | 5 | --- in-yaml 6 | ? !!str a 7 | : !!int 47 8 | ? c 9 | : !!str d 10 | 11 | --- in-json 12 | { 13 | "a": 47, 14 | "c": "d" 15 | } 16 | 17 | --- out-yaml 18 | !!str a: !!int 47 19 | c: !!str d 20 | 21 | --- test-event 22 | +STR 23 | +DOC 24 | +MAP 25 | =VAL :a 26 | =VAL :47 27 | =VAL :c 28 | =VAL :d 29 | -MAP 30 | -DOC 31 | -STR 32 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/P76L.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.19. Secondary Tag Handle 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2782940 3 | --- tags: spec header tag unknown-tag 4 | 5 | --- in-yaml(<) 6 | %TAG !! tag:example.com,2000:app/ 7 | --- 8 | !!int 1 - 3 # Interval, not integer 9 | 10 | --- out-yaml(<) 11 | --- ! 1 - 3 12 | 13 | --- in-json(<) 14 | "1 - 3" 15 | 16 | --- test-event 17 | +STR 18 | +DOC --- 19 | =VAL :1 - 3 20 | -DOC 21 | -STR 22 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6JQW.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.13. In literals, newlines are preserved 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2759963 3 | --- tags: spec scalar literal comment 4 | 5 | --- in-yaml(<) 6 | # ASCII Art 7 | --- | 8 | \//||\/|| 9 | // || ||__ 10 | 11 | --- in-json 12 | "\\//||\\/||\n// || ||__\n" 13 | 14 | --- out-yaml(<) 15 | --- | 16 | \//||\/|| 17 | // || ||__ 18 | 19 | --- test-event 20 | +STR 21 | +DOC --- 22 | =VAL |\\//||\\/||\n// || ||__\n 23 | -DOC 24 | -STR 25 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6WPF.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.8. Flow Folding [1.3] 2 | --- from: TL85, modified for YAML 1.3 3 | --- tags: double spec whitespace scalar 1.3-mod 4 | 5 | --- in-yaml(<) 6 | --- 7 | " 8 | foo 9 | 10 | bar 11 | 12 | baz 13 | " 14 | 15 | --- in-json 16 | " foo\nbar\nbaz " 17 | 18 | --- out-yaml 19 | " foo\nbar\nbaz " 20 | 21 | --- emit-yaml(<) 22 | --- " foo\nbar\nbaz " 23 | 24 | --- test-event 25 | +STR 26 | +DOC --- 27 | =VAL " foo\nbar\nbaz 28 | -DOC 29 | -STR 30 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/93WF.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.6. Line Folding [1.3] 2 | --- from: K527, modified for YAML 1.3 3 | --- tags: folded spec whitespace scalar 1.3-mod 4 | 5 | --- in-yaml(<) 6 | --- >- 7 | trimmed 8 | 9 | 10 | 11 | as 12 | space 13 | 14 | --- in-json 15 | "trimmed\n\n\nas space" 16 | 17 | --- out-yaml(<) 18 | --- >- 19 | trimmed 20 | 21 | 22 | 23 | as space 24 | 25 | --- test-event 26 | +STR 27 | +DOC --- 28 | =VAL >trimmed\n\n\nas space 29 | -DOC 30 | -STR 31 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/7A4E.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.6. Double Quoted Lines 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2787994 3 | --- tags: spec scalar upto-1.2 whitespace 4 | 5 | --- in-yaml 6 | " 1st non-empty 7 | 8 | 2nd non-empty 9 | 3rd non-empty " 10 | 11 | --- in-json 12 | " 1st non-empty\n2nd non-empty 3rd non-empty " 13 | 14 | --- out-yaml 15 | " 1st non-empty\n2nd non-empty 3rd non-empty " 16 | 17 | --- test-event 18 | +STR 19 | +DOC 20 | =VAL " 1st non-empty\n2nd non-empty 3rd non-empty 21 | -DOC 22 | -STR 23 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/CFD4.tml: -------------------------------------------------------------------------------- 1 | === Empty implicit key in single pair flow sequences 2 | --- from: @perlpunk 3 | --- tags: empty-key flow sequence 4 | 5 | --- in-yaml(<) 6 | - [ : empty key ] 7 | - [: another empty key] 8 | 9 | --- out-yaml(<) 10 | - - : empty key 11 | - - : another empty key 12 | 13 | --- test-event 14 | +STR 15 | +DOC 16 | +SEQ 17 | +SEQ 18 | +MAP 19 | =VAL : 20 | =VAL :empty key 21 | -MAP 22 | -SEQ 23 | +SEQ 24 | +MAP 25 | =VAL : 26 | =VAL :another empty key 27 | -MAP 28 | -SEQ 29 | -SEQ 30 | -DOC 31 | -STR 32 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/DC7X.tml: -------------------------------------------------------------------------------- 1 | === Various trailing tabs 2 | --- from: @perlpunk 3 | --- tags: comment whitespace 4 | 5 | --- in-yaml 6 | a: b 7 | seq: 8 | - a 9 | c: d#X 10 | 11 | --- in-json 12 | { 13 | "a": "b", 14 | "seq": [ 15 | "a" 16 | ], 17 | "c": "d" 18 | } 19 | 20 | --- out-yaml 21 | a: b 22 | seq: 23 | - a 24 | c: d 25 | 26 | --- test-event 27 | +STR 28 | +DOC 29 | +MAP 30 | =VAL :a 31 | =VAL :b 32 | =VAL :seq 33 | +SEQ 34 | =VAL :a 35 | -SEQ 36 | =VAL :c 37 | =VAL :d 38 | -MAP 39 | -DOC 40 | -STR 41 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/WZ62.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.2. Empty Content 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2786720 3 | --- tags: spec flow scalar tag 4 | 5 | --- in-yaml 6 | { 7 | foo : !!str, 8 | !!str : bar, 9 | } 10 | 11 | --- in-json 12 | { 13 | "foo": "", 14 | "": "bar" 15 | } 16 | 17 | --- out-yaml 18 | foo: !!str 19 | !!str : bar 20 | 21 | --- test-event 22 | +STR 23 | +DOC 24 | +MAP 25 | =VAL :foo 26 | =VAL : 27 | =VAL : 28 | =VAL :bar 29 | -MAP 30 | -DOC 31 | -STR 32 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/4ABK.tml: -------------------------------------------------------------------------------- 1 | === Flow Mapping Separate Values 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2791704 3 | --- tags: flow mapping 4 | 5 | --- in-yaml 6 | { 7 | unquoted : "separate", 8 | http://foo.com, 9 | omitted value:, 10 | } 11 | 12 | --- out-yaml 13 | unquoted: "separate" 14 | http://foo.com: null 15 | omitted value: null 16 | 17 | --- test-event 18 | +STR 19 | +DOC 20 | +MAP 21 | =VAL :unquoted 22 | =VAL "separate 23 | =VAL :http://foo.com 24 | =VAL : 25 | =VAL :omitted value 26 | =VAL : 27 | -MAP 28 | -DOC 29 | -STR 30 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/LE5A.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.24. Flow Nodes 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2793490 3 | --- tags: spec tag alias 4 | 5 | --- in-yaml 6 | - !!str "a" 7 | - 'b' 8 | - &anchor "c" 9 | - *anchor 10 | - !!str 11 | 12 | --- in-json 13 | [ 14 | "a", 15 | "b", 16 | "c", 17 | "c", 18 | "" 19 | ] 20 | 21 | --- test-event 22 | +STR 23 | +DOC 24 | +SEQ 25 | =VAL "a 26 | =VAL 'b 27 | =VAL &anchor "c 28 | =ALI *anchor 29 | =VAL : 30 | -SEQ 31 | -DOC 32 | -STR 33 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/T5N4.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.7. Literal Scalar [1.3] 2 | --- from: M9B4, modified for YAML 1.3 3 | --- tags: spec literal scalar whitespace 1.3-mod 4 | 5 | --- in-yaml(<+) 6 | --- | 7 | literal 8 | text 9 | 10 | 11 | --- in-json 12 | "literal\n\ttext\n" 13 | 14 | --- out-yaml 15 | # XXX Should be literal? 16 | "literal\n\ttext\n" 17 | 18 | --- emit-yaml(<) 19 | --- | 20 | literal 21 | text 22 | 23 | --- test-event 24 | +STR 25 | +DOC --- 26 | =VAL |literal\n\ttext\n 27 | -DOC 28 | -STR 29 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6BFJ.tml: -------------------------------------------------------------------------------- 1 | === Mapping, key and flow sequence item anchors 2 | --- from: @perlpunk 3 | --- tags: anchor complex-key flow mapping sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | &mapping 8 | &key [ &item a, b, c ]: value 9 | 10 | --- out-yaml(<) 11 | --- &mapping 12 | ? &key 13 | - &item a 14 | - b 15 | - c 16 | : value 17 | 18 | --- test-event 19 | +STR 20 | +DOC --- 21 | +MAP &mapping 22 | +SEQ &key 23 | =VAL &item :a 24 | =VAL :b 25 | =VAL :c 26 | -SEQ 27 | =VAL :value 28 | -MAP 29 | -DOC 30 | -STR 31 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/SKE5.tml: -------------------------------------------------------------------------------- 1 | === Anchor before zero indented sequence 2 | --- from: @perlpunk 3 | --- tags: anchor indent sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | seq: 8 | &anchor 9 | - a 10 | - b 11 | 12 | --- in-json 13 | { 14 | "seq": [ 15 | "a", 16 | "b" 17 | ] 18 | } 19 | 20 | --- out-yaml(<) 21 | --- 22 | seq: &anchor 23 | - a 24 | - b 25 | 26 | --- test-event 27 | +STR 28 | +DOC --- 29 | +MAP 30 | =VAL :seq 31 | +SEQ &anchor 32 | =VAL :a 33 | =VAL :b 34 | -SEQ 35 | -MAP 36 | -DOC 37 | -STR 38 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/X38W.tml: -------------------------------------------------------------------------------- 1 | === Aliases in Flow Objects 2 | --- from: NimYAML tests 3 | --- tags: alias complex-key flow 4 | 5 | Anchors and aliases in flow collections. 6 | 7 | --- in-yaml 8 | { &a [a, &b b]: *b, *a : [c, *b, d]} 9 | 10 | --- out-yaml 11 | ? &a 12 | - a 13 | - &b b 14 | : *b 15 | *a : 16 | - c 17 | - *b 18 | - d 19 | 20 | --- test-event 21 | +STR 22 | +DOC 23 | +MAP 24 | +SEQ &a 25 | =VAL :a 26 | =VAL &b :b 27 | -SEQ 28 | =ALI *b 29 | =ALI *a 30 | +SEQ 31 | =VAL :c 32 | =ALI *b 33 | =VAL :d 34 | -SEQ 35 | -MAP 36 | -DOC 37 | -STR 38 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/Z9M4.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.22. Global Tag Prefix 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2783726 3 | --- tags: spec header tag unknown-tag 4 | 5 | --- in-yaml(<) 6 | %TAG !e! tag:example.com,2000:app/ 7 | --- 8 | - !e!foo "bar" 9 | 10 | --- out-yaml(<) 11 | --- 12 | - ! "bar" 13 | 14 | --- in-json(<) 15 | [ 16 | "bar" 17 | ] 18 | 19 | --- test-event 20 | +STR 21 | +DOC --- 22 | +SEQ 23 | =VAL "bar 24 | -SEQ 25 | -DOC 26 | -STR 27 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | update_release_draft: 10 | runs-on: ubuntu-latest 11 | steps: 12 | # Drafts your next Release notes as Pull Requests are merged into "main" 13 | - uses: release-drafter/release-drafter@v6 14 | # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml 15 | with: 16 | config-name: release-drafter-config.yml 17 | env: 18 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 19 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/MZX3.tml: -------------------------------------------------------------------------------- 1 | === Non-Specific Tags on Scalars 2 | --- from: NimYAML tests 3 | --- tags: folded scalar 4 | 5 | --- in-yaml 6 | - plain 7 | - "double quoted" 8 | - 'single quoted' 9 | - > 10 | block 11 | - plain again 12 | 13 | --- in-json 14 | [ 15 | "plain", 16 | "double quoted", 17 | "single quoted", 18 | "block\n", 19 | "plain again" 20 | ] 21 | 22 | --- test-event 23 | +STR 24 | +DOC 25 | +SEQ 26 | =VAL :plain 27 | =VAL "double quoted 28 | =VAL 'single quoted 29 | =VAL >block\n 30 | =VAL :plain again 31 | -SEQ 32 | -DOC 33 | -STR 34 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6M2F.tml: -------------------------------------------------------------------------------- 1 | === Aliases in Explicit Block Mapping 2 | --- from: NimYAML tests 3 | --- tags: alias explicit-key empty-key 4 | 5 | This test is showing a mapping with explicit keys, in which one pair is missing 6 | the key component. 7 | 8 | It also is testing an alias to a scalar anchored in an explicit key. 9 | 10 | --- in-yaml 11 | ? &a a 12 | : &b b 13 | : *a 14 | 15 | --- out-yaml 16 | &a a: &b b 17 | : *a 18 | 19 | --- test-event 20 | +STR 21 | +DOC 22 | +MAP 23 | =VAL &a :a 24 | =VAL &b :b 25 | =VAL : 26 | =ALI *a 27 | -MAP 28 | -DOC 29 | -STR 30 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/EHF6.tml: -------------------------------------------------------------------------------- 1 | === Tags for Flow Objects 2 | --- from: NimYAML tests 3 | --- tags: tag flow mapping sequence 4 | 5 | --- in-yaml 6 | !!map { 7 | k: !!seq 8 | [ a, !!str b] 9 | } 10 | 11 | --- in-json 12 | { 13 | "k": [ 14 | "a", 15 | "b" 16 | ] 17 | } 18 | 19 | --- out-yaml 20 | !!map 21 | k: !!seq 22 | - a 23 | - !!str b 24 | 25 | --- test-event 26 | +STR 27 | +DOC 28 | +MAP 29 | =VAL :k 30 | +SEQ 31 | =VAL :a 32 | =VAL :b 33 | -SEQ 34 | -MAP 35 | -DOC 36 | -STR 37 | -------------------------------------------------------------------------------- /project/plugin.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.14.5") 2 | 3 | addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.6") 4 | 5 | addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.11.2") 6 | 7 | addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2") 8 | 9 | addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2") 10 | 11 | addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.20.1") 12 | 13 | addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.9") 14 | 15 | addSbtPlugin("org.typelevel" % "sbt-typelevel-no-publish" % "0.8.4") 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # bloop and metals 2 | .bloop 3 | .bsp 4 | 5 | # metals 6 | project/metals.sbt 7 | .metals 8 | 9 | # vs code 10 | .vscode 11 | 12 | # scala 3 13 | .tasty 14 | 15 | # sbt 16 | project/project/ 17 | project/target/ 18 | target/ 19 | 20 | # intellij idea 21 | *.log 22 | *.iml 23 | *.ipr 24 | *.iws 25 | .idea 26 | 27 | # mac 28 | .DS_Store 29 | 30 | # other? 31 | .history 32 | .scala_dependencies 33 | .cache-main 34 | 35 | # scala worksheets 36 | *.sc 37 | 38 | # test files 39 | *.tml 40 | *.yaml 41 | tests/repositories/ 42 | 43 | #general 44 | *.class 45 | *.log 46 | 47 | generated-docs 48 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/HS5T.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.12. Plain Lines 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2789986 3 | --- tags: spec scalar whitespace upto-1.2 4 | 5 | --- in-yaml 6 | 1st non-empty 7 | 8 | 2nd non-empty 9 | 3rd non-empty 10 | 11 | --- in-json 12 | "1st non-empty\n2nd non-empty 3rd non-empty" 13 | 14 | --- out-yaml 15 | # XXX Should this be doublequote? 16 | '1st non-empty 17 | 18 | 2nd non-empty 3rd non-empty' 19 | 20 | --- test-event 21 | +STR 22 | +DOC 23 | =VAL :1st non-empty\n2nd non-empty 3rd non-empty 24 | -DOC 25 | -STR 26 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/ZWK4.tml: -------------------------------------------------------------------------------- 1 | === Key with anchor after missing explicit mapping value 2 | --- from: @perlpunk 3 | --- tags: anchor explicit-key mapping 4 | 5 | --- in-yaml(<) 6 | --- 7 | a: 1 8 | ? b 9 | &anchor c: 3 10 | 11 | --- in-json 12 | { 13 | "a": 1, 14 | "b": null, 15 | "c": 3 16 | } 17 | 18 | --- out-yaml(<) 19 | --- 20 | a: 1 21 | b: 22 | &anchor c: 3 23 | 24 | --- test-event 25 | +STR 26 | +DOC --- 27 | +MAP 28 | =VAL :a 29 | =VAL :1 30 | =VAL :b 31 | =VAL : 32 | =VAL &anchor :c 33 | =VAL :3 34 | -MAP 35 | -DOC 36 | -STR 37 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/33X3.tml: -------------------------------------------------------------------------------- 1 | === Three explicit integers in a block sequence 2 | --- from: IRC 3 | --- tags: sequence tag 4 | 5 | --- in-yaml(<) 6 | --- 7 | - !!int 1 8 | - !!int -2 9 | - !!int 33 10 | 11 | --- out-yaml(<) 12 | --- 13 | - !!int 1 14 | - !!int -2 15 | - !!int 33 16 | 17 | --- in-json 18 | [ 19 | 1, 20 | -2, 21 | 33 22 | ] 23 | 24 | --- test-event 25 | +STR 26 | +DOC --- 27 | +SEQ 28 | =VAL :1 29 | =VAL :-2 30 | =VAL :33 31 | -SEQ 32 | -DOC 33 | -STR 34 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/5TYM.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.21. Local Tag Prefix 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2783499 3 | --- tags: local-tag spec directive tag 4 | 5 | --- in-yaml(<) 6 | %TAG !m! !my- 7 | --- # Bulb here 8 | !m!light fluorescent 9 | ... 10 | %TAG !m! !my- 11 | --- # Color here 12 | !m!light green 13 | 14 | --- in-json(<) 15 | "fluorescent" 16 | "green" 17 | 18 | --- test-event 19 | +STR 20 | +DOC --- 21 | =VAL :fluorescent 22 | -DOC ... 23 | +DOC --- 24 | =VAL :green 25 | -DOC 26 | -STR 27 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/EX5H.tml: -------------------------------------------------------------------------------- 1 | === Multiline Scalar at Top Level [1.3] 2 | --- from: 9YRD, modified for YAML 1.3 3 | --- tags: scalar whitespace 1.3-mod 4 | 5 | --- in-yaml(<) 6 | --- 7 | a 8 | b 9 | c 10 | d 11 | 12 | e 13 | 14 | --- in-json 15 | "a b c d\ne" 16 | 17 | --- out-yaml 18 | # XXX This should emit as double quoted (opinion) 19 | # "a b c d\ne" 20 | 'a b c d 21 | 22 | e' 23 | 24 | --- emit-yaml(<) 25 | --- a b c d 26 | 27 | e 28 | 29 | --- test-event 30 | +STR 31 | +DOC --- 32 | =VAL :a b c d\ne 33 | -DOC 34 | -STR 35 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/RLU9.tml: -------------------------------------------------------------------------------- 1 | === Sequence Indent 2 | --- from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/indent.tml 3 | --- tags: sequence indent 4 | 5 | --- in-yaml 6 | foo: 7 | - 42 8 | bar: 9 | - 44 10 | 11 | --- in-json 12 | { 13 | "foo": [ 14 | 42 15 | ], 16 | "bar": [ 17 | 44 18 | ] 19 | } 20 | 21 | --- out-yaml 22 | foo: 23 | - 42 24 | bar: 25 | - 44 26 | 27 | --- test-event 28 | +STR 29 | +DOC 30 | +MAP 31 | =VAL :foo 32 | +SEQ 33 | =VAL :42 34 | -SEQ 35 | =VAL :bar 36 | +SEQ 37 | =VAL :44 38 | -SEQ 39 | -MAP 40 | -DOC 41 | -STR 42 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/ZK9H.tml: -------------------------------------------------------------------------------- 1 | === Nested top level flow mapping 2 | --- from: @perlpunk 3 | --- tags: flow indent mapping sequence 4 | 5 | --- in-yaml(<) 6 | { key: [[[ 7 | value 8 | ]]] 9 | } 10 | 11 | --- out-yaml(<) 12 | key: 13 | - - - value 14 | 15 | --- in-json 16 | { 17 | "key": [ 18 | [ 19 | [ 20 | "value" 21 | ] 22 | ] 23 | ] 24 | } 25 | 26 | --- test-event 27 | +STR 28 | +DOC 29 | +MAP 30 | =VAL :key 31 | +SEQ 32 | +SEQ 33 | +SEQ 34 | =VAL :value 35 | -SEQ 36 | -SEQ 37 | -SEQ 38 | -MAP 39 | -DOC 40 | -STR 41 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/HMQ5.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.23. Node Properties 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2783940 3 | --- tags: spec tag alias 4 | 5 | --- in-yaml 6 | !!str &a1 "foo": 7 | !!str bar 8 | &a2 baz : *a1 9 | 10 | --- in-json 11 | { 12 | "foo": "bar", 13 | "baz": "foo" 14 | } 15 | 16 | --- out-yaml 17 | &a1 !!str "foo": !!str bar 18 | &a2 baz: *a1 19 | 20 | --- test-event 21 | +STR 22 | +DOC 23 | +MAP 24 | =VAL &a1 "foo 25 | =VAL :bar 26 | =VAL &a2 :baz 27 | =ALI *a1 28 | -MAP 29 | -DOC 30 | -STR 31 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/S3PD.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.18. Implicit Block Mapping Entries 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2798896 3 | --- tags: empty-key spec mapping 4 | 5 | --- in-yaml 6 | plain key: in-line value 7 | : # Both empty 8 | "quoted key": 9 | - entry 10 | 11 | --- emit-yaml 12 | plain key: in-line value 13 | : 14 | "quoted key": 15 | - entry 16 | 17 | --- test-event 18 | +STR 19 | +DOC 20 | +MAP 21 | =VAL :plain key 22 | =VAL :in-line value 23 | =VAL : 24 | =VAL : 25 | =VAL "quoted key 26 | +SEQ 27 | =VAL :entry 28 | -SEQ 29 | -MAP 30 | -DOC 31 | -STR 32 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/CUP7.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 5.6. Node Property Indicators 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2773402 3 | --- tags: local-tag spec tag alias 4 | 5 | --- in-yaml 6 | anchored: !local &anchor value 7 | alias: *anchor 8 | 9 | --- in-json 10 | { 11 | "anchored": "value", 12 | "alias": "value" 13 | } 14 | 15 | --- out-yaml 16 | anchored: &anchor !local value 17 | alias: *anchor 18 | 19 | --- test-event 20 | +STR 21 | +DOC 22 | +MAP 23 | =VAL :anchored 24 | =VAL &anchor :value 25 | =VAL :alias 26 | =ALI *anchor 27 | -MAP 28 | -DOC 29 | -STR 30 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/D83L.tml: -------------------------------------------------------------------------------- 1 | === Block scalar indicator order 2 | --- from: @perlpunk 3 | --- tags: indent literal 4 | 5 | --- in-yaml 6 | - |2- 7 | explicit indent and chomp 8 | - |-2 9 | chomp and explicit indent 10 | 11 | --- in-json 12 | [ 13 | "explicit indent and chomp", 14 | "chomp and explicit indent" 15 | ] 16 | 17 | --- out-yaml 18 | - |- 19 | explicit indent and chomp 20 | - |- 21 | chomp and explicit indent 22 | 23 | --- test-event 24 | +STR 25 | +DOC 26 | +SEQ 27 | =VAL |explicit indent and chomp 28 | =VAL |chomp and explicit indent 29 | -SEQ 30 | -DOC 31 | -STR 32 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6CK3.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.26. Tag Shorthands 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2785009 3 | --- tags: spec tag local-tag 4 | 5 | --- in-yaml(<) 6 | %TAG !e! tag:example.com,2000:app/ 7 | --- 8 | - !local foo 9 | - !!str bar 10 | - !e!tag%21 baz 11 | 12 | --- in-json(<) 13 | [ 14 | "foo", 15 | "bar", 16 | "baz" 17 | ] 18 | 19 | --- test-event 20 | +STR 21 | +DOC --- 22 | +SEQ 23 | =VAL :foo 24 | =VAL :bar 25 | =VAL :baz 26 | -SEQ 27 | -DOC 28 | -STR 29 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/Z67P.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.21. Block Scalar Nodes [1.3] 2 | --- from: M5C3, modified for YAML 1.3 3 | --- tags: indent spec literal folded tag local-tag 1.3-mod 4 | 5 | --- in-yaml 6 | literal: |2 7 | value 8 | folded: !foo >1 9 | value 10 | 11 | --- in-json 12 | { 13 | "literal": "value\n", 14 | "folded": "value\n" 15 | } 16 | 17 | --- out-yaml 18 | literal: | 19 | value 20 | folded: !foo > 21 | value 22 | 23 | --- test-event 24 | +STR 25 | +DOC 26 | +MAP 27 | =VAL :literal 28 | =VAL |value\n 29 | =VAL :folded 30 | =VAL >value\n 31 | -MAP 32 | -DOC 33 | -STR 34 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6SLA.tml: -------------------------------------------------------------------------------- 1 | === Allowed characters in quoted mapping key 2 | --- from: @perlpunk 3 | --- tags: mapping single double 4 | 5 | --- in-yaml 6 | "foo\nbar:baz\tx \\$%^&*()x": 23 7 | 'x\ny:z\tx $%^&*()x': 24 8 | 9 | --- in-json 10 | { 11 | "foo\nbar:baz\tx \\$%^&*()x": 23, 12 | "x\\ny:z\\tx $%^&*()x": 24 13 | } 14 | 15 | --- out-yaml 16 | ? "foo\nbar:baz\tx \\$%^&*()x" 17 | : 23 18 | 'x\ny:z\tx $%^&*()x': 24 19 | 20 | --- test-event 21 | +STR 22 | +DOC 23 | +MAP 24 | =VAL "foo\nbar:baz\tx \\$%^&*()x 25 | =VAL :23 26 | =VAL 'x\\ny:z\\tx $%^&*()x 27 | =VAL :24 28 | -MAP 29 | -DOC 30 | -STR 31 | 32 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/SYW4.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.2. Mapping Scalars to Scalars 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2759963 3 | --- tags: spec scalar comment 4 | 5 | --- in-yaml 6 | hr: 65 # Home runs 7 | avg: 0.278 # Batting average 8 | rbi: 147 # Runs Batted In 9 | 10 | --- in-json 11 | { 12 | "hr": 65, 13 | "avg": 0.278, 14 | "rbi": 147 15 | } 16 | 17 | --- out-yaml 18 | hr: 65 19 | avg: 0.278 20 | rbi: 147 21 | 22 | --- test-event 23 | +STR 24 | +DOC 25 | +MAP 26 | =VAL :hr 27 | =VAL :65 28 | =VAL :avg 29 | =VAL :0.278 30 | =VAL :rbi 31 | =VAL :147 32 | -MAP 33 | -DOC 34 | -STR 35 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/NP9H.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.5. Double Quoted Line Breaks 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2787745 3 | --- tags: double spec scalar whitespace upto-1.2 4 | 5 | --- in-yaml 6 | "folded 7 | to a space, 8 | 9 | to a line feed, or \ 10 | \ non-content" 11 | 12 | --- in-json 13 | "folded to a space,\nto a line feed, or \t \tnon-content" 14 | 15 | --- out-yaml 16 | "folded to a space,\nto a line feed, or \t \tnon-content" 17 | 18 | --- test-event 19 | +STR 20 | +DOC 21 | =VAL "folded to a space,\nto a line feed, or \t \tnon-content 22 | -DOC 23 | -STR 24 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/5KJE.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.13. Flow Sequence 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2790506 3 | --- tags: spec flow sequence 4 | 5 | --- in-yaml 6 | - [ one, two, ] 7 | - [three ,four] 8 | 9 | --- in-json 10 | [ 11 | [ 12 | "one", 13 | "two" 14 | ], 15 | [ 16 | "three", 17 | "four" 18 | ] 19 | ] 20 | 21 | --- out-yaml 22 | - - one 23 | - two 24 | - - three 25 | - four 26 | 27 | --- test-event 28 | +STR 29 | +DOC 30 | +SEQ 31 | +SEQ 32 | =VAL :one 33 | =VAL :two 34 | -SEQ 35 | +SEQ 36 | =VAL :three 37 | =VAL :four 38 | -SEQ 39 | -SEQ 40 | -DOC 41 | -STR 42 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/FH7J.tml: -------------------------------------------------------------------------------- 1 | === Tags on Empty Scalars 2 | --- from: NimYAML tests 3 | --- tags: tag scalar 4 | 5 | --- in-yaml 6 | - !!str 7 | - 8 | !!null : a 9 | b: !!str 10 | - !!str : !!null 11 | 12 | --- out-yaml 13 | - !!str 14 | - !!null : a 15 | b: !!str 16 | - !!str : !!null 17 | 18 | --- test-event 19 | +STR 20 | +DOC 21 | +SEQ 22 | =VAL : 23 | +MAP 24 | =VAL : 25 | =VAL :a 26 | =VAL :b 27 | =VAL : 28 | -MAP 29 | +MAP 30 | =VAL : 31 | =VAL : 32 | -MAP 33 | -SEQ 34 | -DOC 35 | -STR 36 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/96L6.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.14. In the folded scalars, newlines become spaces 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2761032 3 | --- tags: spec folded scalar 4 | 5 | --- in-yaml(<) 6 | --- > 7 | Mark McGwire's 8 | year was crippled 9 | by a knee injury. 10 | 11 | --- in-json 12 | "Mark McGwire's year was crippled by a knee injury.\n" 13 | 14 | --- out-yaml(<) 15 | --- > 16 | Mark McGwire's year was crippled by a knee injury. 17 | 18 | --- test-event 19 | +STR 20 | +DOC --- 21 | =VAL >Mark McGwire's year was crippled by a knee injury.\n 22 | -DOC 23 | -STR 24 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/DWX9.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.8. Literal Content 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2796118 3 | --- tags: spec literal scalar comment whitespace 1.3-err 4 | 5 | --- in-yaml 6 | | 7 | 8 | 9 | literal 10 | 11 | 12 | text 13 | 14 | # Comment 15 | 16 | --- in-json 17 | "\n\nliteral\n \n\ntext\n" 18 | 19 | --- out-yaml 20 | "\n\nliteral\n \n\ntext\n" 21 | 22 | --- emit-yaml 23 | | 24 | 25 | 26 | literal 27 | 28 | 29 | text 30 | 31 | --- test-event 32 | +STR 33 | +DOC 34 | =VAL |\n\nliteral\n \n\ntext\n 35 | -DOC 36 | -STR 37 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/M5C3.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.21. Block Scalar Nodes 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2799693 3 | --- tags: indent spec literal folded tag local-tag 1.3-err 4 | 5 | --- in-yaml 6 | literal: |2 7 | value 8 | folded: 9 | !foo 10 | >1 11 | value 12 | 13 | --- in-json 14 | { 15 | "literal": "value\n", 16 | "folded": "value\n" 17 | } 18 | 19 | --- out-yaml 20 | literal: | 21 | value 22 | folded: !foo > 23 | value 24 | 25 | --- test-event 26 | +STR 27 | +DOC 28 | +MAP 29 | =VAL :literal 30 | =VAL |value\n 31 | =VAL :folded 32 | =VAL >value\n 33 | -MAP 34 | -DOC 35 | -STR 36 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/5BVJ.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 5.7. Block Scalar Indicators 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2773653 3 | --- tags: spec literal folded scalar 4 | 5 | --- in-yaml 6 | literal: | 7 | some 8 | text 9 | folded: > 10 | some 11 | text 12 | 13 | --- in-json 14 | { 15 | "literal": "some\ntext\n", 16 | "folded": "some text\n" 17 | } 18 | 19 | --- out-yaml 20 | literal: | 21 | some 22 | text 23 | folded: > 24 | some text 25 | 26 | --- test-event 27 | +STR 28 | +DOC 29 | +MAP 30 | =VAL :literal 31 | =VAL |some\ntext\n 32 | =VAL :folded 33 | =VAL >some text\n 34 | -MAP 35 | -DOC 36 | -STR 37 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/UT92.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 9.4. Explicit Documents 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2801448 3 | --- tags: flow spec header footer comment 4 | 5 | --- in-yaml(<) 6 | --- 7 | { matches 8 | % : 20 } 9 | ... 10 | --- 11 | # Empty 12 | ... 13 | 14 | --- in-json 15 | { 16 | "matches %": 20 17 | } 18 | null 19 | 20 | --- out-yaml(<) 21 | --- 22 | matches %: 20 23 | ... 24 | --- 25 | ... 26 | 27 | --- test-event 28 | +STR 29 | +DOC --- 30 | +MAP 31 | =VAL :matches % 32 | =VAL :20 33 | -MAP 34 | -DOC ... 35 | +DOC --- 36 | =VAL : 37 | -DOC ... 38 | -STR 39 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/JQ4R.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.14. Block Sequence 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2797596 3 | --- tags: mapping spec sequence 4 | 5 | --- in-yaml 6 | block sequence: 7 | - one 8 | - two : three 9 | 10 | --- in-json 11 | { 12 | "block sequence": [ 13 | "one", 14 | { 15 | "two": "three" 16 | } 17 | ] 18 | } 19 | 20 | --- out-yaml 21 | block sequence: 22 | - one 23 | - two: three 24 | 25 | --- test-event 26 | +STR 27 | +DOC 28 | +MAP 29 | =VAL :block sequence 30 | +SEQ 31 | =VAL :one 32 | +MAP 33 | =VAL :two 34 | =VAL :three 35 | -MAP 36 | -SEQ 37 | -MAP 38 | -DOC 39 | -STR 40 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/C2DT.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.18. Flow Mapping Adjacent Values 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2792073 3 | --- tags: spec flow mapping 4 | 5 | --- in-yaml 6 | { 7 | "adjacent":value, 8 | "readable": value, 9 | "empty": 10 | } 11 | 12 | --- in-json 13 | { 14 | "adjacent": "value", 15 | "readable": "value", 16 | "empty": null 17 | } 18 | 19 | --- out-yaml 20 | "adjacent": value 21 | "readable": value 22 | "empty": 23 | 24 | --- test-event 25 | +STR 26 | +DOC 27 | +MAP 28 | =VAL "adjacent 29 | =VAL :value 30 | =VAL "readable 31 | =VAL :value 32 | =VAL "empty 33 | =VAL : 34 | -MAP 35 | -DOC 36 | -STR 37 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/F2C7.tml: -------------------------------------------------------------------------------- 1 | === Anchors and Tags 2 | --- from: NimYAML tests 3 | --- tags: anchor tag 4 | 5 | This test show all the possible orders of properties (anchors and tags). 6 | 7 | --- in-yaml 8 | - &a !!str a 9 | - !!int 2 10 | - !!int &c 4 11 | - &d d 12 | 13 | --- in-json 14 | [ 15 | "a", 16 | 2, 17 | 4, 18 | "d" 19 | ] 20 | 21 | --- out-yaml 22 | - &a !!str a 23 | - !!int 2 24 | - &c !!int 4 25 | - &d d 26 | 27 | --- test-event 28 | +STR 29 | +DOC 30 | +SEQ 31 | =VAL &a :a 32 | =VAL :2 33 | =VAL &c :4 34 | =VAL &d :d 35 | -SEQ 36 | -DOC 37 | -STR 38 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9TFX.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.6. Double Quoted Lines [1.3] 2 | --- from: 7A4E, modified for YAML 1.3 3 | --- tags: double spec scalar whitespace 1.3-mod 4 | 5 | --- in-yaml(<) 6 | --- 7 | " 1st non-empty 8 | 9 | 2nd non-empty 10 | 3rd non-empty " 11 | 12 | --- in-json 13 | " 1st non-empty\n2nd non-empty 3rd non-empty " 14 | 15 | --- out-yaml 16 | " 1st non-empty\n2nd non-empty 3rd non-empty " 17 | 18 | --- emit-yaml(<) 19 | --- " 1st non-empty\n2nd non-empty 3rd non-empty " 20 | 21 | --- test-event 22 | +STR 23 | +DOC --- 24 | =VAL " 1st non-empty\n2nd non-empty 3rd non-empty 25 | -DOC 26 | -STR 27 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/PRH3.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.9. Single Quoted Lines 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2788756 3 | --- tags: single spec scalar whitespace upto-1.2 4 | 5 | --- in-yaml 6 | ' 1st non-empty 7 | 8 | 2nd non-empty 9 | 3rd non-empty ' 10 | 11 | --- in-json 12 | " 1st non-empty\n2nd non-empty 3rd non-empty " 13 | 14 | --- out-yaml 15 | ' 1st non-empty 16 | 17 | 2nd non-empty 3rd non-empty ' 18 | 19 | --- emit-yaml 20 | ' 1st non-empty 21 | 22 | 2nd non-empty 3rd non-empty ' 23 | 24 | --- test-event 25 | +STR 26 | +DOC 27 | =VAL ' 1st non-empty\n2nd non-empty 3rd non-empty 28 | -DOC 29 | -STR 30 | -------------------------------------------------------------------------------- /core/shared/src/main/scala-2/org/virtuslab/yaml/syntax/YamlPrimitiveCrossCompat.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml 2 | package syntax 3 | 4 | import Node._ 5 | 6 | private[yaml] trait YamlPrimitiveCompanionCrossCompat { 7 | implicit def fromString(s: String): YamlPrimitive = YamlPrimitive(ScalarNode(s.toString)) 8 | implicit def fromBoolean(s: Boolean): YamlPrimitive = YamlPrimitive(ScalarNode(s.toString)) 9 | implicit def fromInt(s: Int): YamlPrimitive = YamlPrimitive(ScalarNode(s.toString)) 10 | implicit def fromLong(s: Long): YamlPrimitive = YamlPrimitive(ScalarNode(s.toString)) 11 | implicit def fromNode(s: Node): YamlPrimitive = YamlPrimitive(s) 12 | } 13 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/A6F9.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.4. Chomping Final Line Break 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2795034 3 | --- tags: spec literal scalar 4 | 5 | --- in-yaml 6 | strip: |- 7 | text 8 | clip: | 9 | text 10 | keep: |+ 11 | text 12 | 13 | --- in-json 14 | { 15 | "strip": "text", 16 | "clip": "text\n", 17 | "keep": "text\n" 18 | } 19 | 20 | --- out-yaml 21 | strip: |- 22 | text 23 | clip: | 24 | text 25 | keep: | 26 | text 27 | 28 | --- test-event 29 | +STR 30 | +DOC 31 | +MAP 32 | =VAL :strip 33 | =VAL |text 34 | =VAL :clip 35 | =VAL |text\n 36 | =VAL :keep 37 | =VAL |text\n 38 | -MAP 39 | -DOC 40 | -STR 41 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/93JH.tml: -------------------------------------------------------------------------------- 1 | === Block Mappings in Block Sequence 2 | --- from: NimYAML tests 3 | --- tags: mapping sequence 4 | 5 | --- in-yaml 6 | - key: value 7 | key2: value2 8 | - 9 | key3: value3 10 | 11 | --- in-json 12 | [ 13 | { 14 | "key": "value", 15 | "key2": "value2" 16 | }, 17 | { 18 | "key3": "value3" 19 | } 20 | ] 21 | 22 | --- out-yaml 23 | - key: value 24 | key2: value2 25 | - key3: value3 26 | 27 | --- test-event 28 | +STR 29 | +DOC 30 | +SEQ 31 | +MAP 32 | =VAL :key 33 | =VAL :value 34 | =VAL :key2 35 | =VAL :value2 36 | -MAP 37 | +MAP 38 | =VAL :key3 39 | =VAL :value3 40 | -MAP 41 | -SEQ 42 | -DOC 43 | -STR 44 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/NJ66.tml: -------------------------------------------------------------------------------- 1 | === Multiline plain flow mapping key 2 | --- from: @perlpunk 3 | --- tags: flow mapping 4 | 5 | --- in-yaml(<) 6 | --- 7 | - { single line: value} 8 | - { multi 9 | line: value} 10 | 11 | --- out-yaml(<) 12 | --- 13 | - single line: value 14 | - multi line: value 15 | 16 | --- in-json 17 | [ 18 | { 19 | "single line": "value" 20 | }, 21 | { 22 | "multi line": "value" 23 | } 24 | ] 25 | 26 | --- test-event 27 | +STR 28 | +DOC --- 29 | +SEQ 30 | +MAP 31 | =VAL :single line 32 | =VAL :value 33 | -MAP 34 | +MAP 35 | =VAL :multi line 36 | =VAL :value 37 | -MAP 38 | -SEQ 39 | -DOC 40 | -STR 41 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/5T43.tml: -------------------------------------------------------------------------------- 1 | === Colon at the beginning of adjacent flow scalar 2 | --- from: @perlpunk 3 | --- tags: flow mapping scalar 4 | 5 | --- in-yaml(<) 6 | - { "key":value } 7 | - { "key"::value } 8 | 9 | --- emit-yaml(<) 10 | - "key": value 11 | - "key": :value 12 | 13 | --- out-yaml(<) 14 | - key: value 15 | - key: :value 16 | 17 | --- in-json 18 | [ 19 | { 20 | "key": "value" 21 | }, 22 | { 23 | "key": ":value" 24 | } 25 | ] 26 | 27 | --- test-event 28 | +STR 29 | +DOC 30 | +SEQ 31 | +MAP 32 | =VAL "key 33 | =VAL :value 34 | -MAP 35 | +MAP 36 | =VAL "key 37 | =VAL ::value 38 | -MAP 39 | -SEQ 40 | -DOC 41 | -STR 42 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/L9U5.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.11. Plain Implicit Keys 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2789794 3 | --- tags: spec flow mapping 4 | 5 | --- in-yaml 6 | implicit block key : [ 7 | implicit flow key : value, 8 | ] 9 | 10 | --- in-json 11 | { 12 | "implicit block key": [ 13 | { 14 | "implicit flow key": "value" 15 | } 16 | ] 17 | } 18 | 19 | --- out-yaml 20 | implicit block key: 21 | - implicit flow key: value 22 | 23 | --- test-event 24 | +STR 25 | +DOC 26 | +MAP 27 | =VAL :implicit block key 28 | +SEQ 29 | +MAP 30 | =VAL :implicit flow key 31 | =VAL :value 32 | -MAP 33 | -SEQ 34 | -MAP 35 | -DOC 36 | -STR 37 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/4FJ6.tml: -------------------------------------------------------------------------------- 1 | === Nested implicit complex keys 2 | --- from: @perlpunk 3 | --- tags: complex-key flow mapping sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | [ 8 | [ a, [ [[b,c]]: d, e]]: 23 9 | ] 10 | 11 | --- out-yaml(<) 12 | --- 13 | - ? - a 14 | - - ? - - b 15 | - c 16 | : d 17 | - e 18 | : 23 19 | 20 | --- test-event 21 | +STR 22 | +DOC --- 23 | +SEQ 24 | +MAP 25 | +SEQ 26 | =VAL :a 27 | +SEQ 28 | +MAP 29 | +SEQ 30 | +SEQ 31 | =VAL :b 32 | =VAL :c 33 | -SEQ 34 | -SEQ 35 | =VAL :d 36 | -MAP 37 | =VAL :e 38 | -SEQ 39 | -SEQ 40 | =VAL :23 41 | -MAP 42 | -SEQ 43 | -DOC 44 | -STR 45 | -------------------------------------------------------------------------------- /core/shared/src/main/scala/org/virtuslab/yaml/Range.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml 2 | 3 | final case class Position( 4 | offset: Int, 5 | line: Int, 6 | column: Int 7 | ) 8 | 9 | final case class Range( 10 | start: Position, 11 | input: Vector[String], 12 | end: Option[Position] = None 13 | ) { 14 | def errorMsg: String = { 15 | val msg = input(start.line) 16 | val spaces = start.column 17 | s"""|$msg 18 | |${" " * spaces}^""".stripMargin 19 | } 20 | 21 | def withEndPos(end: Position): Range = 22 | copy( 23 | end = Some(end) 24 | ) 25 | 26 | def show: String = s"Position(${start.line}, ${start.column}), offset ${start.offset}" 27 | } 28 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/T4YY.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.9. Single Quoted Lines [1.3] 2 | --- from: PRH3, modified for YAML 1.3 3 | --- tags: single spec scalar whitespace 1.3-mod 4 | 5 | --- in-yaml(<) 6 | --- 7 | ' 1st non-empty 8 | 9 | 2nd non-empty 10 | 3rd non-empty ' 11 | 12 | --- in-json 13 | " 1st non-empty\n2nd non-empty 3rd non-empty " 14 | 15 | --- out-yaml 16 | ' 1st non-empty 17 | 18 | 2nd non-empty 3rd non-empty ' 19 | 20 | --- emit-yaml(<) 21 | --- ' 1st non-empty 22 | 23 | 2nd non-empty 3rd non-empty ' 24 | 25 | --- test-event 26 | +STR 27 | +DOC --- 28 | =VAL ' 1st non-empty\n2nd non-empty 3rd non-empty 29 | -DOC 30 | -STR 31 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9WXW.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.18. Primary Tag Handle 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2782728 3 | --- tags: local-tag spec directive tag unknown-tag 1.3-err 4 | 5 | --- in-yaml(<) 6 | # Private 7 | !foo "bar" 8 | ... 9 | # Global 10 | %TAG ! tag:example.com,2000:app/ 11 | --- 12 | !foo "bar" 13 | 14 | --- out-yaml(<) 15 | !foo "bar" 16 | ... 17 | --- ! "bar" 18 | 19 | --- in-json(<) 20 | "bar" 21 | "bar" 22 | 23 | --- test-event 24 | +STR 25 | +DOC 26 | =VAL "bar 27 | -DOC ... 28 | +DOC --- 29 | =VAL "bar 30 | -DOC 31 | -STR 32 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/LQZ7.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.4. Double Quoted Implicit Keys 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2787420 3 | --- tags: spec scalar flow 4 | 5 | --- in-yaml 6 | "implicit block key" : [ 7 | "implicit flow key" : value, 8 | ] 9 | 10 | --- in-json 11 | { 12 | "implicit block key": [ 13 | { 14 | "implicit flow key": "value" 15 | } 16 | ] 17 | } 18 | 19 | --- out-yaml 20 | "implicit block key": 21 | - "implicit flow key": value 22 | 23 | --- test-event 24 | +STR 25 | +DOC 26 | +MAP 27 | =VAL "implicit block key 28 | +SEQ 29 | +MAP 30 | =VAL "implicit flow key 31 | =VAL :value 32 | -MAP 33 | -SEQ 34 | -MAP 35 | -DOC 36 | -STR 37 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/T26H.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.8. Literal Content [1.3] 2 | --- from: DWX9, modified for YAML 1.3 3 | --- tags: spec literal scalar comment whitespace 1.3-mod 4 | 5 | --- in-yaml(<) 6 | --- | 7 | 8 | 9 | literal 10 | 11 | 12 | text 13 | 14 | # Comment 15 | 16 | --- in-json 17 | "\n\nliteral\n \n\ntext\n" 18 | 19 | --- out-yaml 20 | "\n\nliteral\n \n\ntext\n" 21 | 22 | --- emit-yaml(<) 23 | --- | 24 | 25 | 26 | literal 27 | 28 | 29 | text 30 | 31 | --- test-event 32 | +STR 33 | +DOC --- 34 | =VAL |\n\nliteral\n \n\ntext\n 35 | -DOC 36 | -STR 37 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9FMG.tml: -------------------------------------------------------------------------------- 1 | === Multi-level Mapping Indent 2 | --- from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/indent.tml 3 | --- tags: mapping indent 4 | 5 | --- in-yaml 6 | a: 7 | b: 8 | c: d 9 | e: 10 | f: g 11 | h: i 12 | 13 | --- in-json 14 | { 15 | "a": { 16 | "b": { 17 | "c": "d" 18 | }, 19 | "e": { 20 | "f": "g" 21 | } 22 | }, 23 | "h": "i" 24 | } 25 | 26 | --- test-event 27 | +STR 28 | +DOC 29 | +MAP 30 | =VAL :a 31 | +MAP 32 | =VAL :b 33 | +MAP 34 | =VAL :c 35 | =VAL :d 36 | -MAP 37 | =VAL :e 38 | +MAP 39 | =VAL :f 40 | =VAL :g 41 | -MAP 42 | -MAP 43 | =VAL :h 44 | =VAL :i 45 | -MAP 46 | -DOC 47 | -STR 48 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9SA2.tml: -------------------------------------------------------------------------------- 1 | === Multiline double quoted flow mapping key 2 | --- from: @perlpunk 3 | --- tags: double flow mapping 4 | 5 | --- in-yaml(<) 6 | --- 7 | - { "single line": value} 8 | - { "multi 9 | line": value} 10 | 11 | --- out-yaml(<) 12 | --- 13 | - "single line": value 14 | - "multi line": value 15 | 16 | --- in-json 17 | [ 18 | { 19 | "single line": "value" 20 | }, 21 | { 22 | "multi line": "value" 23 | } 24 | ] 25 | 26 | --- test-event 27 | +STR 28 | +DOC --- 29 | +SEQ 30 | +MAP 31 | =VAL "single line 32 | =VAL :value 33 | -MAP 34 | +MAP 35 | =VAL "multi line 36 | =VAL :value 37 | -MAP 38 | -SEQ 39 | -DOC 40 | -STR 41 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/2SXE.tml: -------------------------------------------------------------------------------- 1 | === Anchors With Colon in Name 2 | --- from: Mailing List Discussion 3 | --- tags: alias edge mapping 1.3-err 4 | 5 | This test is showing that a colon in an anchor (allowed in 1.2) can look like a 6 | mapping separator. In 1.3 we we propose to not allow `:` or other punctation in 7 | anchors. See [[rfc 3]]. 8 | 9 | --- in-yaml 10 | &a: key: &a value 11 | foo: 12 | *a: 13 | 14 | --- in-json 15 | { 16 | "key": "value", 17 | "foo": "key" 18 | } 19 | 20 | --- out-yaml 21 | &a: key: &a value 22 | foo: *a: 23 | 24 | --- test-event 25 | +STR 26 | +DOC 27 | +MAP 28 | =VAL &a: :key 29 | =VAL &a :value 30 | =VAL :foo 31 | =ALI *a: 32 | -MAP 33 | -DOC 34 | -STR 35 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6BCT.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.3. Separation Spaces 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2778394 3 | --- tags: spec libyaml-err sequence whitespace upto-1.2 4 | 5 | --- in-yaml 6 | # XXX Why are tabs allowed as indentation after dash? 7 | - foo: bar 8 | - - baz 9 | -baz 10 | 11 | --- in-json 12 | [ 13 | { 14 | "foo": "bar" 15 | }, 16 | [ 17 | "baz", 18 | "baz" 19 | ] 20 | ] 21 | 22 | --- out-yaml 23 | - foo: bar 24 | - - baz 25 | - baz 26 | 27 | --- test-event 28 | +STR 29 | +DOC 30 | +SEQ 31 | +MAP 32 | =VAL :foo 33 | =VAL :bar 34 | -MAP 35 | +SEQ 36 | =VAL :baz 37 | =VAL :baz 38 | -SEQ 39 | -SEQ 40 | -DOC 41 | -STR 42 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/87E4.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.8. Single Quoted Implicit Keys 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2788496 3 | --- tags: spec flow sequence mapping 4 | 5 | --- in-yaml 6 | 'implicit block key' : [ 7 | 'implicit flow key' : value, 8 | ] 9 | 10 | --- in-json 11 | { 12 | "implicit block key": [ 13 | { 14 | "implicit flow key": "value" 15 | } 16 | ] 17 | } 18 | 19 | --- out-yaml 20 | 'implicit block key': 21 | - 'implicit flow key': value 22 | 23 | --- test-event 24 | +STR 25 | +DOC 26 | +MAP 27 | =VAL 'implicit block key 28 | +SEQ 29 | +MAP 30 | =VAL 'implicit flow key 31 | =VAL :value 32 | -MAP 33 | -SEQ 34 | -MAP 35 | -DOC 36 | -STR 37 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/W4TN.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 9.5. Directives Documents 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2801606 3 | --- tags: spec header footer 1.3-err 4 | 5 | --- in-yaml(<) 6 | %YAML 1.2 7 | --- | 8 | %!PS-Adobe-2.0 9 | ... 10 | %YAML 1.2 11 | # see also https://github.com/yaml/yaml-test-suite/issues/34 12 | --- 13 | # Empty 14 | ... 15 | 16 | --- in-json 17 | "%!PS-Adobe-2.0\n" 18 | null 19 | 20 | --- out-yaml(<) 21 | --- | 22 | %!PS-Adobe-2.0 23 | ... 24 | --- 25 | ... 26 | 27 | --- test-event 28 | +STR 29 | +DOC --- 30 | =VAL |%!PS-Adobe-2.0\n 31 | -DOC ... 32 | +DOC --- 33 | =VAL : 34 | -DOC ... 35 | -STR 36 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/K858.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.6. Empty Scalar Chomping 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2795596 3 | --- tags: spec folded literal whitespace 4 | 5 | --- in-yaml(+) 6 | strip: >- 7 | 8 | clip: > 9 | 10 | keep: |+ 11 | 12 | --- in-json 13 | { 14 | "strip": "", 15 | "clip": "", 16 | "keep": "\n" 17 | } 18 | 19 | --- out-yaml 20 | # XXX empty string should emit as '' 21 | strip: "" 22 | clip: "" 23 | # XXX why is libyaml emitting 2 (or literal at all) 24 | keep: |2+ 25 | 26 | ... 27 | 28 | --- test-event 29 | +STR 30 | +DOC 31 | +MAP 32 | =VAL :strip 33 | =VAL > 34 | =VAL :clip 35 | =VAL > 36 | =VAL :keep 37 | =VAL |\n 38 | -MAP 39 | -DOC 40 | -STR 41 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6JWB.tml: -------------------------------------------------------------------------------- 1 | === Tags for Block Objects 2 | --- from: NimYAML tests 3 | --- tags: mapping sequence tag 4 | 5 | --- in-yaml 6 | foo: !!seq 7 | - !!str a 8 | - !!map 9 | key: !!str value 10 | 11 | --- in-json 12 | { 13 | "foo": [ 14 | "a", 15 | { 16 | "key": "value" 17 | } 18 | ] 19 | } 20 | 21 | --- out-yaml 22 | foo: !!seq 23 | - !!str a 24 | - !!map 25 | key: !!str value 26 | 27 | --- test-event 28 | +STR 29 | +DOC 30 | +MAP 31 | =VAL :foo 32 | +SEQ 33 | =VAL :a 34 | +MAP 35 | =VAL :key 36 | =VAL :value 37 | -MAP 38 | -SEQ 39 | -MAP 40 | -DOC 41 | -STR 42 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6ZKB.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 9.6. Stream 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2801896 3 | --- tags: spec header 1.3-err 4 | 5 | --- in-yaml(<) 6 | Document 7 | --- 8 | # Empty 9 | ... 10 | %YAML 1.2 11 | --- 12 | matches %: 20 13 | 14 | --- in-json 15 | "Document" 16 | null 17 | { 18 | "matches %": 20 19 | } 20 | 21 | --- emit-yaml(<) 22 | Document 23 | --- 24 | ... 25 | %YAML 1.2 26 | --- 27 | matches %: 20 28 | 29 | --- test-event 30 | +STR 31 | +DOC 32 | =VAL :Document 33 | -DOC 34 | +DOC --- 35 | =VAL : 36 | -DOC ... 37 | +DOC --- 38 | +MAP 39 | =VAL :matches % 40 | =VAL :20 41 | -MAP 42 | -DOC 43 | -STR 44 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/Q88A.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.23. Flow Content 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2793163 3 | --- tags: spec flow sequence mapping 4 | 5 | --- in-yaml 6 | - [ a, b ] 7 | - { a: b } 8 | - "a" 9 | - 'b' 10 | - c 11 | 12 | --- in-json 13 | [ 14 | [ 15 | "a", 16 | "b" 17 | ], 18 | { 19 | "a": "b" 20 | }, 21 | "a", 22 | "b", 23 | "c" 24 | ] 25 | 26 | --- out-yaml 27 | - - a 28 | - b 29 | - a: b 30 | - "a" 31 | - 'b' 32 | - c 33 | 34 | --- test-event 35 | +STR 36 | +DOC 37 | +SEQ 38 | +SEQ 39 | =VAL :a 40 | =VAL :b 41 | -SEQ 42 | +MAP 43 | =VAL :a 44 | =VAL :b 45 | -MAP 46 | =VAL "a 47 | =VAL 'b 48 | =VAL :c 49 | -SEQ 50 | -DOC 51 | -STR 52 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/A2M4.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.2. Indentation Indicators 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2778101 3 | --- tags: explicit-key spec libyaml-err indent whitespace sequence upto-1.2 4 | 5 | --- in-yaml 6 | # XXX Why are tabs allowed as indentation after dash? 7 | ? a 8 | : -b 9 | - -c 10 | - d 11 | 12 | --- in-json 13 | { 14 | "a": [ 15 | "b", 16 | [ 17 | "c", 18 | "d" 19 | ] 20 | ] 21 | } 22 | 23 | --- out-yaml 24 | a: 25 | - b 26 | - - c 27 | - d 28 | 29 | --- test-event 30 | +STR 31 | +DOC 32 | +MAP 33 | =VAL :a 34 | +SEQ 35 | =VAL :b 36 | +SEQ 37 | =VAL :c 38 | =VAL :d 39 | -SEQ 40 | -SEQ 41 | -MAP 42 | -DOC 43 | -STR 44 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/BU8L.tml: -------------------------------------------------------------------------------- 1 | === Node Anchor and Tag on Seperate Lines 2 | --- from: https://gist.github.com/anonymous/f192e7dab6da31831f264dbf1947cb83 via @ingydotnet 3 | --- tags: anchor indent 1.3-err tag 4 | 5 | This test is showing node properties spread over multiple lines. 6 | 7 | This is an error in 1.3 [[RFC 10]]. 8 | 9 | --- in-yaml 10 | key: &anchor 11 | !!map 12 | a: b 13 | 14 | --- in-json 15 | { 16 | "key": { 17 | "a": "b" 18 | } 19 | } 20 | 21 | --- out-yaml 22 | key: &anchor !!map 23 | a: b 24 | 25 | --- test-event 26 | +STR 27 | +DOC 28 | +MAP 29 | =VAL :key 30 | +MAP &anchor 31 | =VAL :a 32 | =VAL :b 33 | -MAP 34 | -MAP 35 | -DOC 36 | -STR 37 | 38 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/Q9WF.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.12. Separation Spaces 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2780989 3 | --- tags: complex-key flow spec comment whitespace 1.3-err 4 | 5 | --- in-yaml(<) 6 | { first: Sammy, last: Sosa }: 7 | # Statistics: 8 | hr: # Home runs 9 | 65 10 | avg: # Average 11 | 0.278 12 | 13 | --- out-yaml 14 | ? first: Sammy 15 | last: Sosa 16 | : hr: 65 17 | avg: 0.278 18 | 19 | --- test-event 20 | +STR 21 | +DOC 22 | +MAP 23 | +MAP 24 | =VAL :first 25 | =VAL :Sammy 26 | =VAL :last 27 | =VAL :Sosa 28 | -MAP 29 | +MAP 30 | =VAL :hr 31 | =VAL :65 32 | =VAL :avg 33 | =VAL :0.278 34 | -MAP 35 | -MAP 36 | -DOC 37 | -STR 38 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/F3CP.tml: -------------------------------------------------------------------------------- 1 | === Nested flow collections on one line 2 | --- from: @perlpunk 3 | --- tags: flow mapping sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | { a: [b, c, { d: [e, f] } ] } 8 | 9 | --- in-json 10 | { 11 | "a": [ 12 | "b", 13 | "c", 14 | { 15 | "d": [ 16 | "e", 17 | "f" 18 | ] 19 | } 20 | ] 21 | } 22 | 23 | --- out-yaml(<) 24 | --- 25 | a: 26 | - b 27 | - c 28 | - d: 29 | - e 30 | - f 31 | 32 | --- test-event 33 | +STR 34 | +DOC --- 35 | +MAP 36 | =VAL :a 37 | +SEQ 38 | =VAL :b 39 | =VAL :c 40 | +MAP 41 | =VAL :d 42 | +SEQ 43 | =VAL :e 44 | =VAL :f 45 | -SEQ 46 | -MAP 47 | -SEQ 48 | -MAP 49 | -DOC 50 | -STR 51 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/FQ7F.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.1. Sequence of Scalars 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2759963 3 | --- tags: spec sequence 4 | 5 | --- in-yaml 6 | - Mark McGwire 7 | - Sammy Sosa 8 | - Ken Griffey 9 | 10 | --- in-json 11 | [ 12 | "Mark McGwire", 13 | "Sammy Sosa", 14 | "Ken Griffey" 15 | ] 16 | 17 | --- test-event 18 | +STR 19 | +DOC 20 | +SEQ 21 | =VAL :Mark McGwire 22 | =VAL :Sammy Sosa 23 | =VAL :Ken Griffey 24 | -SEQ 25 | -DOC 26 | -STR 27 | 28 | --- lex-token 29 | SEQ-MARK 0 1 1 1 30 | WS-SPACE 1 1 1 2 31 | TEXT-VAL 2 12 1 3 :Mark McGwire 32 | WS-NEWLN 14 1 1 15 33 | SEQ-MARK 15 1 2 1 34 | WS-SPACE 1 1 1 2 35 | TEXT-VAL 2 12 1 3 :Sammy Sosa 36 | WS-NEWLN 14 1 1 15 37 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/KSS4.tml: -------------------------------------------------------------------------------- 1 | === Scalars on --- line 2 | --- from: @perlpunk 3 | --- tags: anchor header scalar 1.3-err 4 | 5 | Testing top level scalars with headers. 6 | 7 | This would fail in 1.3 due to [[RFC 2]] which does not allow content on header 8 | lines. 9 | 10 | --- in-yaml(<) 11 | --- "quoted 12 | string" 13 | --- &node foo 14 | 15 | --- in-json 16 | "quoted string" 17 | "foo" 18 | 19 | --- out-yaml(<) 20 | --- "quoted string" 21 | --- &node foo 22 | ... 23 | 24 | --- emit-yaml(<) 25 | --- "quoted string" 26 | --- &node foo 27 | 28 | --- test-event 29 | +STR 30 | +DOC --- 31 | =VAL "quoted string 32 | -DOC 33 | +DOC --- 34 | =VAL &node :foo 35 | -DOC 36 | -STR 37 | 38 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/XV9V.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.5. Empty Lines [1.3] 2 | --- from: 5GBF, modified for YAML 1.3 3 | --- tags: literal spec scalar 1.3-mod 4 | 5 | --- in-yaml(+) 6 | Folding: 7 | "Empty line 8 | 9 | as a line feed" 10 | Chomping: | 11 | Clipped empty lines 12 | 13 | 14 | --- in-json 15 | { 16 | "Folding": "Empty line\nas a line feed", 17 | "Chomping": "Clipped empty lines\n" 18 | } 19 | 20 | --- out-yaml 21 | Folding: "Empty line\nas a line feed" 22 | Chomping: | 23 | Clipped empty lines 24 | 25 | --- test-event 26 | +STR 27 | +DOC 28 | +MAP 29 | =VAL :Folding 30 | =VAL "Empty line\nas a line feed 31 | =VAL :Chomping 32 | =VAL |Clipped empty lines\n 33 | -MAP 34 | -DOC 35 | -STR 36 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/Q8AD.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.5. Double Quoted Line Breaks [1.3] 2 | --- from: NP9H, modified for YAML 1.3 3 | --- tags: double spec scalar whitespace 1.3-mod 4 | 5 | --- in-yaml(<) 6 | --- 7 | "folded 8 | to a space, 9 | 10 | to a line feed, or \ 11 | \ non-content" 12 | 13 | --- in-json 14 | "folded to a space,\nto a line feed, or \t \tnon-content" 15 | 16 | --- out-yaml 17 | "folded to a space,\nto a line feed, or \t \tnon-content" 18 | 19 | --- emit-yaml(<) 20 | --- "folded to a space,\nto a line feed, or \t \tnon-content" 21 | 22 | --- test-event 23 | +STR 24 | +DOC --- 25 | =VAL "folded to a space,\nto a line feed, or \t \tnon-content 26 | -DOC 27 | -STR 28 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/735Y.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.20. Block Node Types 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2799426 3 | --- tags: comment double spec folded tag 4 | 5 | --- in-yaml 6 | - 7 | "flow in block" 8 | - > 9 | Block scalar 10 | - !!map # Block collection 11 | foo : bar 12 | 13 | --- in-json 14 | [ 15 | "flow in block", 16 | "Block scalar\n", 17 | { 18 | "foo": "bar" 19 | } 20 | ] 21 | 22 | --- out-yaml 23 | - "flow in block" 24 | - > 25 | Block scalar 26 | - !!map 27 | foo: bar 28 | 29 | --- test-event 30 | +STR 31 | +DOC 32 | +SEQ 33 | =VAL "flow in block 34 | =VAL >Block scalar\n 35 | +MAP 36 | =VAL :foo 37 | =VAL :bar 38 | -MAP 39 | -SEQ 40 | -DOC 41 | -STR 42 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/3GZX.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.1. Alias Nodes 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2786448 3 | --- tags: mapping spec alias 4 | 5 | --- in-yaml 6 | First occurrence: &anchor Foo 7 | Second occurrence: *anchor 8 | Override anchor: &anchor Bar 9 | Reuse anchor: *anchor 10 | 11 | --- in-json 12 | { 13 | "First occurrence": "Foo", 14 | "Second occurrence": "Foo", 15 | "Override anchor": "Bar", 16 | "Reuse anchor": "Bar" 17 | } 18 | 19 | --- test-event 20 | +STR 21 | +DOC 22 | +MAP 23 | =VAL :First occurrence 24 | =VAL &anchor :Foo 25 | =VAL :Second occurrence 26 | =ALI *anchor 27 | =VAL :Override anchor 28 | =VAL &anchor :Bar 29 | =VAL :Reuse anchor 30 | =ALI *anchor 31 | -MAP 32 | -DOC 33 | -STR 34 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9MMW.tml: -------------------------------------------------------------------------------- 1 | === Single Pair Implicit Entries 2 | --- from: @perlpunk, Spec Example 7.21 3 | --- tags: flow mapping sequence 4 | 5 | --- in-yaml(<) 6 | - [ YAML : separate ] 7 | - [ "JSON like":adjacent ] 8 | - [ {JSON: like}:adjacent ] 9 | 10 | --- out-yaml(<) 11 | - - YAML: separate 12 | - - "JSON like": adjacent 13 | - - ? JSON: like 14 | : adjacent 15 | 16 | --- test-event 17 | +STR 18 | +DOC 19 | +SEQ 20 | +SEQ 21 | +MAP 22 | =VAL :YAML 23 | =VAL :separate 24 | -MAP 25 | -SEQ 26 | +SEQ 27 | +MAP 28 | =VAL "JSON like 29 | =VAL :adjacent 30 | -MAP 31 | -SEQ 32 | +SEQ 33 | +MAP 34 | +MAP 35 | =VAL :JSON 36 | =VAL :like 37 | -MAP 38 | =VAL :adjacent 39 | -MAP 40 | -SEQ 41 | -SEQ 42 | -DOC 43 | -STR 44 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/5GBF.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.5. Empty Lines 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2778971 3 | --- tags: double literal spec scalar upto-1.2 whitespace 4 | 5 | --- in-yaml(+) 6 | Folding: 7 | "Empty line 8 | 9 | as a line feed" 10 | Chomping: | 11 | Clipped empty lines 12 | 13 | 14 | --- in-json 15 | { 16 | "Folding": "Empty line\nas a line feed", 17 | "Chomping": "Clipped empty lines\n" 18 | } 19 | 20 | --- out-yaml 21 | Folding: "Empty line\nas a line feed" 22 | Chomping: | 23 | Clipped empty lines 24 | 25 | --- test-event 26 | +STR 27 | +DOC 28 | +MAP 29 | =VAL :Folding 30 | =VAL "Empty line\nas a line feed 31 | =VAL :Chomping 32 | =VAL |Clipped empty lines\n 33 | -MAP 34 | -DOC 35 | -STR 36 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/5WE3.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.17. Explicit Block Mapping Entries 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2798425 3 | --- tags: explicit-key spec mapping comment literal sequence 4 | 5 | --- in-yaml 6 | ? explicit key # Empty value 7 | ? | 8 | block key 9 | : - one # Explicit compact 10 | - two # block value 11 | 12 | --- in-json 13 | { 14 | "explicit key": null, 15 | "block key\n": [ 16 | "one", 17 | "two" 18 | ] 19 | } 20 | 21 | --- out-yaml 22 | explicit key: 23 | ? | 24 | block key 25 | : - one 26 | - two 27 | 28 | --- test-event 29 | +STR 30 | +DOC 31 | +MAP 32 | =VAL :explicit key 33 | =VAL : 34 | =VAL |block key\n 35 | +SEQ 36 | =VAL :one 37 | =VAL :two 38 | -SEQ 39 | -MAP 40 | -DOC 41 | -STR 42 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/5C5M.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.15. Flow Mappings 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2791018 3 | --- tags: spec flow mapping 4 | 5 | --- in-yaml 6 | - { one : two , three: four , } 7 | - {five: six,seven : eight} 8 | 9 | --- in-json 10 | [ 11 | { 12 | "one": "two", 13 | "three": "four" 14 | }, 15 | { 16 | "five": "six", 17 | "seven": "eight" 18 | } 19 | ] 20 | 21 | --- out-yaml 22 | - one: two 23 | three: four 24 | - five: six 25 | seven: eight 26 | 27 | --- test-event 28 | +STR 29 | +DOC 30 | +SEQ 31 | +MAP 32 | =VAL :one 33 | =VAL :two 34 | =VAL :three 35 | =VAL :four 36 | -MAP 37 | +MAP 38 | =VAL :five 39 | =VAL :six 40 | =VAL :seven 41 | =VAL :eight 42 | -MAP 43 | -SEQ 44 | -DOC 45 | -STR 46 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/8KB6.tml: -------------------------------------------------------------------------------- 1 | === Multiline plain flow mapping key without value 2 | --- from: @perlpunk 3 | --- tags: flow mapping 4 | 5 | --- in-yaml(<) 6 | --- 7 | - { single line, a: b} 8 | - { multi 9 | line, a: b} 10 | 11 | --- out-yaml(<) 12 | --- 13 | - single line: 14 | a: b 15 | - multi line: 16 | a: b 17 | 18 | --- in-json 19 | [ 20 | { 21 | "single line": null, 22 | "a": "b" 23 | }, 24 | { 25 | "multi line": null, 26 | "a": "b" 27 | } 28 | ] 29 | 30 | --- test-event 31 | +STR 32 | +DOC --- 33 | +SEQ 34 | +MAP 35 | =VAL :single line 36 | =VAL : 37 | =VAL :a 38 | =VAL :b 39 | -MAP 40 | +MAP 41 | =VAL :multi line 42 | =VAL : 43 | =VAL :a 44 | =VAL :b 45 | -MAP 46 | -SEQ 47 | -DOC 48 | -STR 49 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/4CQQ.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.18. Multi-line Flow Scalars 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2761268 3 | --- tags: spec scalar 4 | 5 | --- in-yaml 6 | plain: 7 | This unquoted scalar 8 | spans many lines. 9 | 10 | quoted: "So does this 11 | quoted scalar.\n" 12 | 13 | --- in-json 14 | { 15 | "plain": "This unquoted scalar spans many lines.", 16 | "quoted": "So does this quoted scalar.\n" 17 | } 18 | 19 | --- out-yaml 20 | plain: This unquoted scalar spans many lines. 21 | quoted: "So does this quoted scalar.\n" 22 | 23 | --- test-event 24 | +STR 25 | +DOC 26 | +MAP 27 | =VAL :plain 28 | =VAL :This unquoted scalar spans many lines. 29 | =VAL :quoted 30 | =VAL "So does this quoted scalar.\n 31 | -MAP 32 | -DOC 33 | -STR 34 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9DXL.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 9.6. Stream [1.3] 2 | --- from: 6ZKB, modified for YAML 1.3 3 | --- tags: spec header 1.3-mod 4 | 5 | --- in-yaml(<) 6 | Mapping: Document 7 | --- 8 | # Empty 9 | ... 10 | %YAML 1.2 11 | --- 12 | matches %: 20 13 | 14 | --- in-json 15 | { 16 | "Mapping": "Document" 17 | } 18 | null 19 | { 20 | "matches %": 20 21 | } 22 | 23 | --- emit-yaml(<) 24 | Mapping: Document 25 | --- 26 | ... 27 | %YAML 1.2 28 | --- 29 | matches %: 20 30 | 31 | --- test-event 32 | +STR 33 | +DOC 34 | +MAP 35 | =VAL :Mapping 36 | =VAL :Document 37 | -MAP 38 | -DOC 39 | +DOC --- 40 | =VAL : 41 | -DOC ... 42 | +DOC --- 43 | +MAP 44 | =VAL :matches % 45 | =VAL :20 46 | -MAP 47 | -DOC 48 | -STR 49 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/M7NX.tml: -------------------------------------------------------------------------------- 1 | === Nested flow collections 2 | --- from: @perlpunk 3 | --- tags: flow mapping sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | { 8 | a: [ 9 | b, c, { 10 | d: [e, f] 11 | } 12 | ] 13 | } 14 | 15 | --- in-json 16 | { 17 | "a": [ 18 | "b", 19 | "c", 20 | { 21 | "d": [ 22 | "e", 23 | "f" 24 | ] 25 | } 26 | ] 27 | } 28 | 29 | --- out-yaml(<) 30 | --- 31 | a: 32 | - b 33 | - c 34 | - d: 35 | - e 36 | - f 37 | 38 | --- test-event 39 | +STR 40 | +DOC --- 41 | +MAP 42 | =VAL :a 43 | +SEQ 44 | =VAL :b 45 | =VAL :c 46 | +MAP 47 | =VAL :d 48 | +SEQ 49 | =VAL :e 50 | =VAL :f 51 | -SEQ 52 | -MAP 53 | -SEQ 54 | -MAP 55 | -DOC 56 | -STR 57 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/PW8X.tml: -------------------------------------------------------------------------------- 1 | === Anchors on Empty Scalars 2 | --- from: NimYAML tests 3 | --- tags: anchor explicit-key 4 | 5 | Test showing empty values and missing explicit components. 6 | 7 | --- in-yaml 8 | - &a 9 | - a 10 | - 11 | &a : a 12 | b: &b 13 | - 14 | &c : &a 15 | - 16 | ? &d 17 | - 18 | ? &e 19 | : &a 20 | 21 | --- out-yaml 22 | - &a 23 | - a 24 | - &a : a 25 | b: &b 26 | - &c : &a 27 | - &d : 28 | - &e : &a 29 | 30 | --- test-event 31 | +STR 32 | +DOC 33 | +SEQ 34 | =VAL &a : 35 | =VAL :a 36 | +MAP 37 | =VAL &a : 38 | =VAL :a 39 | =VAL :b 40 | =VAL &b : 41 | -MAP 42 | +MAP 43 | =VAL &c : 44 | =VAL &a : 45 | -MAP 46 | +MAP 47 | =VAL &d : 48 | =VAL : 49 | -MAP 50 | +MAP 51 | =VAL &e : 52 | =VAL &a : 53 | -MAP 54 | -SEQ 55 | -DOC 56 | -STR 57 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/P2AD.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.1. Block Scalar Header 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2793888 3 | --- tags: spec literal folded comment scalar 4 | 5 | --- in-yaml 6 | - | # Empty header↓ 7 | literal 8 | - >1 # Indentation indicator↓ 9 | folded 10 | - |+ # Chomping indicator↓ 11 | keep 12 | 13 | - >1- # Both indicators↓ 14 | strip 15 | 16 | --- in-json 17 | [ 18 | "literal\n", 19 | " folded\n", 20 | "keep\n\n", 21 | " strip" 22 | ] 23 | 24 | --- out-yaml 25 | - | 26 | literal 27 | - >2 28 | folded 29 | - |+ 30 | keep 31 | 32 | - >2- 33 | strip 34 | 35 | --- test-event 36 | +STR 37 | +DOC 38 | +SEQ 39 | =VAL |literal\n 40 | =VAL > folded\n 41 | =VAL |keep\n\n 42 | =VAL > strip 43 | -SEQ 44 | -DOC 45 | -STR 46 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/35KP.tml: -------------------------------------------------------------------------------- 1 | === Tags for Root Objects 2 | --- from: NimYAML tests 3 | --- tags: explicit-key header mapping tag 4 | 5 | --- in-yaml(<) 6 | --- !!map 7 | ? a 8 | : b 9 | --- !!seq 10 | - !!str c 11 | --- !!str 12 | d 13 | e 14 | 15 | --- in-json 16 | { 17 | "a": "b" 18 | } 19 | [ 20 | "c" 21 | ] 22 | "d e" 23 | 24 | --- out-yaml(<) 25 | --- !!map 26 | a: b 27 | --- !!seq 28 | - !!str c 29 | --- !!str d e 30 | 31 | --- test-event 32 | +STR 33 | +DOC --- 34 | +MAP 35 | =VAL :a 36 | =VAL :b 37 | -MAP 38 | -DOC 39 | +DOC --- 40 | +SEQ 41 | =VAL :c 42 | -SEQ 43 | -DOC 44 | +DOC --- 45 | =VAL :d e 46 | -DOC 47 | -STR 48 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/R52L.tml: -------------------------------------------------------------------------------- 1 | === Nested flow mapping sequence and mappings 2 | --- from: @perlpunk 3 | --- tags: flow mapping sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | { top1: [item1, {key2: value2}, item3], top2: value2 } 8 | 9 | --- out-yaml(<) 10 | --- 11 | top1: 12 | - item1 13 | - key2: value2 14 | - item3 15 | top2: value2 16 | 17 | --- in-json 18 | { 19 | "top1": [ 20 | "item1", 21 | { 22 | "key2": "value2" 23 | }, 24 | "item3" 25 | ], 26 | "top2": "value2" 27 | } 28 | 29 | --- test-event 30 | +STR 31 | +DOC --- 32 | +MAP 33 | =VAL :top1 34 | +SEQ 35 | =VAL :item1 36 | +MAP 37 | =VAL :key2 38 | =VAL :value2 39 | -MAP 40 | =VAL :item3 41 | -SEQ 42 | =VAL :top2 43 | =VAL :value2 44 | -MAP 45 | -DOC 46 | -STR 47 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/4QFQ.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.2. Block Indentation Indicator [1.3] 2 | --- from: R4YG, modified for YAML 1.3 3 | --- tags: spec literal folded scalar libyaml-err 1.3-mod whitespace 4 | 5 | --- in-yaml 6 | - | 7 | detected 8 | - > 9 | 10 | 11 | # detected 12 | - |1 13 | explicit 14 | - > 15 | detected 16 | 17 | --- in-json 18 | [ 19 | "detected\n", 20 | "\n\n# detected\n", 21 | " explicit\n", 22 | "detected\n" 23 | ] 24 | 25 | --- emit-yaml 26 | - | 27 | detected 28 | - >2 29 | 30 | 31 | # detected 32 | - |2 33 | explicit 34 | - > 35 | detected 36 | 37 | --- test-event 38 | +STR 39 | +DOC 40 | +SEQ 41 | =VAL |detected\n 42 | =VAL >\n\n# detected\n 43 | =VAL | explicit\n 44 | =VAL >detected\n 45 | -SEQ 46 | -DOC 47 | -STR 48 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/74H7.tml: -------------------------------------------------------------------------------- 1 | === Tags in Implicit Mapping 2 | --- from: NimYAML tests 3 | --- tags: tag mapping 4 | 5 | --- in-yaml 6 | !!str a: b 7 | c: !!int 42 8 | e: !!str f 9 | g: h 10 | !!str 23: !!bool false 11 | 12 | --- in-json 13 | { 14 | "a": "b", 15 | "c": 42, 16 | "e": "f", 17 | "g": "h", 18 | "23": false 19 | } 20 | 21 | --- out-yaml 22 | !!str a: b 23 | c: !!int 42 24 | e: !!str f 25 | g: h 26 | !!str 23: !!bool false 27 | 28 | --- test-event 29 | +STR 30 | +DOC 31 | +MAP 32 | =VAL :a 33 | =VAL :b 34 | =VAL :c 35 | =VAL :42 36 | =VAL :e 37 | =VAL :f 38 | =VAL :g 39 | =VAL :h 40 | =VAL :23 41 | =VAL :false 42 | -MAP 43 | -DOC 44 | -STR 45 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/9BXH.tml: -------------------------------------------------------------------------------- 1 | === Multiline doublequoted flow mapping key without value 2 | --- from: @perlpunk 3 | --- tags: double flow mapping 4 | 5 | --- in-yaml(<) 6 | --- 7 | - { "single line", a: b} 8 | - { "multi 9 | line", a: b} 10 | 11 | --- out-yaml(<) 12 | --- 13 | - "single line": 14 | a: b 15 | - "multi line": 16 | a: b 17 | 18 | --- in-json 19 | [ 20 | { 21 | "single line": null, 22 | "a": "b" 23 | }, 24 | { 25 | "multi line": null, 26 | "a": "b" 27 | } 28 | ] 29 | 30 | --- test-event 31 | +STR 32 | +DOC --- 33 | +SEQ 34 | +MAP 35 | =VAL "single line 36 | =VAL : 37 | =VAL :a 38 | =VAL :b 39 | -MAP 40 | +MAP 41 | =VAL "multi line 42 | =VAL : 43 | =VAL :a 44 | =VAL :b 45 | -MAP 46 | -SEQ 47 | -DOC 48 | -STR 49 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/F6MC.tml: -------------------------------------------------------------------------------- 1 | === More indented lines at the beginning of folded block scalars 2 | --- from: @perlpunk 3 | --- tags: folded indent 4 | 5 | --- in-yaml(<) 6 | --- 7 | a: >2 8 | more indented 9 | regular 10 | b: >2 11 | 12 | 13 | more indented 14 | regular 15 | 16 | --- emit-yaml(<) 17 | --- 18 | a: >2 19 | more indented 20 | regular 21 | b: >2 22 | 23 | 24 | more indented 25 | regular 26 | 27 | --- in-json 28 | { 29 | "a": " more indented\nregular\n", 30 | "b": "\n\n more indented\nregular\n" 31 | } 32 | 33 | --- test-event 34 | +STR 35 | +DOC --- 36 | +MAP 37 | =VAL :a 38 | =VAL > more indented\nregular\n 39 | =VAL :b 40 | =VAL >\n\n more indented\nregular\n 41 | -MAP 42 | -DOC 43 | -STR 44 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/LP6E.tml: -------------------------------------------------------------------------------- 1 | === Whitespace After Scalars in Flow 2 | --- from: NimYAML tests 3 | --- tags: flow scalar whitespace 4 | 5 | --- in-yaml 6 | - [a, b , c ] 7 | - { "a" : b 8 | , c : 'd' , 9 | e : "f" 10 | } 11 | - [ ] 12 | 13 | --- in-json 14 | [ 15 | [ 16 | "a", 17 | "b", 18 | "c" 19 | ], 20 | { 21 | "a": "b", 22 | "c": "d", 23 | "e": "f" 24 | }, 25 | [] 26 | ] 27 | 28 | --- out-yaml 29 | - - a 30 | - b 31 | - c 32 | - "a": b 33 | c: 'd' 34 | e: "f" 35 | - [] 36 | 37 | --- test-event 38 | +STR 39 | +DOC 40 | +SEQ 41 | +SEQ 42 | =VAL :a 43 | =VAL :b 44 | =VAL :c 45 | -SEQ 46 | +MAP 47 | =VAL "a 48 | =VAL :b 49 | =VAL :c 50 | =VAL 'd 51 | =VAL :e 52 | =VAL "f 53 | -MAP 54 | +SEQ 55 | -SEQ 56 | -SEQ 57 | -DOC 58 | -STR 59 | -------------------------------------------------------------------------------- /core/shared/src/test/scala-3/org/virtuslab/yaml/decoder/DecoderErrorsSuite.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml.decoder 2 | 3 | import org.virtuslab.yaml.Node.ScalarNode 4 | import org.virtuslab.yaml.Node.SequenceNode 5 | import org.virtuslab.yaml.YamlError 6 | import org.virtuslab.yaml.* 7 | 8 | class DecoderErrorsSuite extends BaseDecoderErrorSuite: 9 | 10 | case class Person(name: String, age: Int) derives YamlCodec 11 | 12 | test("fail for invalid int") { 13 | 14 | val yaml = """|name: John 15 | |age: xxx 16 | |""".stripMargin 17 | 18 | assertError( 19 | yaml.as[Person], 20 | s"""|For input string: "xxx" 21 | |at 1:5, expected Int 22 | |age: xxx 23 | | ^ 24 | |""".stripMargin 25 | ) 26 | } 27 | end DecoderErrorsSuite 28 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/UDR7.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 5.4. Flow Collection Indicators 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2772813 3 | --- tags: spec flow sequence mapping 4 | 5 | --- in-yaml 6 | sequence: [ one, two, ] 7 | mapping: { sky: blue, sea: green } 8 | 9 | --- in-json 10 | { 11 | "sequence": [ 12 | "one", 13 | "two" 14 | ], 15 | "mapping": { 16 | "sky": "blue", 17 | "sea": "green" 18 | } 19 | } 20 | 21 | --- out-yaml 22 | sequence: 23 | - one 24 | - two 25 | mapping: 26 | sky: blue 27 | sea: green 28 | 29 | --- test-event 30 | +STR 31 | +DOC 32 | +MAP 33 | =VAL :sequence 34 | +SEQ 35 | =VAL :one 36 | =VAL :two 37 | -SEQ 38 | =VAL :mapping 39 | +MAP 40 | =VAL :sky 41 | =VAL :blue 42 | =VAL :sea 43 | =VAL :green 44 | -MAP 45 | -MAP 46 | -DOC 47 | -STR 48 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/W42U.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.15. Block Sequence Entry Types 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2797944 3 | --- tags: comment spec literal sequence 4 | 5 | --- in-yaml 6 | - # Empty 7 | - | 8 | block node 9 | - - one # Compact 10 | - two # sequence 11 | - one: two # Compact mapping 12 | 13 | --- in-json 14 | [ 15 | null, 16 | "block node\n", 17 | [ 18 | "one", 19 | "two" 20 | ], 21 | { 22 | "one": "two" 23 | } 24 | ] 25 | 26 | --- out-yaml 27 | - 28 | - | 29 | block node 30 | - - one 31 | - two 32 | - one: two 33 | 34 | --- test-event 35 | +STR 36 | +DOC 37 | +SEQ 38 | =VAL : 39 | =VAL |block node\n 40 | +SEQ 41 | =VAL :one 42 | =VAL :two 43 | -SEQ 44 | +MAP 45 | =VAL :one 46 | =VAL :two 47 | -MAP 48 | -SEQ 49 | -DOC 50 | -STR 51 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6WLZ.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.18. Primary Tag Handle [1.3] 2 | --- from: 9WXW, modified for YAML 1.3 3 | --- tags: local-tag spec directive tag 1.3-mod 4 | 5 | --- in-yaml(<) 6 | # Private 7 | --- 8 | !foo "bar" 9 | ... 10 | # Global 11 | %TAG ! tag:example.com,2000:app/ 12 | --- 13 | !foo "bar" 14 | 15 | --- out-yaml(<) 16 | --- 17 | !foo "bar" 18 | ... 19 | --- ! 20 | "bar" 21 | 22 | --- emit-yaml(<) 23 | --- !foo "bar" 24 | ... 25 | --- ! "bar" 26 | 27 | --- in-json(<) 28 | "bar" 29 | "bar" 30 | 31 | --- test-event 32 | +STR 33 | +DOC --- 34 | =VAL "bar 35 | -DOC ... 36 | +DOC --- 37 | =VAL "bar 38 | -DOC 39 | -STR 40 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/CN3R.tml: -------------------------------------------------------------------------------- 1 | === Various location of anchors in flow sequence 2 | --- from: @perlpunk 3 | --- tags: anchor flow mapping sequence 4 | 5 | --- in-yaml 6 | &flowseq [ 7 | a: b, 8 | &c c: d, 9 | { &e e: f }, 10 | &g { g: h } 11 | ] 12 | 13 | --- in-json 14 | [ 15 | { 16 | "a": "b" 17 | }, 18 | { 19 | "c": "d" 20 | }, 21 | { 22 | "e": "f" 23 | }, 24 | { 25 | "g": "h" 26 | } 27 | ] 28 | 29 | --- out-yaml 30 | &flowseq 31 | - a: b 32 | - &c c: d 33 | - &e e: f 34 | - &g 35 | g: h 36 | 37 | --- test-event 38 | +STR 39 | +DOC 40 | +SEQ &flowseq 41 | +MAP 42 | =VAL :a 43 | =VAL :b 44 | -MAP 45 | +MAP 46 | =VAL &c :c 47 | =VAL :d 48 | -MAP 49 | +MAP 50 | =VAL &e :e 51 | =VAL :f 52 | -MAP 53 | +MAP &g 54 | =VAL :g 55 | =VAL :h 56 | -MAP 57 | -SEQ 58 | -DOC 59 | -STR 60 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/J3BT.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 5.12. Tabs and Spaces 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2775350 3 | --- tags: spec whitespace upto-1.2 4 | 5 | --- in-yaml(<) 6 | # Tabs and spaces 7 | quoted: "Quoted " 8 | block:| 9 | void main() { 10 | printf("Hello, world!\n"); 11 | } 12 | 13 | --- in-json 14 | { 15 | "quoted": "Quoted \t", 16 | "block": "void main() {\n\tprintf(\"Hello, world!\\n\");\n}\n" 17 | } 18 | 19 | --- out-yaml 20 | quoted: "Quoted \t" 21 | block: | 22 | void main() { 23 | printf("Hello, world!\n"); 24 | } 25 | 26 | --- test-event 27 | +STR 28 | +DOC 29 | +MAP 30 | =VAL :quoted 31 | =VAL "Quoted \t 32 | =VAL :block 33 | =VAL |void main() {\n\tprintf("Hello, world!\\n");\n}\n 34 | -MAP 35 | -DOC 36 | -STR 37 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/M7A3.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 9.3. Bare Documents 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2801226 3 | --- tags: spec footer 1.3-err 4 | 5 | --- in-yaml(<) 6 | Bare 7 | document 8 | ... 9 | # No document 10 | # XXX libyaml wants a --- here 11 | ... 12 | # XXX libyaml wants a --- here 13 | | 14 | # XXX literal needs indentation? libyaml sees a directive. 15 | %!PS-Adobe-2.0 # Not the first line 16 | 17 | --- in-json 18 | "Bare document" 19 | "%!PS-Adobe-2.0 # Not the first line\n" 20 | 21 | --- emit-yaml(<) 22 | Bare document 23 | ... 24 | | 25 | %!PS-Adobe-2.0 # Not the first line 26 | 27 | --- test-event 28 | +STR 29 | +DOC 30 | =VAL :Bare document 31 | -DOC ... 32 | +DOC 33 | =VAL |%!PS-Adobe-2.0 # Not the first line\n 34 | -DOC 35 | -STR 36 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/7T8X.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.10. Folded Lines - 8.13. Final Empty Lines 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2796543 3 | --- tags: spec folded scalar comment 1.3-err 4 | 5 | --- in-yaml(<) 6 | > 7 | 8 | folded 9 | line 10 | 11 | next 12 | line 13 | * bullet 14 | 15 | * list 16 | * lines 17 | 18 | last 19 | line 20 | 21 | # Comment 22 | 23 | --- in-json 24 | "\nfolded line\nnext line\n * bullet\n\n * list\n * lines\n\nlast line\n" 25 | 26 | --- out-yaml 27 | > 28 | 29 | folded line 30 | 31 | next line 32 | * bullet 33 | 34 | * list 35 | * lines 36 | 37 | last line 38 | 39 | --- test-event 40 | +STR 41 | +DOC 42 | =VAL >\nfolded line\nnext line\n * bullet\n\n * list\n * lines\n\nlast line\n 43 | -DOC 44 | -STR 45 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/R4YG.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.2. Block Indentation Indicator 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2794311 3 | --- tags: spec literal folded scalar whitespace libyaml-err upto-1.2 4 | 5 | --- in-yaml 6 | - | 7 | detected 8 | - > 9 | 10 | 11 | # detected 12 | - |1 13 | explicit 14 | - > 15 | 16 | detected 17 | 18 | --- in-json 19 | [ 20 | "detected\n", 21 | "\n\n# detected\n", 22 | " explicit\n", 23 | "\t\ndetected\n" 24 | ] 25 | 26 | --- out-yaml 27 | - | 28 | detected 29 | - >2 30 | 31 | 32 | # detected 33 | - |2 34 | explicit 35 | # XXX > becomes "? 36 | - "\t\ndetected\n" 37 | 38 | --- test-event 39 | +STR 40 | +DOC 41 | +SEQ 42 | =VAL |detected\n 43 | =VAL >\n\n# detected\n 44 | =VAL | explicit\n 45 | =VAL >\t\ndetected\n 46 | -SEQ 47 | -DOC 48 | -STR 49 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/S9E8.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 5.3. Block Structure Indicators 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2772312 3 | --- tags: explicit-key spec mapping sequence 4 | 5 | --- in-yaml 6 | sequence: 7 | - one 8 | - two 9 | mapping: 10 | ? sky 11 | : blue 12 | sea : green 13 | 14 | --- in-json 15 | { 16 | "sequence": [ 17 | "one", 18 | "two" 19 | ], 20 | "mapping": { 21 | "sky": "blue", 22 | "sea": "green" 23 | } 24 | } 25 | 26 | --- out-yaml 27 | sequence: 28 | - one 29 | - two 30 | mapping: 31 | sky: blue 32 | sea: green 33 | 34 | --- test-event 35 | +STR 36 | +DOC 37 | +MAP 38 | =VAL :sequence 39 | +SEQ 40 | =VAL :one 41 | =VAL :two 42 | -SEQ 43 | =VAL :mapping 44 | +MAP 45 | =VAL :sky 46 | =VAL :blue 47 | =VAL :sea 48 | =VAL :green 49 | -MAP 50 | -MAP 51 | -DOC 52 | -STR 53 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/2XXW.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.25. Unordered Sets 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2761758 3 | --- tags: spec mapping unknown-tag explicit-key 4 | 5 | --- in-yaml(<) 6 | # Sets are represented as a 7 | # Mapping where each key is 8 | # associated with a null value 9 | --- !!set 10 | ? Mark McGwire 11 | ? Sammy Sosa 12 | ? Ken Griff 13 | 14 | --- out-yaml(<) 15 | --- !!set 16 | Mark McGwire: 17 | Sammy Sosa: 18 | Ken Griff: 19 | 20 | --- in-json(<) 21 | { 22 | "Mark McGwire": null, 23 | "Sammy Sosa": null, 24 | "Ken Griff": null 25 | } 26 | 27 | --- test-event 28 | +STR 29 | +DOC --- 30 | +MAP 31 | =VAL :Mark McGwire 32 | =VAL : 33 | =VAL :Sammy Sosa 34 | =VAL : 35 | =VAL :Ken Griff 36 | =VAL : 37 | -MAP 38 | -DOC 39 | -STR 40 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/H2RW.tml: -------------------------------------------------------------------------------- 1 | === Blank lines 2 | --- from: IRC discussion with leont 3 | --- tags: comment literal scalar whitespace 4 | 5 | --- in-yaml 6 | foo: 1 7 | 8 | bar: 2 9 | 10 | text: | 11 | a 12 | 13 | b 14 | 15 | c 16 | 17 | d 18 | 19 | --- in-json 20 | { 21 | "foo": 1, 22 | "bar": 2, 23 | "text": "a\n \nb\n\nc\n\nd\n" 24 | } 25 | 26 | --- out-yaml 27 | foo: 1 28 | bar: 2 29 | # XXX libyaml changes | scalar events to " emission 30 | text: "a\n \nb\n\nc\n\nd\n" 31 | 32 | --- emit-yaml 33 | foo: 1 34 | bar: 2 35 | text: | 36 | a 37 | 38 | b 39 | 40 | c 41 | 42 | d 43 | 44 | --- test-event 45 | +STR 46 | +DOC 47 | +MAP 48 | =VAL :foo 49 | =VAL :1 50 | =VAL :bar 51 | =VAL :2 52 | =VAL :text 53 | =VAL |a\n \nb\n\nc\n\nd\n 54 | -MAP 55 | -DOC 56 | -STR 57 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/8UDB.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 7.14. Flow Sequence Entries 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2790726 3 | --- tags: spec flow sequence 4 | 5 | --- in-yaml 6 | [ 7 | "double 8 | quoted", 'single 9 | quoted', 10 | plain 11 | text, [ nested ], 12 | single: pair, 13 | ] 14 | 15 | --- in-json 16 | [ 17 | "double quoted", 18 | "single quoted", 19 | "plain text", 20 | [ 21 | "nested" 22 | ], 23 | { 24 | "single": "pair" 25 | } 26 | ] 27 | 28 | --- out-yaml 29 | - "double quoted" 30 | - 'single quoted' 31 | - plain text 32 | - - nested 33 | - single: pair 34 | 35 | --- test-event 36 | +STR 37 | +DOC 38 | +SEQ 39 | =VAL "double quoted 40 | =VAL 'single quoted 41 | =VAL :plain text 42 | +SEQ 43 | =VAL :nested 44 | -SEQ 45 | +MAP 46 | =VAL :single 47 | =VAL :pair 48 | -MAP 49 | -SEQ 50 | -DOC 51 | -STR 52 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/4ZYM.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 6.4. Line Prefixes 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2778720 3 | --- tags: spec scalar literal double upto-1.2 whitespace 4 | 5 | --- in-yaml 6 | plain: text 7 | lines 8 | quoted: "text 9 | lines" 10 | block: | 11 | text 12 | lines 13 | 14 | --- in-json 15 | { 16 | "plain": "text lines", 17 | "quoted": "text lines", 18 | "block": "text\n \tlines\n" 19 | } 20 | 21 | --- out-yaml 22 | plain: text lines 23 | quoted: "text lines" 24 | block: "text\n \tlines\n" 25 | 26 | --- emit-yaml 27 | plain: text lines 28 | quoted: "text lines" 29 | block: | 30 | text 31 | lines 32 | 33 | --- test-event 34 | +STR 35 | +DOC 36 | +MAP 37 | =VAL :plain 38 | =VAL :text lines 39 | =VAL :quoted 40 | =VAL "text lines 41 | =VAL :block 42 | =VAL |text\n \tlines\n 43 | -MAP 44 | -DOC 45 | -STR 46 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/F8F9.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.5. Chomping Trailing Lines 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2795435 3 | --- tags: spec literal scalar comment 4 | 5 | --- in-yaml 6 | # Strip 7 | # Comments: 8 | strip: |- 9 | # text 10 | 11 | # Clip 12 | # comments: 13 | 14 | clip: | 15 | # text 16 | 17 | # Keep 18 | # comments: 19 | 20 | keep: |+ 21 | # text 22 | 23 | # Trail 24 | # comments. 25 | 26 | --- in-json 27 | { 28 | "strip": "# text", 29 | "clip": "# text\n", 30 | "keep": "# text\n\n" 31 | } 32 | 33 | --- out-yaml 34 | strip: |- 35 | # text 36 | clip: | 37 | # text 38 | keep: |+ 39 | # text 40 | 41 | ... 42 | 43 | --- test-event 44 | +STR 45 | +DOC 46 | +MAP 47 | =VAL :strip 48 | =VAL |# text 49 | =VAL :clip 50 | =VAL |# text\n 51 | =VAL :keep 52 | =VAL |# text\n\n 53 | -MAP 54 | -DOC 55 | -STR 56 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/ZF4X.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.6. Mapping of Mappings 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2760372 3 | --- tags: flow spec mapping 4 | 5 | --- in-yaml 6 | Mark McGwire: {hr: 65, avg: 0.278} 7 | Sammy Sosa: { 8 | hr: 63, 9 | avg: 0.288 10 | } 11 | 12 | --- in-json 13 | { 14 | "Mark McGwire": { 15 | "hr": 65, 16 | "avg": 0.278 17 | }, 18 | "Sammy Sosa": { 19 | "hr": 63, 20 | "avg": 0.288 21 | } 22 | } 23 | 24 | --- out-yaml 25 | Mark McGwire: 26 | hr: 65 27 | avg: 0.278 28 | Sammy Sosa: 29 | hr: 63 30 | avg: 0.288 31 | 32 | --- test-event 33 | +STR 34 | +DOC 35 | +MAP 36 | =VAL :Mark McGwire 37 | +MAP 38 | =VAL :hr 39 | =VAL :65 40 | =VAL :avg 41 | =VAL :0.278 42 | -MAP 43 | =VAL :Sammy Sosa 44 | +MAP 45 | =VAL :hr 46 | =VAL :63 47 | =VAL :avg 48 | =VAL :0.288 49 | -MAP 50 | -MAP 51 | -DOC 52 | -STR 53 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/57H4.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 8.22. Block Collection Nodes 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2800008 3 | --- tags: sequence mapping tag 4 | 5 | --- in-yaml 6 | sequence: !!seq 7 | - entry 8 | - !!seq 9 | - nested 10 | mapping: !!map 11 | foo: bar 12 | 13 | --- in-json 14 | { 15 | "sequence": [ 16 | "entry", 17 | [ 18 | "nested" 19 | ] 20 | ], 21 | "mapping": { 22 | "foo": "bar" 23 | } 24 | } 25 | 26 | --- out-yaml 27 | sequence: !!seq 28 | - entry 29 | - !!seq 30 | - nested 31 | mapping: !!map 32 | foo: bar 33 | 34 | --- test-event 35 | +STR 36 | +DOC 37 | +MAP 38 | =VAL :sequence 39 | +SEQ 40 | =VAL :entry 41 | +SEQ 42 | =VAL :nested 43 | -SEQ 44 | -SEQ 45 | =VAL :mapping 46 | +MAP 47 | =VAL :foo 48 | =VAL :bar 49 | -MAP 50 | -MAP 51 | -DOC 52 | -STR 53 | -------------------------------------------------------------------------------- /core/jvm/src/test/org/virtuslab/yaml/YamlEncoderSuite.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml 2 | 3 | import org.virtuslab.yaml.* 4 | 5 | class YamlEncoderSuite extends munit.FunSuite: 6 | 7 | test("case class (mapping)") { 8 | case class Stats(hr: Int, avg: Double, rbi: Int) derives YamlCodec 9 | val data = Stats(1, 1.0, 1) 10 | val expected = 11 | s"""hr: 1 12 | |avg: 1.0 13 | |rbi: 1 14 | |""".stripMargin 15 | 16 | assertEquals(data.asYaml, expected) 17 | } 18 | 19 | test("mapping of sequences") { 20 | case class Data(ints: Seq[Int], doubles: Seq[Double]) derives YamlCodec 21 | val data = Data(Seq(1, 2), Seq(3.0, 4.0)) 22 | 23 | val expected = 24 | s"""ints: 25 | | - 1 26 | | - 2 27 | |doubles: 28 | | - 3.0 29 | | - 4.0 30 | |""".stripMargin 31 | 32 | assertEquals(data.asYaml, expected) 33 | } 34 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/6VJK.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.15. Folded newlines are preserved for "more indented" and blank lines 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2761056 3 | --- tags: spec folded scalar 1.3-err 4 | 5 | --- in-yaml 6 | > 7 | Sammy Sosa completed another 8 | fine season with great stats. 9 | 10 | 63 Home Runs 11 | 0.288 Batting Average 12 | 13 | What a year! 14 | 15 | --- in-json 16 | "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n" 17 | 18 | --- out-yaml 19 | > 20 | Sammy Sosa completed another fine season with great stats. 21 | 22 | 63 Home Runs 23 | 0.288 Batting Average 24 | 25 | What a year! 26 | 27 | --- test-event 28 | +STR 29 | +DOC 30 | =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 31 | -DOC 32 | -STR 33 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/XW4D.tml: -------------------------------------------------------------------------------- 1 | === Various Trailing Comments 2 | --- from: @perlpunk 3 | --- tags: comment explicit-key folded 1.3-err 4 | 5 | --- in-yaml 6 | a: "double 7 | quotes" # lala 8 | b: plain 9 | value # lala 10 | c : #lala 11 | d 12 | ? # lala 13 | - seq1 14 | : # lala 15 | - #lala 16 | seq2 17 | e: 18 | &node # lala 19 | - x: y 20 | block: > # lala 21 | abcde 22 | 23 | --- out-yaml 24 | a: "double quotes" 25 | b: plain value 26 | c: d 27 | ? - seq1 28 | : - seq2 29 | e: &node 30 | - x: y 31 | block: > 32 | abcde 33 | 34 | --- test-event 35 | +STR 36 | +DOC 37 | +MAP 38 | =VAL :a 39 | =VAL "double quotes 40 | =VAL :b 41 | =VAL :plain value 42 | =VAL :c 43 | =VAL :d 44 | +SEQ 45 | =VAL :seq1 46 | -SEQ 47 | +SEQ 48 | =VAL :seq2 49 | -SEQ 50 | =VAL :e 51 | +SEQ &node 52 | +MAP 53 | =VAL :x 54 | =VAL :y 55 | -MAP 56 | -SEQ 57 | =VAL :block 58 | =VAL >abcde\n 59 | -MAP 60 | -DOC 61 | -STR 62 | 63 | -------------------------------------------------------------------------------- /core/js/src/test/org/virtuslab/yaml/YamlEncoderSuite.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml 2 | 3 | import org.virtuslab.yaml.* 4 | 5 | class YamlEncoderSpec extends munit.FunSuite: 6 | 7 | test("sequence of sequences") { 8 | val data = Seq( 9 | Seq(1, 2), 10 | Seq(3, 4) 11 | ) 12 | 13 | val expected = 14 | s"""- 15 | | - 1 16 | | - 2 17 | |- 18 | | - 3 19 | | - 4 20 | |""".stripMargin 21 | 22 | assertEquals(data.asYaml, expected) 23 | } 24 | 25 | test("mapping of sequences") { 26 | case class Data(ints: Seq[Int], doubles: Seq[Double]) derives YamlCodec 27 | val data = Data(Seq(1, 2), Seq(3.0, 4.0)) 28 | 29 | val expected = 30 | s"""ints: 31 | | - 1 32 | | - 2 33 | |doubles: 34 | | - 3.0 35 | | - 4.0 36 | |""".stripMargin 37 | 38 | assertEquals(data.asYaml, expected) 39 | } 40 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/RZP5.tml: -------------------------------------------------------------------------------- 1 | === Various Trailing Comments [1.3] 2 | --- from: XW4D, modified for YAML 1.3 3 | --- tags: anchor comment folded mapping 1.3-mod 4 | 5 | --- in-yaml 6 | a: "double 7 | quotes" # lala 8 | b: plain 9 | value # lala 10 | c : #lala 11 | d 12 | ? # lala 13 | - seq1 14 | : # lala 15 | - #lala 16 | seq2 17 | e: &node # lala 18 | - x: y 19 | block: > # lala 20 | abcde 21 | 22 | --- out-yaml 23 | a: "double quotes" 24 | b: plain value 25 | c: d 26 | ? - seq1 27 | : - seq2 28 | e: &node 29 | - x: y 30 | block: > 31 | abcde 32 | 33 | --- test-event 34 | +STR 35 | +DOC 36 | +MAP 37 | =VAL :a 38 | =VAL "double quotes 39 | =VAL :b 40 | =VAL :plain value 41 | =VAL :c 42 | =VAL :d 43 | +SEQ 44 | =VAL :seq1 45 | -SEQ 46 | +SEQ 47 | =VAL :seq2 48 | -SEQ 49 | =VAL :e 50 | +SEQ &node 51 | +MAP 52 | =VAL :x 53 | =VAL :y 54 | -MAP 55 | -SEQ 56 | =VAL :block 57 | =VAL >abcde\n 58 | -MAP 59 | -DOC 60 | -STR 61 | 62 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/7ZZ5.tml: -------------------------------------------------------------------------------- 1 | === Empty flow collections 2 | --- from: @perlpunk 3 | --- tags: flow mapping sequence 4 | 5 | --- in-yaml(<) 6 | --- 7 | nested sequences: 8 | - - - [] 9 | - - - {} 10 | key1: [] 11 | key2: {} 12 | 13 | --- out-yaml(<) 14 | --- 15 | nested sequences: 16 | - - - [] 17 | - - - {} 18 | key1: [] 19 | key2: {} 20 | 21 | --- in-json 22 | { 23 | "nested sequences": [ 24 | [ 25 | [ 26 | [] 27 | ] 28 | ], 29 | [ 30 | [ 31 | {} 32 | ] 33 | ] 34 | ], 35 | "key1": [], 36 | "key2": {} 37 | } 38 | 39 | --- test-event 40 | +STR 41 | +DOC --- 42 | +MAP 43 | =VAL :nested sequences 44 | +SEQ 45 | +SEQ 46 | +SEQ 47 | +SEQ 48 | -SEQ 49 | -SEQ 50 | -SEQ 51 | +SEQ 52 | +SEQ 53 | +MAP 54 | -MAP 55 | -SEQ 56 | -SEQ 57 | -SEQ 58 | =VAL :key1 59 | +SEQ 60 | -SEQ 61 | =VAL :key2 62 | +MAP 63 | -MAP 64 | -MAP 65 | -DOC 66 | -STR 67 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/M5DY.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.11. Mapping between Sequences 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2760799 3 | --- tags: complex-key explicit-key spec mapping sequence 4 | 5 | --- in-yaml 6 | ? - Detroit Tigers 7 | - Chicago cubs 8 | : 9 | - 2001-07-23 10 | 11 | ? [ New York Yankees, 12 | Atlanta Braves ] 13 | : [ 2001-07-02, 2001-08-12, 14 | 2001-08-14 ] 15 | 16 | --- out-yaml 17 | ? - Detroit Tigers 18 | - Chicago cubs 19 | : - 2001-07-23 20 | ? - New York Yankees 21 | - Atlanta Braves 22 | : - 2001-07-02 23 | - 2001-08-12 24 | - 2001-08-14 25 | 26 | --- test-event 27 | +STR 28 | +DOC 29 | +MAP 30 | +SEQ 31 | =VAL :Detroit Tigers 32 | =VAL :Chicago cubs 33 | -SEQ 34 | +SEQ 35 | =VAL :2001-07-23 36 | -SEQ 37 | +SEQ 38 | =VAL :New York Yankees 39 | =VAL :Atlanta Braves 40 | -SEQ 41 | +SEQ 42 | =VAL :2001-07-02 43 | =VAL :2001-08-12 44 | =VAL :2001-08-14 45 | -SEQ 46 | -MAP 47 | -DOC 48 | -STR 49 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/NKF9.tml: -------------------------------------------------------------------------------- 1 | === Empty keys in block and flow mapping 2 | --- from: @perlpunk 3 | --- tags: empty-key mapping 4 | 5 | --- in-yaml(<) 6 | --- 7 | key: value 8 | : empty key 9 | --- 10 | { 11 | key: value, : empty key 12 | } 13 | --- 14 | # empty key and value 15 | : 16 | --- 17 | # empty key and value 18 | { : } 19 | 20 | --- emit-yaml(<) 21 | --- 22 | key: value 23 | : empty key 24 | --- 25 | key: value 26 | : empty key 27 | --- 28 | : 29 | --- 30 | : 31 | 32 | --- test-event 33 | +STR 34 | +DOC --- 35 | +MAP 36 | =VAL :key 37 | =VAL :value 38 | =VAL : 39 | =VAL :empty key 40 | -MAP 41 | -DOC 42 | +DOC --- 43 | +MAP 44 | =VAL :key 45 | =VAL :value 46 | =VAL : 47 | =VAL :empty key 48 | -MAP 49 | -DOC 50 | +DOC --- 51 | +MAP 52 | =VAL : 53 | =VAL : 54 | -MAP 55 | -DOC 56 | +DOC --- 57 | +MAP 58 | =VAL : 59 | =VAL : 60 | -MAP 61 | -DOC 62 | -STR 63 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/YD5X.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.5. Sequence of Sequences 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2760351 3 | --- tags: spec sequence 4 | 5 | --- in-yaml 6 | - [name , hr, avg ] 7 | - [Mark McGwire, 65, 0.278] 8 | - [Sammy Sosa , 63, 0.288] 9 | 10 | --- in-json 11 | [ 12 | [ 13 | "name", 14 | "hr", 15 | "avg" 16 | ], 17 | [ 18 | "Mark McGwire", 19 | 65, 20 | 0.278 21 | ], 22 | [ 23 | "Sammy Sosa", 24 | 63, 25 | 0.288 26 | ] 27 | ] 28 | 29 | --- out-yaml 30 | - - name 31 | - hr 32 | - avg 33 | - - Mark McGwire 34 | - 65 35 | - 0.278 36 | - - Sammy Sosa 37 | - 63 38 | - 0.288 39 | 40 | --- test-event 41 | +STR 42 | +DOC 43 | +SEQ 44 | +SEQ 45 | =VAL :name 46 | =VAL :hr 47 | =VAL :avg 48 | -SEQ 49 | +SEQ 50 | =VAL :Mark McGwire 51 | =VAL :65 52 | =VAL :0.278 53 | -SEQ 54 | +SEQ 55 | =VAL :Sammy Sosa 56 | =VAL :63 57 | =VAL :0.288 58 | -SEQ 59 | -SEQ 60 | -DOC 61 | -STR 62 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/J9HZ.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.9. Single Document with Two Comments 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2760633 3 | --- tags: mapping sequence spec comment 4 | 5 | --- in-yaml(<) 6 | --- 7 | hr: # 1998 hr ranking 8 | - Mark McGwire 9 | - Sammy Sosa 10 | rbi: 11 | # 1998 rbi ranking 12 | - Sammy Sosa 13 | - Ken Griffey 14 | 15 | --- in-json 16 | { 17 | "hr": [ 18 | "Mark McGwire", 19 | "Sammy Sosa" 20 | ], 21 | "rbi": [ 22 | "Sammy Sosa", 23 | "Ken Griffey" 24 | ] 25 | } 26 | 27 | --- out-yaml(<) 28 | --- 29 | hr: 30 | - Mark McGwire 31 | - Sammy Sosa 32 | rbi: 33 | - Sammy Sosa 34 | - Ken Griffey 35 | 36 | --- test-event 37 | +STR 38 | +DOC --- 39 | +MAP 40 | =VAL :hr 41 | +SEQ 42 | =VAL :Mark McGwire 43 | =VAL :Sammy Sosa 44 | -SEQ 45 | =VAL :rbi 46 | +SEQ 47 | =VAL :Sammy Sosa 48 | =VAL :Ken Griffey 49 | -SEQ 50 | -MAP 51 | -DOC 52 | -STR 53 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/2EBW.tml: -------------------------------------------------------------------------------- 1 | === Allowed characters in keys 2 | --- from: @perlpunk 3 | --- tags: mapping scalar 4 | 5 | --- in-yaml 6 | a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~: safe 7 | ?foo: safe question mark 8 | :foo: safe colon 9 | -foo: safe dash 10 | this is#not: a comment 11 | 12 | --- in-json 13 | { 14 | "a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~": "safe", 15 | "?foo": "safe question mark", 16 | ":foo": "safe colon", 17 | "-foo": "safe dash", 18 | "this is#not": "a comment" 19 | } 20 | 21 | --- out-yaml 22 | a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~: safe 23 | ?foo: safe question mark 24 | :foo: safe colon 25 | -foo: safe dash 26 | this is#not: a comment 27 | 28 | --- test-event 29 | +STR 30 | +DOC 31 | +MAP 32 | =VAL :a!"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~ 33 | =VAL :safe 34 | =VAL :?foo 35 | =VAL :safe question mark 36 | =VAL ::foo 37 | =VAL :safe colon 38 | =VAL :-foo 39 | =VAL :safe dash 40 | =VAL :this is#not 41 | =VAL :a comment 42 | -MAP 43 | -DOC 44 | -STR 45 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/JHB9.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.7. Two Documents in a Stream 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2760493 3 | --- tags: spec header 4 | 5 | --- in-yaml(<) 6 | # Ranking of 1998 home runs 7 | --- 8 | - Mark McGwire 9 | - Sammy Sosa 10 | - Ken Griffey 11 | 12 | # Team ranking 13 | --- 14 | - Chicago Cubs 15 | - St Louis Cardinals 16 | 17 | --- in-json 18 | [ 19 | "Mark McGwire", 20 | "Sammy Sosa", 21 | "Ken Griffey" 22 | ] 23 | [ 24 | "Chicago Cubs", 25 | "St Louis Cardinals" 26 | ] 27 | 28 | --- out-yaml(<) 29 | --- 30 | - Mark McGwire 31 | - Sammy Sosa 32 | - Ken Griffey 33 | --- 34 | - Chicago Cubs 35 | - St Louis Cardinals 36 | 37 | --- test-event 38 | +STR 39 | +DOC --- 40 | +SEQ 41 | =VAL :Mark McGwire 42 | =VAL :Sammy Sosa 43 | =VAL :Ken Griffey 44 | -SEQ 45 | -DOC 46 | +DOC --- 47 | +SEQ 48 | =VAL :Chicago Cubs 49 | =VAL :St Louis Cardinals 50 | -SEQ 51 | -DOC 52 | -STR 53 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/229Q.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.4. Sequence of Mappings 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2760193 3 | --- tags: sequence mapping spec 4 | 5 | --- in-yaml 6 | - 7 | name: Mark McGwire 8 | hr: 65 9 | avg: 0.278 10 | - 11 | name: Sammy Sosa 12 | hr: 63 13 | avg: 0.288 14 | 15 | --- in-json 16 | [ 17 | { 18 | "name": "Mark McGwire", 19 | "hr": 65, 20 | "avg": 0.278 21 | }, 22 | { 23 | "name": "Sammy Sosa", 24 | "hr": 63, 25 | "avg": 0.288 26 | } 27 | ] 28 | 29 | --- out-yaml 30 | - name: Mark McGwire 31 | hr: 65 32 | avg: 0.278 33 | - name: Sammy Sosa 34 | hr: 63 35 | avg: 0.288 36 | 37 | --- test-event 38 | +STR 39 | +DOC 40 | +SEQ 41 | +MAP 42 | =VAL :name 43 | =VAL :Mark McGwire 44 | =VAL :hr 45 | =VAL :65 46 | =VAL :avg 47 | =VAL :0.278 48 | -MAP 49 | +MAP 50 | =VAL :name 51 | =VAL :Sammy Sosa 52 | =VAL :hr 53 | =VAL :63 54 | =VAL :avg 55 | =VAL :0.288 56 | -MAP 57 | -SEQ 58 | -DOC 59 | -STR 60 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/7BUB.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.10. Node for “Sammy Sosa” appears twice in this document 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2760658 3 | --- tags: mapping sequence spec alias 4 | 5 | --- in-yaml(<) 6 | --- 7 | hr: 8 | - Mark McGwire 9 | # Following node labeled SS 10 | - &SS Sammy Sosa 11 | rbi: 12 | - *SS # Subsequent occurrence 13 | - Ken Griffey 14 | 15 | --- in-json 16 | { 17 | "hr": [ 18 | "Mark McGwire", 19 | "Sammy Sosa" 20 | ], 21 | "rbi": [ 22 | "Sammy Sosa", 23 | "Ken Griffey" 24 | ] 25 | } 26 | 27 | --- out-yaml(<) 28 | --- 29 | hr: 30 | - Mark McGwire 31 | - &SS Sammy Sosa 32 | rbi: 33 | - *SS 34 | - Ken Griffey 35 | 36 | --- test-event 37 | +STR 38 | +DOC --- 39 | +MAP 40 | =VAL :hr 41 | +SEQ 42 | =VAL :Mark McGwire 43 | =VAL &SS :Sammy Sosa 44 | -SEQ 45 | =VAL :rbi 46 | +SEQ 47 | =ALI *SS 48 | =VAL :Ken Griffey 49 | -SEQ 50 | -MAP 51 | -DOC 52 | -STR 53 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/U9NS.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.8. Play by Play Feed from a Game 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2760519 3 | --- tags: spec header 4 | 5 | --- in-yaml(<) 6 | --- 7 | time: 20:03:20 8 | player: Sammy Sosa 9 | action: strike (miss) 10 | ... 11 | --- 12 | time: 20:03:47 13 | player: Sammy Sosa 14 | action: grand slam 15 | ... 16 | 17 | --- in-json 18 | { 19 | "time": "20:03:20", 20 | "player": "Sammy Sosa", 21 | "action": "strike (miss)" 22 | } 23 | { 24 | "time": "20:03:47", 25 | "player": "Sammy Sosa", 26 | "action": "grand slam" 27 | } 28 | 29 | --- test-event 30 | +STR 31 | +DOC --- 32 | +MAP 33 | =VAL :time 34 | =VAL :20:03:20 35 | =VAL :player 36 | =VAL :Sammy Sosa 37 | =VAL :action 38 | =VAL :strike (miss) 39 | -MAP 40 | -DOC ... 41 | +DOC --- 42 | +MAP 43 | =VAL :time 44 | =VAL :20:03:47 45 | =VAL :player 46 | =VAL :Sammy Sosa 47 | =VAL :action 48 | =VAL :grand slam 49 | -MAP 50 | -DOC ... 51 | -STR 52 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/FBC9.tml: -------------------------------------------------------------------------------- 1 | === Allowed characters in plain scalars 2 | --- from: @perlpunk 3 | --- tags: scalar 4 | 5 | --- in-yaml 6 | safe: a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~ 7 | !"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~ 8 | safe question mark: ?foo 9 | safe colon: :foo 10 | safe dash: -foo 11 | 12 | --- in-json 13 | { 14 | "safe": "a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~ !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~", 15 | "safe question mark": "?foo", 16 | "safe colon": ":foo", 17 | "safe dash": "-foo" 18 | } 19 | 20 | --- out-yaml 21 | safe: a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~ !"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~ 22 | safe question mark: ?foo 23 | safe colon: :foo 24 | safe dash: -foo 25 | 26 | --- test-event 27 | +STR 28 | +DOC 29 | +MAP 30 | =VAL :safe 31 | =VAL :a!"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~ !"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~ 32 | =VAL :safe question mark 33 | =VAL :?foo 34 | =VAL :safe colon 35 | =VAL ::foo 36 | =VAL :safe dash 37 | =VAL :-foo 38 | -MAP 39 | -DOC 40 | -STR 41 | -------------------------------------------------------------------------------- /integration-tests/src/test/resources/yaml/test-suite/HMK4.tml: -------------------------------------------------------------------------------- 1 | === Spec Example 2.16. Indentation determines scope 2 | --- from: http://www.yaml.org/spec/1.2/spec.html#id2761083 3 | --- tags: spec folded literal 4 | 5 | --- in-yaml 6 | name: Mark McGwire 7 | accomplishment: > 8 | Mark set a major league 9 | home run record in 1998. 10 | stats: | 11 | 65 Home Runs 12 | 0.278 Batting Average 13 | 14 | --- in-json 15 | { 16 | "name": "Mark McGwire", 17 | "accomplishment": "Mark set a major league home run record in 1998.\n", 18 | "stats": "65 Home Runs\n0.278 Batting Average\n" 19 | } 20 | 21 | --- out-yaml 22 | name: Mark McGwire 23 | accomplishment: > 24 | Mark set a major league home run record in 1998. 25 | stats: | 26 | 65 Home Runs 27 | 0.278 Batting Average 28 | 29 | --- test-event 30 | +STR 31 | +DOC 32 | +MAP 33 | =VAL :name 34 | =VAL :Mark McGwire 35 | =VAL :accomplishment 36 | =VAL >Mark set a major league home run record in 1998.\n 37 | =VAL :stats 38 | =VAL |65 Home Runs\n0.278 Batting Average\n 39 | -MAP 40 | -DOC 41 | -STR 42 | -------------------------------------------------------------------------------- /core/shared/src/main/scala/org/virtuslab/yaml/internal/load/TagHandle.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml.internal.load 2 | 3 | sealed abstract class TagHandle(val value: String) 4 | object TagHandle { 5 | case object Primary extends TagHandle("!") 6 | case object Secondary extends TagHandle("!!") 7 | case class Named(name: String) extends TagHandle(name) 8 | } 9 | 10 | sealed abstract class TagPrefix(val value: String) 11 | object TagPrefix { 12 | case class Local(prefix: String) extends TagPrefix(prefix) 13 | case class Global(prefix: String) extends TagPrefix(prefix) 14 | } 15 | 16 | sealed abstract class TagValue 17 | object TagValue { 18 | case object NonSpecific extends TagValue 19 | case class Verbatim(value: String) extends TagValue 20 | case class Shorthand(handle: TagHandle, rest: String) extends TagValue 21 | } 22 | 23 | final class TagSuffix(val suffix: String) extends AnyVal 24 | object TagSuffix { 25 | def apply(suffix: String): TagSuffix = new TagSuffix(suffix) 26 | } 27 | -------------------------------------------------------------------------------- /core/shared/src/main/scala-3/org/virtuslab/yaml/syntax/YamlPrimitiveCrossCompat.scala: -------------------------------------------------------------------------------- 1 | package org.virtuslab.yaml 2 | package syntax 3 | 4 | import org.virtuslab.yaml.Node.* 5 | 6 | private[yaml] trait YamlPrimitiveCompanionCrossCompat { 7 | given Conversion[String, YamlPrimitive] = s => YamlPrimitive(ScalarNode(s)) 8 | given Conversion[Boolean, YamlPrimitive] = s => YamlPrimitive(ScalarNode(s.toString)) 9 | given Conversion[Int, YamlPrimitive] = s => YamlPrimitive(ScalarNode(s.toString)) 10 | given Conversion[Long, YamlPrimitive] = s => YamlPrimitive(ScalarNode(s.toString)) 11 | given Conversion[Node, YamlPrimitive] = s => YamlPrimitive(s) 12 | 13 | given conv[A, B](using 14 | c1: Conversion[A, YamlPrimitive], 15 | c2: Conversion[B, YamlPrimitive] 16 | ): Conversion[(A, B), (YamlPrimitive, YamlPrimitive)] = (s, b) => (c1(s), c2(b)) 17 | 18 | given singleConv[A, B](using 19 | conversion: Conversion[A, YamlPrimitive] 20 | ): Conversion[(A, Node), (YamlPrimitive, YamlPrimitive)] = (s, b) => 21 | (conversion(s), YamlPrimitive(b)) 22 | } 23 | --------------------------------------------------------------------------------