commit e303cbe543cd1809f996fc4d17c1bff87ba6890b Author: Ethiraric Date: Sat Oct 12 16:15:38 2024 +0200 Squashed 'parser/tests/yaml-test-suite/' content from commit ccfa74e5 git-subtree-dir: parser/tests/yaml-test-suite git-subtree-split: ccfa74e56afb53da960847ff6e6976c0a0825709 diff --git a/.bpan/run-or-docker.bash b/.bpan/run-or-docker.bash new file mode 100644 index 0000000..44e46cf --- /dev/null +++ b/.bpan/run-or-docker.bash @@ -0,0 +1,351 @@ +#!/bash + +# shellcheck disable=2030,2031,2154 + +set -e -u -o pipefail + +# shellcheck disable=2206 +declare -a docker_run_options=(${RUN_OR_DOCKER_OPTIONS-}) +RUN_OR_DOCKER_PULL=${RUN_OR_DOCKER_PULL:-false} +RUN_OR_DOCKER_PUSH=${RUN_OR_DOCKER_PUSH:-false} + +run() ( + verbose=${RUN_OR_DOCKER_VERBOSE:-false} + bin=$(dirname "${BASH_SOURCE[1]}") + self=$(basename "${BASH_SOURCE[1]}") + root=${ROOT:-$PWD} + prog=$(cd "$bin" && echo "$self".*) + version=${version:-$(calculate-version)} + image=yamlio/$self:$version + + if [[ $prog == *'.*' ]]; then + prog=$self + lang=bash + else + case $prog in + *.sh) lang=bash ;; + *.bash) lang=bash ;; + *.pl) lang=perl ;; + *.py) lang=python3 ;; + *.rb) lang=ruby ;; + *) die "Don't recognize language of '$prog'" ;; + esac + fi + + if $RUN_OR_DOCKER_PUSH; then + build-docker-image + exit + fi + + if [[ -e /.dockerenv || ${RUN_OR_DOCKER-} == local ]]; then + if [[ $self == "$prog" ]]; then + main "$@" + else + run-local "$@" + fi + return + fi + + if [[ ${RUN_OR_DOCKER-} == force* || ${GITHUB_ACTIONS-} ]]; then + run-docker "$@" + return + fi + + out=$(check 2>/tmp/out) && rc=0 || rc=$? + + err=$(< /tmp/out) + + [[ $rc == 0 || $err == FAIL:* ]] || die "Error: $err" + + if [[ $rc -eq 0 ]]; then + run-local "$@" + else + $verbose && + echo "Can't run '$self' locally: ${err#FAIL:\ }" >&2 + echo "Running '$self' with docker..." >&2 + run-docker "$@" + fi +) + +run-local() ( + export RUN_OR_DOCKER=local + "$lang" "$bin/$prog" "$@" +) + +run-docker() ( + if [[ ${RUN_OR_DOCKER-} == force-build ]]; then + build-docker-image + else + docker inspect --type=image "$image" &>/dev/null && + ok=true || ok=false + if ! $ok; then + if $RUN_OR_DOCKER_PULL; then + ( + $verbose && set -x + docker pull "$image" + ) + else + build-docker-image + fi + fi + fi + + args=() + docker_run_options+=( + --env ROOT=/home/host + ) + for arg; do + if [[ $arg == "$root"/* ]]; then + arg=/home/host/${arg#$root/} + fi + args+=("$arg") + done + + flags=() + [[ -t 0 ]] && flags+=('--tty') + + workdir=/home/host + [[ ${RUN_OR_DOCKER_WORKDIR-} ]] && + workdir=$workdir/$RUN_OR_DOCKER_WORKDIR + + uid=$(id -u) + gid=$(id -g) + + $verbose && set -x + docker run "${flags[@]}" --interactive --rm \ + --volume "$root":/home/host \ + --workdir "$workdir" \ + --user "$uid:$gid" \ + --entrypoint '' \ + "${docker_run_options[@]}" \ + "$image" \ + "$self" "${args[@]}" +) + +force() { + fail 'docker is forced here' +} + +need() { + cmd=$1 + + [[ $(command -v "$cmd") ]] || + fail "requires command '$cmd'" + + [[ ${2-} ]] || return 0 + + if [[ ${2-} =~ ^[0-9]+(\.|$) ]]; then + check=need-version + else + check=need-modules + fi + + "$check" "$@" +} + +need-version() { + cmd=$1 ver=$2 + + if [[ $("$cmd" --version) =~ ([0-9]+)\.([0-9]+)(\.[0-9]+)? ]]; then + set -- "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[3]#.}" + else + die "Could not get version from '$cmd --version'" + fi + + vers=$ver + while [[ $vers && $* ]]; do + v=${vers%%.*} + if [[ $1 -gt $v ]]; then + return + elif [[ $1 -lt $v ]]; then + fail "requires '$cmd' version '$ver' or higher" + fi + if [[ $vers != *.* ]]; then + return + fi + vers=${vers#*.} + shift + done + fail "requires '$cmd' version '$ver' or higher" +} + +need-modules() { + cmd=$1; shift + + for module; do + case $cmd in + perl) + if [[ $module == *=* ]]; then + want=$module + version=${module#*=} + module=${module%=*} + perl -M"$module"\ "$version" -e1 &>/dev/null || + fail "'$cmd' requires Perl module '$want'" + else + want=$module + perl -M"$module" -e1 &>/dev/null || + fail "'$cmd' requires Perl module '$module'" + fi + ;; + node) + node -e "require('$module');" &>/dev/null || + fail "'$cmd' requires NodeJS module '$module'" + ;; + python) + python3 -c "import $module" &>/dev/null || + fail "'$cmd' requires Python(3) module '$module'" + ;; + ruby) + list=$(gem list) + if [[ $module == *=* ]]; then + version=${module#*=} + module=${module%=*} + else + version=0 + fi + (set -x; ruby -e "gem '$module', '>=$version'") &>/dev/null || + fail "'$cmd' requires Ruby module '$module' >= v$version" + ;; + *) die "Can't check module '$module' for '$cmd'" ;; + esac + done +} + +build-docker-image() ( + build=$(mktemp -d) + + build-fail() { fail "docker-build failed: $*"; } + + cmd() ( + _args=${1//\ \+\ /\ &&\ } + echo "$_args" + echo + ) + + run() ( + cmd "RUN $*" + ) + + from() { + _from=$1 + case $_from in + alpine) + cmd 'FROM alpine' + cmd 'WORKDIR /home' + cmd 'RUN apk update && apk add bash build-base coreutils' + ;; + ubuntu) + cmd 'FROM ubuntu:20.04' + cmd 'WORKDIR /home' + cmd 'RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential' + ;; + *) build-fail "from $*" + esac + } + + pkg() ( + case $_from in + alpine) + cmd "RUN apk add $*" + ;; + ubuntu) + cmd "RUN DEBIAN_FRONTEND=noninteractive apt-get install -y $*" + ;; + *) build-fail "pkg $*" + esac + ) + + cpan() ( + case $_from in + alpine) + pkg perl perl-dev perl-app-cpanminus wget + ;; + ubuntu) + pkg cpanminus + ;; + *) build-fail "cpan $*" + esac + + cmd "RUN cpanm -n $*" + ) + + npm() ( + case $_from in + alpine) + pkg nodejs npm + ;; + *) build-fail "npm $*" + esac + + cmd "RUN mkdir node_modules && npm install $*" + ) + + gem() ( + case $_from in + alpine) + pkg ruby + ;; + *) build-fail "npm $*" + esac + + for module; do + if [[ $module == *=* ]]; then + module="${module%=*} -v ${module#*=}" + fi + + cmd "RUN gem install $module" + done + ) + + pip() ( + case $_from in + alpine) + pkg python3 py3-pip + ;; + *) build-fail "npm $*" + esac + + cmd "RUN pip3 install $*" + ) + + ( + dockerfile + bin=$(dirname "$0") + bin=${bin#$root/} + if [[ $bin == bin ]]; then + cmd "ENV PATH=/home/host/bin:\$PATH" + else + cmd "ENV PATH=/home/host/$bin:/home/host/bin:\$PATH" + fi + ) > "$build/Dockerfile" + + + ( + set -x + cd "$build" + docker build -t "$image" . + ) + + rm -fr "$build" + + if $RUN_OR_DOCKER_PUSH; then + ( + set -x + docker push "$image" + ) + fi +) + +calculate-version() ( + [[ ${uses-} ]] || + die "'$0' requires either '\$version' variable or '\$uses' array" + + cd "$(dirname "$0")" || exit + + cat "${uses[@]}" | + md5sum | + cut -d' ' -f1 +) + +fail() { echo "FAIL: $*" >&2; exit 1; } +die() { echo "$*" >&2; exit 1; } diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..537d9f5 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,15 @@ +name: yaml-test-suite Repository Testing + +on: + push: + pull_request: + types: [opened] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - run: make test + # - uses: mxschmitt/action-tmate@v3 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dfface0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +/data/ +/gh-pages/ +/export.tsv +/import.tsv +/matrix/ +/new/ +/node_modules/ +/testml/ diff --git a/License b/License new file mode 100644 index 0000000..5059e95 --- /dev/null +++ b/License @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016-2020 Ingy döt Net + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..54dda81 --- /dev/null +++ b/Makefile @@ -0,0 +1,124 @@ +SHELL := bash + +export ROOT := $(shell pwd) + +export PATH := $(ROOT)/bin:$(PATH) + +CONFIG_MK := $(ROOT)/../yaml-test-runtimes/Config.mk + +ifneq (,$(wildcard $(CONFIG_MK))) + include $(CONFIG_MK) + YAML_TEST_RUNTIMES_VERSION := $(TAG_MAIN) +endif +ifneq (,$(YAML_TEST_RUNTIMES_VERSION)) + export YAML_TEST_RUNTIMES_VERSION +endif + +BPAN := .bpan +COMMON := ../yaml-common + +SRC ?= src/*.yaml + +ifneq (,$(DOCKER)) + export RUN_OR_DOCKER := $(DOCKER) +endif + +default: + +docker: + $(eval override export RUN_OR_DOCKER := force) + @true + +docker-build: + RUN_OR_DOCKER=force-build suite-to-data + +verbose: + $(eval override export RUN_OR_DOCKER_VERBOSE := true) + @true + +test: + ! $$(git rev-parse --is-shallow-repository) || \ + git fetch --unshallow + make data + make clean + make data-update + GIT_PAGER=cat make data-diff + make data-status + make clean + make gh-pages + make clean + +add-new: + for f in new/*; do cp "$$f" "src/$${f#*-}"; done + +import: import.tsv + ./bin/tsv-to-new $< + +import.tsv: + $(error 'make import' requires a '$@' file) + +export: export.tsv + +run-tests: +ifndef YAML_TEST_RUNTIMES_VERSION + $(error Set YAML_TEST_RUNTIMES_VERSION) +endif + $(eval override export YTS_TEST_RUNNER := true) + @true + +export.tsv: + time ./bin/suite-to-tsv $(SRC) > $@ + +new-test: + new-test-file + +testml: + suite-to-testml $(SRC) + +data: + git branch --track $@ origin/$@ 2>/dev/null || true + git worktree add -f $@ $@ + +data-update: data + rm -fr $/dev/null + +#------------------------------------------------------------------------------ + +gh-pages: + git branch --track $@ origin/$@ 2>/dev/null || true + git worktree add $@ $@ diff --git a/ReadMe.md b/ReadMe.md new file mode 100644 index 0000000..4064055 --- /dev/null +++ b/ReadMe.md @@ -0,0 +1,173 @@ +YAML Test Suite +=============== + +Comprehensive Test Suite for YAML + +## Overview + +This repository contains data for testing the correctness of YAML processors. + +The types of data include: + +* Metadata about the test + * Name (short phrase) + * Tags + * Description +* Input YAML +* Canonical output YAML +* Matching JSON +* Token stream notation +* Event stream notation +* Error data +* etc + +To get a quick overview of the tests you can have a look at the [YAML Test +Matrix](http://matrix.yaml.info/), made from +. + +You can also view the latest test results from 15 different parsers in +[this Google sheet](https://tinyurl.com/2p97ah8a). + +## Usage + +The tests are available in 2 forms. +Files in the `src` directory encode all the data for YAML using YAML. +The data from these tests is also available in a form where each test +has its own directory. + +For that, use the latest data release under +[https://github.com/yaml/yaml-test-suite/releases]( +https://github.com/yaml/yaml-test-suite/releases): + + git clone https://github.com/yaml/yaml-test-suite -b data-YYYY-MM-DD + +There are tests which have multiple similar subtests. Those subtests are +in their own numeric directories under the parent id, e.g.: + + VJP3/ + VJP3/00 + VJP3/00/=== + VJP3/00/error + VJP3/00/in.yaml + VJP3/00/test.event + VJP3/01 + ... + + +The releases are made from the `data` branch, which is made from the data in +the YAML in the `main` branch. +You shouldn't use the data branch directly as the branch contains unreleased +commits which might be wrong, and it is squashed and force pushed from time to +time. + +### Special Characters + +The YAML files use a number of non-ascii unicode characters to indicate the +presence of certain characters that would be otherwise hard to read. + +* `␣` is used for trailing space characters +* Hard tabs are reresented by one of: (expanding to 4 spaces) + * `———»` + * `——»` + * `—»` + * `»` +* `↵` us used to show trailing newline characters +* `∎` is used at the end when there is no final newline character +* `←` indicates a carriage return character +* `⇔` indicates a byte order mark (BOM) character + +Also these are used in test event output: + +* `` for a space character +* `` for a tab character + +## The `data` branch files + +The YAML test files in the `src/` dir are turned into data files in the `data` +branch. +The `make data-update` command generates the `data` branch files under the +`./data/` directory. +For instance, a file `src/AB3D.yaml` will generate a `data/AB3D/` directory. + +A YAML test file can have 1 or more tests. +Originally each file had one test, and all the data files were under +`data/AB3D/`. +If a YAML test file has more than one test, subdirectories are created: +`data/AB3D/00/`, `data/AB3D/01/`, `data/AB3D/02/`, etc. + +The test files are: + +* `===` -- The name/label of the test +* `in.yaml` -- The YAML input to be parsed or loaded +* `test.event` -- The event DSL produced by the parser test program +* `in.json` -- The JSON value that shoiuld load the same as `in.yaml` +* `out.yaml` -- The most normal output a dumper would produce +* `error` -- This file indicates the YAML should fail to parse +* `emit.yaml` -- Output an emitter would produce + +## Makefile Targets + +The Makefile has a number of targets for automating the process of adding new +tests and also preprocessing them into the `data` branch. + +* `make data` + + Create a `data` worktree subdirectory with all the tests as data files. + +* `make data-update` + + Update the `data` branch directory with the latest info in the `src` + directory. + +* `make export` + + Creates an `export.tsv` file with all the data from the `src` test files. + This tsv data can be copied into a google spreadsheet. + The [YAML parser playground](https://play.yaml.io/main/parser) has a button + to copy a test to the same tsv form. + +* `make import` + + Make a directory called `new` from a file named `import.tsv`. + The `import.tsv` file should have data copied from a google spreadsheet. + +* `make add-new` + + Copy the new tests under `new/` into `src/` to make a PR for new tests. + +* `make testml` + + Generate `.tml` files under a `testml/` directory for all the suite tests. + +* `make clean` + + Remove generated files and directories. + +## Libaries using this test suite + +* C + * [libyaml](https://github.com/yaml/libyaml) + * [libfyaml](https://github.com/pantoniou/libfyaml) +* C++ + * [rapidyaml](https://github.com/biojppm/rapidyaml) +* C# + * [YamlDotNet](https://github.com/aaubry/YamlDotNet) +* D + * [dyaml](https://github.com/dlang-community/D-YAML) +* Delphi + * [Neslib.Yaml](https://github.com/neslib/Neslib.Yaml) +* Haskell + * [HsYAML](https://github.com/haskell-hvr/HsYAML) +* Java + * [SnakeYAML Engine](https://bitbucket.org/asomov/snakeyaml-engine) +* Javascript + * [yaml](https://github.com/eemeli/yaml) +* Nim + * [NimYAML](https://github.com/flyx/NimYAML) +* Perl 5 + * [YAML::PP](https://github.com/perlpunk/YAML-PP-p5) +* Scala + * [Scala-Yaml](https://github.com/VirtusLab/scala-yaml) + +If your library is using the test suite, drop us a line and we can add it here. +It would also be nice if you could add a link back to this test suite. diff --git a/bin/YAMLTestSuite.pm b/bin/YAMLTestSuite.pm new file mode 100644 index 0000000..c0a2603 --- /dev/null +++ b/bin/YAMLTestSuite.pm @@ -0,0 +1,129 @@ +#------------------------------------------------------------------------------ +# Common code for the bin/suite-to-* programs. +#------------------------------------------------------------------------------ + +package YAMLTestSuite; +use strict; use warnings; + +use utf8; +use autodie qw(open close); +use Encode; +use MIME::Base64; +use YAML::PP; + +my $ypp = YAML::PP->new; + +sub new { + my $class = shift; + my $self = bless { + data => undef, + id => undef, + num => undef, + ID => undef, + file => 0, + skip => 0, + make => 0, + }, $class; + return $self; +} + +sub initial {} +sub done {} +sub final {} +sub skip {1} + +sub run { + my ($self, $files) = @_; + + $self->initial; + + for my $file (@$files) { + $self->{file}++; + + $file =~ m{^.*/(.*)\.yaml$} or die; + $self->{id} = $1; + + # next unless $1 eq '6BFJ'; + + my $data = $ypp->load_file($file); + + if ($data->[0]{skip} and $self->skip) { + $self->{skip}++; + next; + } + + my $multi = $self->{multi} = (@$data > 1) || 0; + my $l = $multi + ? int(log(@$data - 1) / log(10)) + 2 + : 2; + my $cache = {}; + my $i = 0; + + for my $test (@$data) { + $self->{make}++; + $self->{data} = $test; + $self->{num} = sprintf "%0${l}d", $i++; + my $ID = $self->{ID} = $multi + ? "$self->{id}-$self->{num}" + : $self->{id}; + + die "Can't change test name in '$ID'" + if $test->{name} and $cache->{name}; + + $test->{name} ||= $cache->{name} or die; + $test->{tags} ||= $cache->{tags} || ''; + $test->{yaml} ||= $cache->{yaml} or die; + $test->{fail} = exists $test->{fail} ? 1 : 0; + + $self->{slug} = lc $test->{name}; + $self->{slug} =~ s/[^\w]+/-/g; + $self->{slug} =~ s/^-//; + $self->{slug} =~ s/-$//; + + for my $key (qw< tree json dump emit toke >) { + if ( + not exists $test->{$key} and + defined $cache->{$key} + ) { + $test->{$key} = $cache->{$key}; + } + } + + $cache = { %$test }; + + $self->make; + } + + $self->done; + } + + $self->final; +} + +sub unescape { + my ($self, $text) = @_; + + $text =~ s/␣/ /g; + $text =~ s/—*»/\t/g; + $text =~ s/←/\r/g; + $text =~ s/⇔/x{FEFF}/g; + $text =~ s/↵//g; + $text =~ s/∎\n\z//; + + return $text; +} + +sub play_url { + my ($self, $text) = @_; + + $text = encode_utf8 $self->unescape($text); + + my $base64 = encode_base64($text); + $base64 =~ s{\n}{}g; + $base64 =~ s{\+}{-}g; + $base64 =~ s{/}{_}g; + + return "https://play.yaml.io/main/parser?input=$base64"; +} + +1; diff --git a/bin/new-test-file b/bin/new-test-file new file mode 100755 index 0000000..e77313c --- /dev/null +++ b/bin/new-test-file @@ -0,0 +1,82 @@ +#!/usr/bin/env bash + +version=0.0.1 + +source "${ROOT:-$PWD}/.bpan/run-or-docker.bash" + +check() ( + need bash 4.4 +) + +dockerfile() ( + from alpine + pkg vim +) + +main() ( + id=$(new-test-id) + tmp=$(mktemp -d) + orig=$tmp/yaml + edit=$tmp/$id.yaml + new=src/$id.yaml + + trap 'rm -fr $tmp' exit + + template > "$orig" + cp "$orig" "$edit" + + "${editor:-vim}" "$edit" + + echo + if diff "$edit" "$orig" &>/dev/null; then + echo "New test case aborted" + else + cp "$edit" "$new" + echo "Created new test case: '$new'" + fi +) + +template() ( + cat <<... +--- +- name: + + from: '@your-github-id' + + tags: alias anchor comment complex-key directive document double duplicate-key edge empty-key empty error explicit-key flow folded footer header indent literal local-tag mapping scalar sequence simple single spec tag whitespace + + # error: true + # skip: true + + yaml: | + --- + name: YAML + ... + + tree: | + +STR + +DOC --- + +SEQ + +MAP + =VAL :name + =VAL :YAML + -MAP + -SEQ + -DOC ... + -STR + + json: | + [ + { + "name": "YAML" + } + ] + + dump: | + --- + name: YAML + +... +) + +run "$@" diff --git a/bin/new-test-id b/bin/new-test-id new file mode 100755 index 0000000..419371a --- /dev/null +++ b/bin/new-test-id @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +( + while true; do + id=$( + cat /dev/urandom | + LC_ALL=C tr -cd A-HJ-NP-Z2-9 | + fold -w4 | + grep '[A-Z]' | + grep '[0-9]' | + head -n1 + ) + + [[ -e src/$id.yaml ]] || break + done + + echo "$id" +) + diff --git a/bin/run-all-parsers b/bin/run-all-parsers new file mode 100755 index 0000000..5a15b88 --- /dev/null +++ b/bin/run-all-parsers @@ -0,0 +1,157 @@ +#!/usr/bin/env bash + +#------------------------------------------------------------------------------ +# +# This program runs inside a Docker container that contains every known YAML +# parser that supports the parse event DSL output. +# +# It is used to run every test in the suite against each YAML parser. +# +#------------------------------------------------------------------------------ + +set -e -u -o pipefail + +main() ( + id=$ID + tmp=/tmp/test/$id + + set -- $RUNNERS + + run-all-parsers "$@" + + write-tsv-line "$@" +) + +run-all-parsers() ( + cat > "$tmp-input.yaml" + + for parser; do + ( + timeout 5 \ + "$parser" \ + < "$tmp-input.yaml" \ + > "$tmp-$parser.stdout" \ + 2> "$tmp-$parser.stderr" || ( + echo $? > "$tmp-$parser.err" + ) + ) & + done + + wait +) + +write-tsv-line() ( + refparser=$1 + shift + + if [[ -e $tmp-$refparser.err ]]; then + got_ref='' + else + got_ref=$(< "$tmp-$refparser.stdout") + fi + + out='' + for parser; do + want=$got_ref + + if [[ -e $tmp-$parser.err ]]; then + got='' + elif [[ + -s $tmp-$parser.stderr && + $(< "$tmp-$parser.stdout") != *-STR + ]]; then + got='' + else + got=$(grep -v '=COMMENT' < "$tmp-$parser.stdout" || true) + fi + + if [[ $parser == *-rustyaml ]]; then + got=$(adjust-got-for-rust <<<"$got") + want=$(adjust-want-for-rust <<<"$want") + fi + + if [[ $parser == *-rapid ]]; then + got=$(adjust-got-for-rapid <<<"$got") + want=$(adjust-want-for-rapid <<<"$want") + fi + + if [[ $parser == *-refhs ]]; then + [[ $got =~ (=ERR|=REST) ]] && got='' + if [[ $got && $want ]]; then + out+=$'\t' + elif [[ ! $got && ! $want ]]; then + out+=$'\t' + else + out+=$'\tx' + fi + else + [[ $got =~ $'\n'-STR$ ]] || got='' + if [[ $got == "$want" ]]; then + out+=$'\t' + else + got=${got//+MAP\ \{\}/+MAP} + got=${got//+SEQ\ \[\]/+SEQ} + want2=${want//+MAP\ \{\}/+MAP} + want2=${want2//+SEQ\ \[\]/+SEQ} + + # Ignore Go parser bug: + got=${got//+DOC\ ---/+DOC} + want2=${want2//+DOC\ ---/+DOC} + + if [[ $got == "$want2" ]]; then + out+=$'\t' + else + out+=$'\tx' + fi + fi + fi + done + + printf '%s' "$out" +) + +adjust-got-for-rust() { + perl -p0e ' + s///g; + s///g; + s///g; + s//<$1>/g; + s//<$1>/g; + ' +} + +adjust-want-for-rust() { + perl -p0e ' + s/^\+DOC ---$/+DOC/gm; + s/^-DOC \.\.\.$/-DOC/gm; + s/^=VAL :$/=VAL :~/gm; + s/^\+MAP\ \{\}(\ ?)/+MAP$1/gm; + s/^\+SEQ\ \[\](\ ?)/+SEQ$1/gm; + + my ($c, %a) = (1); + s{^(\+MAP|\+SEQ|=VAL|=ALI) (&|\*)(\S+)(.*)} + {"$1 $2".($2 eq "&" ? ($a{$3} = $c++) : $a{$3}).$4}gem; + ' +} + +adjust-got-for-rapid() { + perl -p0e ' + s/^\+DOC ---/+DOC/gm; + ' +} + +adjust-want-for-rapid() { + perl -p0e ' + s/^=VAL ((?:&\S+ |<\S*> )*)[">|]/=VAL $1'"'"'/gm; + s/^\+DOC ---/+DOC/gm; + s/^-DOC \.\.\./-DOC/gm; + ' +} + +warn() ( echo "$*" >&2 ) + +die() ( echo "$*" >&2; exit 1 ) + +[[ -f /.dockerenv ]] || die "Not in docker" + +main "$@" diff --git a/bin/suite-to-data b/bin/suite-to-data new file mode 100755 index 0000000..376373d --- /dev/null +++ b/bin/suite-to-data @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +#------------------------------------------------------------------------------ +# +# This program runs bin/suite-to-data.pl using Docker if the Perl module +# dependencies are not installed locally. +# +#------------------------------------------------------------------------------ + +version=0.0.8 + +RUN_OR_DOCKER_PULL=true + +source "${ROOT:-$PWD}/.bpan/run-or-docker.bash" + +check() ( + need bash 4.4 + need perl 5.28 + need perl YAML::PP=0.030 +) + +dockerfile() ( + from alpine + cpan YAML::PP@0.030 +) + +run "$@" diff --git a/bin/suite-to-data.pl b/bin/suite-to-data.pl new file mode 100644 index 0000000..77aae17 --- /dev/null +++ b/bin/suite-to-data.pl @@ -0,0 +1,92 @@ +#!/usr/bin/env perl + +#------------------------------------------------------------------------------ +# +# This program turn all the tests under the src/ directory into test data files +# under the `data` directory. +# +#------------------------------------------------------------------------------ + +use strict; use warnings; +use FindBin; +use lib $FindBin::Bin; +use base 'YAMLTestSuite'; +use Encode; +use File::Path qw(make_path); + +my %map = ( + 'name' => '===', + 'fail' => 'error', + 'yaml' => 'in.yaml', + 'tree' => 'test.event', + 'json' => 'in.json', + 'dump' => 'out.yaml', + 'emit' => 'emit.yaml', + 'toke' => 'lex.token', +); + +die "'data' directory not empty" if glob('data/*'); +# mkdir my $meta_dir = "data/meta"; +mkdir my $name_dir = "data/name"; +mkdir my $tags_dir = "data/tags"; + +main->new->run([@ARGV]); + +sub make { + my ($self) = @_; + + my ($id, $ID, $num, $data, $multi, $slug) = + @$self{qw}; + + my $test_dir = "data/$id"; + mkdir $test_dir unless -d $test_dir; + + if ($multi) { + $test_dir .= "/$num"; + mkdir $test_dir or die $test_dir; + } + + for my $k (sort keys %map) { + $_ = $data->{$k}; + if (defined $_) { + if ($k eq 'name') { + $_ .= "\n"; + } + elsif ($k eq 'fail') { + next unless $_; + $_ = ''; + } + elsif ($k eq 'tree') { + s/^\s+//mg; + s/\n*\z/\n/; + } + + $_ = $self->unescape($_); + + open my $out, '>', "$test_dir/$map{$k}" or die; + print $out encode_utf8($_); + close $out; + } + } + + if ($num == 0) { + # symlink $data->{name}, "$meta_dir/$id.label"; + symlink "../$id", "$name_dir/$slug"; + } + + for my $tag (split /\s+/, $data->{tags}) { + mkdir "$tags_dir/$tag"; + if ($multi) { + mkdir "$tags_dir/$tag/$id"; + symlink "../../../$id/$num", "$tags_dir/$tag/$id/$num"; + } + else { + symlink "../../$id", "$tags_dir/$tag/$id"; + } + } +} + +sub final { + my ($self) = @_; + warn "Wrote $self->{make} data tests.\n"; +} diff --git a/bin/suite-to-testml b/bin/suite-to-testml new file mode 100755 index 0000000..049fd19 --- /dev/null +++ b/bin/suite-to-testml @@ -0,0 +1,64 @@ +#!/usr/bin/env perl + +#------------------------------------------------------------------------------ +# +# This program turns all the tests in the src/ directory into TestML tests +# under a testml/ directory. +# It is run by the `make testml` command. +# +#------------------------------------------------------------------------------ + +use strict; use warnings; +use FindBin; +use lib $FindBin::Bin; +use base 'YAMLTestSuite'; +use Encode; + +main->new->run([@ARGV]); + +sub initial { + my ($self) = @_; + $self->{tml} = ''; + mkdir 'testml'; +} + +sub done { + my ($self) = @_; + open my $out, '>', "testml/$self->{id}.tml" or die; + print $out encode_utf8($self->{tml}); + close $out; + $self->{tml} = ''; +} + +my $name; +sub make { + my ($self) = @_; + + my ($id, $ID, $num, $data) = + @$self{qw}; + + my ($name, $yaml, $tree, $fail) = + @$data{qw}; + + $yaml =~ s/^(.)/ $1/gm; + $tree =~ s/^\ +//gm; + + $self->{tml} .= <<"..."; +=== $ID - $name + +--- in-yaml(<) +$yaml +... + + if ($fail) { + $self->{tml} .= "--- error\n\n"; + } + else { + $self->{tml} .= "--- test-event\n$tree\n"; + } +} + +sub final { + my ($self) = @_; + warn "Wrote $self->{file} TestML files.\n"; +} diff --git a/bin/suite-to-tsv b/bin/suite-to-tsv new file mode 100755 index 0000000..380f79d --- /dev/null +++ b/bin/suite-to-tsv @@ -0,0 +1,204 @@ +#!/usr/bin/env perl + +#------------------------------------------------------------------------------ +# +# This program turns the all tests under src/ into a TSV format that can be +# copy/pasted into a Google sheet. +# +# It is called by `make export` which writes the TSV into `export.tsv`. +# If you use `make run-tests export` it will run each test against each +# supported parser and add any failure indicators to the TSV data. +# +#------------------------------------------------------------------------------ + +use strict; use warnings; +use FindBin; +use lib $FindBin::Bin; +use base 'YAMLTestSuite'; +use Capture::Tiny ':all'; +use Cwd; +use Encode; + +my $container_id; + +sub kill_docker_container { + if ($container_id) { + my ($out, $err, $rc) = capture { + system("docker kill $container_id"); + }; + } + exit; +} + +END { + kill_docker_container(); +} + +BEGIN { + `rm -fr /tmp/test`; + mkdir "/tmp/test" or die; + + if ($ENV{YTS_TEST_RUNNER}) { + my $cwd = getcwd; + my ($out, $err, $rc) = capture { + system( + "docker run -d " . + "-v $cwd:/host " . + "-v /tmp/test:/tmp/test " . + "yamlio/yaml-test-runtimes:$ENV{YAML_TEST_RUNTIMES_VERSION} " . + "sleep 600"); + }; + die "docker run failed" unless $rc == 0; + chomp $out; + $container_id = $out; + $SIG{INT} = \&kill_docker_container; + } +} + +my @test_runners = (qw< + yaml-test-parse-refparse + yaml-test-parse-refhs + yaml-test-parse-dotnet + yaml-test-parse-goyaml + yaml-test-parse-hsyaml + yaml-test-parse-libfyaml + yaml-test-parse-libyaml + yaml-test-parse-luayaml + yaml-test-parse-nimyaml + yaml-test-parse-npmyaml + yaml-test-parse-ppyaml + yaml-test-parse-pyyaml + yaml-test-parse-rapid + yaml-test-parse-ruamel + yaml-test-parse-rustyaml + yaml-test-parse-snake + yaml-test-parse-snakeeng +>); + +my @tag_names = (qw< + alias + anchor + binary + comment + complex-key + directive + double + duplicate-key + edge + empty + empty-key + error + explicit-key + flow + folded + footer + header + indent + literal + local-tag + mapping + missing + scalar + sequence + simple + single + spec + tag + unknown-tag + whitespace +>); + +main->new->run([@ARGV]); + +sub make { + my ($self) = @_; + + my $id = $self->{ID}; + my $data = $self->{data}; + + my $name = $data->{name}; + + my $skip = $data->{skip} ? 'X' : ''; + + my $yaml = $data->{yaml}; + $yaml =~ s/"/""/g; + $yaml = qq{"$yaml"}; + + my $tree = $data->{tree}; + $tree =~ s/"/""/g; + chomp $tree; + $tree = qq{"$tree"}; + $tree = 'ERROR' if $data->{fail}; + + my $play = $self->play_url($data->{yaml}); + + print STDERR "\r\e[K$id"; + my @test = $self->run_tests($id, $data->{yaml}); + my @tags = $self->get_tags($data->{tags}); + + my $tsv = encode_utf8 join("\t", + ( + $play, + $id, + $name, + $yaml, + $tree, + @test, + @tags, + ) + ) . "\n"; + + print $tsv; +} + +sub run_tests { + my ($self, $id, $yaml) = @_; + $yaml = $self->unescape($yaml); + + if (not $ENV{YTS_TEST_RUNNER}) { + return ('') x scalar(@test_runners); + } + my ($out, $err, $rc) = capture { + open my $pipe, '|-', + "docker exec -i " . + "--env ID=$id " . + "--env RUNNERS='@test_runners' " . + "$container_id " . + "/host/bin/run-all-parsers" + or die; + print $pipe encode_utf8($yaml); + close $pipe; + return 0; + }; + + # warn "out>>$out<<"; + # warn "err>>$err<<"; + + die "docker run failed:\nrc: $rc\nstdout:\n$out\nstderr:\n$err\n" + unless $rc == 0; + + my @tests = split /\t/, $out, -1; + + return @tests; +} + +sub get_tags { + my ($self, $tags) = @_; + $tags ||= ''; + my @tags = split /\s+/, $tags; + my @list; + for my $tag (@tag_names) { + if (grep {$_ eq $tag} @tags) { + push @list, 'x'; + } + else { + push @list, ''; + } + } + return @list; +} + +sub final { + my ($self) = @_; + print STDERR "\r\e[K\n\nWrote $self->{make} rows.\n"; +} diff --git a/bin/tsv-to-json b/bin/tsv-to-json new file mode 100755 index 0000000..f33bf77 --- /dev/null +++ b/bin/tsv-to-json @@ -0,0 +1,39 @@ +#!/usr/bin/env perl + +use strict; use warnings; +use JSON::PP; + +$_ = do { local $/; }; +s/(?=[^\n])\z/\n/; + +my $rows = []; +my $row = []; +my $cell = ''; +my $E = '(?=[\t\n]|\z)'; +while (length != 0) { + # warn ">>${\ substr($_, 0, 30)}<<\n"; + if (s/^\t//) { + push @$row, $cell; + $cell = ''; + next; + } + if (s/^\n//) { + push @$row, $cell; + $cell = ''; + push @$rows, $row; + $row = []; + next; + } + if (s/\A"((?:""|.)*?)"$E//s) { + $cell = $1; + $cell =~ s/""/"/g; + } + elsif (s/\A(.*?)$E//) { + $cell = $1; + } + else { + die "failed to parse here >>${\ substr($_, 0, 80)}<<"; + } +} + +print JSON::PP->new->encode($rows); diff --git a/bin/tsv-to-new b/bin/tsv-to-new new file mode 100755 index 0000000..7e51410 --- /dev/null +++ b/bin/tsv-to-new @@ -0,0 +1,99 @@ +#!/usr/bin/env bash + +set -e -u -o pipefail + +die() { echo "$*" >&2; exit 1; } + +root=$(cd "$(dirname "$0")/.." && pwd) +bin=$root/bin + +tsv=$1 +dir=$root/new + +rm -fr "$dir" +mkdir "$dir" + +if [[ -e .git/githubid ]]; then + from=$(< .git/githubid) +else + from=$( + ssh git@github.com |& + perl -ne '/Hi (\w+)! You/ and print $1' + ) || true + from=@${from:-${USER:?}} + echo -n "$from" > .git/githubid +fi + +mapfile -t each < <(tsv-to-json < "$tsv" | jq -c '.[]') +mapfile -t head < <(jq -r '.[]' <<<"${each[0]}") +each=("${each[@]:1}") + +# Get all tags. (First tag is 'alias') +found=false +for (( tag_idx = 0; tag_idx < ${#head[*]}; tag_idx++ )); do + [[ ${head[tag_idx]} == alias ]] && found=true && break +done +$found || die "No 'alias' cell. Did you forget the header line?" +tag_name=("${head[@]:$tag_idx}") + +i=0 +_group='' +_tags='' +for line in "${each[@]}"; do + yaml=$(jq -r '.[3]' <<<"$line") + tree=$(jq -r '.[4]' <<<"$line") + mapfile -t cell < <(jq -r ".[1:3],.[5:6],.[$tag_idx:]|.[]" <<<"$line") + set -- "${cell[@]}" + group=$1; shift + name=$1; shift + [[ $name ]] || die "No 'name' field for row $((i+1)) in $tsv" + skip=$1; shift + tags=() + for tag in "${tag_name[@]}"; do + if [[ $1 ]]; then + tags+=( "$tag" ) + fi + shift + done + + if [[ $group && $group == $_group ]]; then + more=1 + if [[ ${tags[*]} == $_tags ]]; then + tags=() + else + _tags=${tags[*]} + fi + else + more='' + _tags=${tags[*]} + if [[ ${#group} -eq 4 ]]; then + id=$group + else + id=$("$bin/new-test-id") + fi + while [[ -f $dir/$id*.yaml ]]; do + id=$("$bin/new-test-id") + done + : $((i++)) + _group=$group + fi + + file_name=$(printf "%03d-%s" "$i" "$id") + file=$dir/$file_name.yaml + + YAML="$yaml" \ + MORE="$more" \ + SKIP="$skip" \ + NAME="$name" \ + FROM="$from" \ + TAGS="${tags[*]}" \ + TREE="$tree" \ + "$bin/yaml-to-test" >> "$file" + + if [[ $more ]]; then + action=' Added to' + else + action=Created + fi + echo "$action 'new/$file_name.yaml'" +done diff --git a/bin/yaml-to-test b/bin/yaml-to-test new file mode 100755 index 0000000..1356b4e --- /dev/null +++ b/bin/yaml-to-test @@ -0,0 +1,148 @@ +#!/usr/bin/env perl + +use strict; use warnings; +use utf8; +use FindBin; +use lib $FindBin::Bin; +use autodie qw(open close); +use YAMLTestSuite; +use Encode; +use YAML::PP; +use YAML::PP::Common qw/ PRESERVE_ORDER /; +use JSON::PP; +use Capture::Tiny ':all'; +use FindBin; +use boolean; + +main(@ARGV); + +sub main { + my $yaml = decode_utf8 $ENV{YAML}; + $yaml .= "\n" if length($yaml); + + my ($more, $skip, $name, $from, $tags, $tree) = + @ENV{qw}; + + my $fail = 0; + if ($tree eq 'ERROR') { + $tree = ''; + $fail = 1; + } + else { + $tree =~ s/\A=//; + $tree =~ s/^\ +//gm; + } + + my $ypp = YAML::PP->new( + boolean => 'boolean', + preserve => PRESERVE_ORDER, + ); + + my $test = $ypp->preserved_mapping({}); + %$test = ( + $skip ? (skip => true) : (), + name => $name, + from => $from, + $tags ? ( tags => $tags ) : (), + $fail ? ( fail => true ) : (), + yaml => $yaml, + tree_json_dump_emit($yaml, $tree, $fail), + ); + + if ($more) { + delete $test->{name}; + delete $test->{from}; + delete $test->{skip}; + $ypp->dumper->{header} = 0; + } + + my $out = encode_utf8 $ypp->dump([$test]); + + if ($more) { + $out = "\n$out"; + } + + print $out; +} + +sub tree_json_dump_emit { + my ($yaml, $tree, $fail) = @_; + + $yaml = YAMLTestSuite->unescape($yaml); + + my @data; + + if ($fail) { + $tree = run_cmd( + "yamlpp-events", + $yaml, + ); + if ($tree) { + push @data, tree => escape(indent($tree)); + } + } + else { + push @data, tree => escape(indent($tree)); + + my $json = run_cmd( + "yamlpp-load-dump -M YAML::PP::Ref -D JSON::PP", + $yaml, + ); + if ($json) { + push @data, json => escape($json); + } + + # my $dump = run_cmd( + # "yamlpp-load-dump -M YAML::PP::Ref -D YAML::PP", + # $yaml, + # ); + # if ($dump) { + # push @data, dump => escape($dump); + # } + + my $emit = run_cmd( + "yamlpp-parse-emit -M YAML::PP::Ref -D YAML::PP::LibYAML", + $yaml, + ); + if ($emit and $emit ne $yaml) { + push @data, emit => escape($emit); + } + } + + return @data; +} + +sub run_cmd { + my ($cmd, $yaml) = @_; + + my ($out, $err, $rc) = capture { + open my $pipe, '|-', $cmd + or die; + print $pipe encode_utf8($yaml); + return 0; + }; + + return $out || ''; +} + +sub escape { + my ($text) = @_; + $text =~ s/(\ +)$/"␣" x length($1)/gem; + return $text; +} + +sub indent { + my ($text) = @_; + my $i = 0; + $text =~ s<^(.)>< + if ($1 eq '+') { + (' ' x $i++) . $1; + } elsif ($1 eq '-') { + (' ' x --$i) . $1; + } else { + (' ' x $i) . $1; + } + >megx; + $text =~ s/\n?\z/\n/; + return $text; +} diff --git a/doc/tag-usage.md b/doc/tag-usage.md new file mode 100644 index 0000000..81a8ab9 --- /dev/null +++ b/doc/tag-usage.md @@ -0,0 +1,60 @@ +Test Suite Tags +=============== + +The .tml files under the `test/` directory have a tags line that looks like +this: + +``` + tags: block sequence mapping spec +``` + +The table below defines the tags that must be used. +This table is used by tools to validate the tags. + +``` +These tags can have one of the following for '*': + + ok YAML is valid + err YAML is invalid + want YAML is invalid but should be valid + dont YAML is valid but shouldn't be + +libyaml-* libyaml differs from normal +1-1-* YAML 1.1 differs from normal +1-2-* YAML 1.2 differs from normal +1-3-* YAML 1.3 differs from normal +2-0-* YAML 2.0 differs from normal + +alias The test uses anchors *and* aliases +anchor The test uses anchors (but *not* aliases) +binary The test encodes binary data +comment The test uses YAML comments +complex-key The test includes a mapping key which is not a scalar, but a + sequence or mapping +directive The test has directives +double The test involves double quoted scalars +duplicate-key The test includes a duplicate mapping key +edge The test is an edge case +empty The test has empty scalars +empty-key The test includes an empty mapping key `: value` +error The test is about YAML that has errors +explicit-key The test uses `?` for an explicit key +flow The test has flow style +folded The test uses '>' folded scalars +footer The test has '...' footer tokens +header The test has '---' header tokens +indent The test is concerned with indentation issues +literal The test uses '|' literal scalars +local-tag The test uses a local tag `!foo` +mapping The test is concerned with mapping issues +missing The test has explicit pair with key or value missing +scalar The test is concerned with scalar issues +sequence The test is concerned with sequence issues +simple The test uses simple YAML +single The test involves single quoted scalars +spec The test is a YAML 1.2 Spec example +tag The test has tags +unknown-tag The test uses an unknown tag from the standard YAML schema + `!!foo` +whitespace The test is concerned with whitespace issues +``` diff --git a/src/229Q.yaml b/src/229Q.yaml new file mode 100644 index 0000000..e4f92ce --- /dev/null +++ b/src/229Q.yaml @@ -0,0 +1,56 @@ +--- +- name: Spec Example 2.4. Sequence of Mappings + from: http://www.yaml.org/spec/1.2/spec.html#id2760193 + tags: sequence mapping spec + yaml: | + - + name: Mark McGwire + hr: 65 + avg: 0.278 + - + name: Sammy Sosa + hr: 63 + avg: 0.288 + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL :name + =VAL :Mark McGwire + =VAL :hr + =VAL :65 + =VAL :avg + =VAL :0.278 + -MAP + +MAP + =VAL :name + =VAL :Sammy Sosa + =VAL :hr + =VAL :63 + =VAL :avg + =VAL :0.288 + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "name": "Mark McGwire", + "hr": 65, + "avg": 0.278 + }, + { + "name": "Sammy Sosa", + "hr": 63, + "avg": 0.288 + } + ] + dump: | + - name: Mark McGwire + hr: 65 + avg: 0.278 + - name: Sammy Sosa + hr: 63 + avg: 0.288 diff --git a/src/236B.yaml b/src/236B.yaml new file mode 100644 index 0000000..2c82424 --- /dev/null +++ b/src/236B.yaml @@ -0,0 +1,15 @@ +--- +- name: Invalid value after mapping + from: '@perlpunk' + tags: error mapping + fail: true + yaml: | + foo: + bar + invalid + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :bar diff --git a/src/26DV.yaml b/src/26DV.yaml new file mode 100644 index 0000000..ada7c5f --- /dev/null +++ b/src/26DV.yaml @@ -0,0 +1,82 @@ +--- +- name: Whitespace around colon in mappings + from: '@perlpunk' + tags: alias mapping whitespace + yaml: | + "top1" :␣ + "key1" : &alias1 scalar1 + 'top2' :␣ + 'key2' : &alias2 scalar2 + top3: &node3␣ + *alias1 : scalar3 + top4:␣ + *alias2 : scalar4 + top5 :␣␣␣␣ + scalar5 + top6:␣ + &anchor6 'key6' : scalar6 + tree: | + +STR + +DOC + +MAP + =VAL "top1 + +MAP + =VAL "key1 + =VAL &alias1 :scalar1 + -MAP + =VAL 'top2 + +MAP + =VAL 'key2 + =VAL &alias2 :scalar2 + -MAP + =VAL :top3 + +MAP &node3 + =ALI *alias1 + =VAL :scalar3 + -MAP + =VAL :top4 + +MAP + =ALI *alias2 + =VAL :scalar4 + -MAP + =VAL :top5 + =VAL :scalar5 + =VAL :top6 + +MAP + =VAL &anchor6 'key6 + =VAL :scalar6 + -MAP + -MAP + -DOC + -STR + json: | + { + "top1": { + "key1": "scalar1" + }, + "top2": { + "key2": "scalar2" + }, + "top3": { + "scalar1": "scalar3" + }, + "top4": { + "scalar2": "scalar4" + }, + "top5": "scalar5", + "top6": { + "key6": "scalar6" + } + } + dump: | + "top1": + "key1": &alias1 scalar1 + 'top2': + 'key2': &alias2 scalar2 + top3: &node3 + *alias1 : scalar3 + top4: + *alias2 : scalar4 + top5: scalar5 + top6: + &anchor6 'key6': scalar6 diff --git a/src/27NA.yaml b/src/27NA.yaml new file mode 100644 index 0000000..8be2be4 --- /dev/null +++ b/src/27NA.yaml @@ -0,0 +1,17 @@ +--- +- name: Spec Example 5.9. Directive Indicator + from: http://www.yaml.org/spec/1.2/spec.html#id2774058 + tags: spec directive 1.3-err + yaml: | + %YAML 1.2 + --- text + tree: | + +STR + +DOC --- + =VAL :text + -DOC + -STR + json: | + "text" + dump: | + --- text diff --git a/src/2AUY.yaml b/src/2AUY.yaml new file mode 100644 index 0000000..e5ca696 --- /dev/null +++ b/src/2AUY.yaml @@ -0,0 +1,32 @@ +--- +- name: Tags in Block Sequence + from: NimYAML tests + tags: tag sequence + yaml: |2 + - !!str a + - b + - !!int 42 + - d + tree: | + +STR + +DOC + +SEQ + =VAL :a + =VAL :b + =VAL :42 + =VAL :d + -SEQ + -DOC + -STR + json: | + [ + "a", + "b", + 42, + "d" + ] + dump: | + - !!str a + - b + - !!int 42 + - d diff --git a/src/2CMS.yaml b/src/2CMS.yaml new file mode 100644 index 0000000..4af7e53 --- /dev/null +++ b/src/2CMS.yaml @@ -0,0 +1,12 @@ +--- +- name: Invalid mapping in plain multiline + from: '@perlpunk' + tags: error mapping + fail: true + yaml: | + this + is + invalid: x + tree: | + +STR + +DOC diff --git a/src/2EBW.yaml b/src/2EBW.yaml new file mode 100644 index 0000000..c7b0e16 --- /dev/null +++ b/src/2EBW.yaml @@ -0,0 +1,41 @@ +--- +- name: Allowed characters in keys + from: '@perlpunk' + tags: mapping scalar + yaml: | + a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~: safe + ?foo: safe question mark + :foo: safe colon + -foo: safe dash + this is#not: a comment + tree: | + +STR + +DOC + +MAP + =VAL :a!"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~ + =VAL :safe + =VAL :?foo + =VAL :safe question mark + =VAL ::foo + =VAL :safe colon + =VAL :-foo + =VAL :safe dash + =VAL :this is#not + =VAL :a comment + -MAP + -DOC + -STR + json: | + { + "a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~": "safe", + "?foo": "safe question mark", + ":foo": "safe colon", + "-foo": "safe dash", + "this is#not": "a comment" + } + dump: | + a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~: safe + ?foo: safe question mark + :foo: safe colon + -foo: safe dash + this is#not: a comment diff --git a/src/2G84.yaml b/src/2G84.yaml new file mode 100644 index 0000000..7268c99 --- /dev/null +++ b/src/2G84.yaml @@ -0,0 +1,38 @@ +--- +- name: Literal modifers + from: '@ingydotnet' + tags: literal scalar + fail: true + yaml: | + --- |0 + tree: | + +STR + +DOC --- + +- fail: true + yaml: | + --- |10 + +- yaml: | + --- |1-∎ + tree: | + +STR + +DOC --- + =VAL | + -DOC + -STR + json: | + "" + emit: | + --- "" + +- yaml: | + --- |1+∎ + tree: | + +STR + +DOC --- + =VAL | + -DOC + -STR + emit: | + --- "" diff --git a/src/2JQS.yaml b/src/2JQS.yaml new file mode 100644 index 0000000..c1cd08e --- /dev/null +++ b/src/2JQS.yaml @@ -0,0 +1,18 @@ +--- +- name: Block Mapping with Missing Keys + from: NimYAML tests + tags: duplicate-key mapping empty-key + yaml: | + : a + : b + tree: | + +STR + +DOC + +MAP + =VAL : + =VAL :a + =VAL : + =VAL :b + -MAP + -DOC + -STR diff --git a/src/2LFX.yaml b/src/2LFX.yaml new file mode 100644 index 0000000..3d80b7d --- /dev/null +++ b/src/2LFX.yaml @@ -0,0 +1,22 @@ +--- +- name: Spec Example 6.13. Reserved Directives [1.3] + from: 6LVF, modified for YAML 1.3 + tags: spec directive header double 1.3-mod + yaml: | + %FOO bar baz # Should be ignored + # with a warning. + --- + "foo" + tree: | + +STR + +DOC --- + =VAL "foo + -DOC + -STR + json: | + "foo" + dump: | + --- + "foo" + emit: | + --- "foo" diff --git a/src/2SXE.yaml b/src/2SXE.yaml new file mode 100644 index 0000000..44dae4d --- /dev/null +++ b/src/2SXE.yaml @@ -0,0 +1,27 @@ +--- +- name: Anchors With Colon in Name + from: Mailing List Discussion + tags: alias edge mapping 1.3-err + yaml: | + &a: key: &a value + foo: + *a: + tree: | + +STR + +DOC + +MAP + =VAL &a: :key + =VAL &a :value + =VAL :foo + =ALI *a: + -MAP + -DOC + -STR + json: | + { + "key": "value", + "foo": "key" + } + dump: | + &a: key: &a value + foo: *a: diff --git a/src/2XXW.yaml b/src/2XXW.yaml new file mode 100644 index 0000000..83cad46 --- /dev/null +++ b/src/2XXW.yaml @@ -0,0 +1,36 @@ +--- +- name: Spec Example 2.25. Unordered Sets + from: http://www.yaml.org/spec/1.2/spec.html#id2761758 + tags: spec mapping unknown-tag explicit-key + yaml: | + # Sets are represented as a + # Mapping where each key is + # associated with a null value + --- !!set + ? Mark McGwire + ? Sammy Sosa + ? Ken Griff + tree: | + +STR + +DOC --- + +MAP + =VAL :Mark McGwire + =VAL : + =VAL :Sammy Sosa + =VAL : + =VAL :Ken Griff + =VAL : + -MAP + -DOC + -STR + json: | + { + "Mark McGwire": null, + "Sammy Sosa": null, + "Ken Griff": null + } + dump: | + --- !!set + Mark McGwire: + Sammy Sosa: + Ken Griff: diff --git a/src/33X3.yaml b/src/33X3.yaml new file mode 100644 index 0000000..6068f92 --- /dev/null +++ b/src/33X3.yaml @@ -0,0 +1,30 @@ +--- +- name: Three explicit integers in a block sequence + from: IRC + tags: sequence tag + yaml: | + --- + - !!int 1 + - !!int -2 + - !!int 33 + tree: | + +STR + +DOC --- + +SEQ + =VAL :1 + =VAL :-2 + =VAL :33 + -SEQ + -DOC + -STR + json: | + [ + 1, + -2, + 33 + ] + dump: | + --- + - !!int 1 + - !!int -2 + - !!int 33 diff --git a/src/35KP.yaml b/src/35KP.yaml new file mode 100644 index 0000000..f89db13 --- /dev/null +++ b/src/35KP.yaml @@ -0,0 +1,44 @@ +--- +- name: Tags for Root Objects + from: NimYAML tests + tags: explicit-key header mapping tag + yaml: | + --- !!map + ? a + : b + --- !!seq + - !!str c + --- !!str + d + e + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL :b + -MAP + -DOC + +DOC --- + +SEQ + =VAL :c + -SEQ + -DOC + +DOC --- + =VAL :d e + -DOC + -STR + json: | + { + "a": "b" + } + [ + "c" + ] + "d e" + dump: | + --- !!map + a: b + --- !!seq + - !!str c + --- !!str d e diff --git a/src/36F6.yaml b/src/36F6.yaml new file mode 100644 index 0000000..c4fe0b1 --- /dev/null +++ b/src/36F6.yaml @@ -0,0 +1,28 @@ +--- +- name: Multiline plain scalar with empty line + from: '@perlpunk' + tags: mapping scalar + yaml: | + --- + plain: a + b + + c + tree: | + +STR + +DOC --- + +MAP + =VAL :plain + =VAL :a b\nc + -MAP + -DOC + -STR + json: | + { + "plain": "a b\nc" + } + dump: | + --- + plain: 'a b + + c' diff --git a/src/3ALJ.yaml b/src/3ALJ.yaml new file mode 100644 index 0000000..7c2044c --- /dev/null +++ b/src/3ALJ.yaml @@ -0,0 +1,28 @@ +--- +- name: Block Sequence in Block Sequence + from: NimYAML tests + tags: sequence + yaml: | + - - s1_i1 + - s1_i2 + - s2 + tree: | + +STR + +DOC + +SEQ + +SEQ + =VAL :s1_i1 + =VAL :s1_i2 + -SEQ + =VAL :s2 + -SEQ + -DOC + -STR + json: | + [ + [ + "s1_i1", + "s1_i2" + ], + "s2" + ] diff --git a/src/3GZX.yaml b/src/3GZX.yaml new file mode 100644 index 0000000..d5e68c2 --- /dev/null +++ b/src/3GZX.yaml @@ -0,0 +1,31 @@ +--- +- name: Spec Example 7.1. Alias Nodes + from: http://www.yaml.org/spec/1.2/spec.html#id2786448 + tags: mapping spec alias + yaml: | + First occurrence: &anchor Foo + Second occurrence: *anchor + Override anchor: &anchor Bar + Reuse anchor: *anchor + tree: | + +STR + +DOC + +MAP + =VAL :First occurrence + =VAL &anchor :Foo + =VAL :Second occurrence + =ALI *anchor + =VAL :Override anchor + =VAL &anchor :Bar + =VAL :Reuse anchor + =ALI *anchor + -MAP + -DOC + -STR + json: | + { + "First occurrence": "Foo", + "Second occurrence": "Foo", + "Override anchor": "Bar", + "Reuse anchor": "Bar" + } diff --git a/src/3HFZ.yaml b/src/3HFZ.yaml new file mode 100644 index 0000000..f83d768 --- /dev/null +++ b/src/3HFZ.yaml @@ -0,0 +1,17 @@ +--- +- name: Invalid content after document end marker + from: '@perlpunk' + tags: error footer + fail: true + yaml: | + --- + key: value + ... invalid + tree: | + +STR + +DOC --- + +MAP + =VAL :key + =VAL :value + -MAP + -DOC ... diff --git a/src/3MYT.yaml b/src/3MYT.yaml new file mode 100644 index 0000000..85644c6 --- /dev/null +++ b/src/3MYT.yaml @@ -0,0 +1,18 @@ +--- +- name: Plain Scalar looking like key, comment, anchor and tag + from: https://gist.github.com/anonymous/a98d50ce42a59b1e999552bea7a31f57 via @ingydotnet + tags: scalar + yaml: | + --- + k:#foo + &a !t s + tree: | + +STR + +DOC --- + =VAL :k:#foo &a !t s + -DOC + -STR + json: | + "k:#foo &a !t s" + dump: | + --- k:#foo &a !t s diff --git a/src/3R3P.yaml b/src/3R3P.yaml new file mode 100644 index 0000000..df3fef9 --- /dev/null +++ b/src/3R3P.yaml @@ -0,0 +1,22 @@ +--- +- name: Single block sequence with anchor + from: '@perlpunk' + tags: anchor sequence + yaml: | + &sequence + - a + tree: | + +STR + +DOC + +SEQ &sequence + =VAL :a + -SEQ + -DOC + -STR + json: | + [ + "a" + ] + dump: | + &sequence + - a diff --git a/src/3RLN.yaml b/src/3RLN.yaml new file mode 100644 index 0000000..14de69a --- /dev/null +++ b/src/3RLN.yaml @@ -0,0 +1,87 @@ +--- +- name: Leading tabs in double quoted + from: '@ingydotnet' + tags: double whitespace + yaml: | + "1 leading + \ttab" + tree: | + +STR + +DOC + =VAL "1 leading \ttab + -DOC + -STR + json: | + "1 leading \ttab" + emit: | + "1 leading \ttab" + +- yaml: | + "2 leading + \———»tab" + tree: | + +STR + +DOC + =VAL "2 leading \ttab + -DOC + -STR + json: | + "2 leading \ttab" + emit: | + "2 leading \ttab" + +- yaml: | + "3 leading + ————»tab" + tree: | + +STR + +DOC + =VAL "3 leading tab + -DOC + -STR + json: | + "3 leading tab" + emit: | + "3 leading tab" + +- yaml: | + "4 leading + \t tab" + tree: | + +STR + +DOC + =VAL "4 leading \t tab + -DOC + -STR + json: | + "4 leading \t tab" + emit: | + "4 leading \t tab" + +- yaml: | + "5 leading + \———» tab" + tree: | + +STR + +DOC + =VAL "5 leading \t tab + -DOC + -STR + json: | + "5 leading \t tab" + emit: | + "5 leading \t tab" + +- yaml: | + "6 leading + ————» tab" + tree: | + +STR + +DOC + =VAL "6 leading tab + -DOC + -STR + json: | + "6 leading tab" + emit: | + "6 leading tab" diff --git a/src/3UYS.yaml b/src/3UYS.yaml new file mode 100644 index 0000000..781181c --- /dev/null +++ b/src/3UYS.yaml @@ -0,0 +1,21 @@ +--- +- name: Escaped slash in double quotes + from: '@perlpunk' + tags: double + yaml: | + escaped slash: "a\/b" + tree: | + +STR + +DOC + +MAP + =VAL :escaped slash + =VAL "a/b + -MAP + -DOC + -STR + json: | + { + "escaped slash": "a/b" + } + dump: | + escaped slash: "a/b" diff --git a/src/4ABK.yaml b/src/4ABK.yaml new file mode 100644 index 0000000..8c0ed87 --- /dev/null +++ b/src/4ABK.yaml @@ -0,0 +1,27 @@ +--- +- name: Flow Mapping Separate Values + from: http://www.yaml.org/spec/1.2/spec.html#id2791704 + tags: flow mapping + yaml: | + { + unquoted : "separate", + http://foo.com, + omitted value:, + } + tree: | + +STR + +DOC + +MAP {} + =VAL :unquoted + =VAL "separate + =VAL :http://foo.com + =VAL : + =VAL :omitted value + =VAL : + -MAP + -DOC + -STR + dump: | + unquoted: "separate" + http://foo.com: null + omitted value: null diff --git a/src/4CQQ.yaml b/src/4CQQ.yaml new file mode 100644 index 0000000..3af04ed --- /dev/null +++ b/src/4CQQ.yaml @@ -0,0 +1,30 @@ +--- +- name: Spec Example 2.18. Multi-line Flow Scalars + from: http://www.yaml.org/spec/1.2/spec.html#id2761268 + tags: spec scalar + yaml: | + plain: + This unquoted scalar + spans many lines. + + quoted: "So does this + quoted scalar.\n" + tree: | + +STR + +DOC + +MAP + =VAL :plain + =VAL :This unquoted scalar spans many lines. + =VAL :quoted + =VAL "So does this quoted scalar.\n + -MAP + -DOC + -STR + json: | + { + "plain": "This unquoted scalar spans many lines.", + "quoted": "So does this quoted scalar.\n" + } + dump: | + plain: This unquoted scalar spans many lines. + quoted: "So does this quoted scalar.\n" diff --git a/src/4EJS.yaml b/src/4EJS.yaml new file mode 100644 index 0000000..16b8643 --- /dev/null +++ b/src/4EJS.yaml @@ -0,0 +1,15 @@ +--- +- name: Invalid tabs as indendation in a mapping + from: https://github.com/nodeca/js-yaml/issues/80 + tags: error mapping whitespace + fail: true + yaml: | + --- + a: + ———»b: + ———»———»c: value + tree: | + +STR + +DOC --- + +MAP + =VAL :a diff --git a/src/4FJ6.yaml b/src/4FJ6.yaml new file mode 100644 index 0000000..dee37a8 --- /dev/null +++ b/src/4FJ6.yaml @@ -0,0 +1,42 @@ +--- +- name: Nested implicit complex keys + from: '@perlpunk' + tags: complex-key flow mapping sequence + yaml: | + --- + [ + [ a, [ [[b,c]]: d, e]]: 23 + ] + tree: | + +STR + +DOC --- + +SEQ [] + +MAP {} + +SEQ [] + =VAL :a + +SEQ [] + +MAP {} + +SEQ [] + +SEQ [] + =VAL :b + =VAL :c + -SEQ + -SEQ + =VAL :d + -MAP + =VAL :e + -SEQ + -SEQ + =VAL :23 + -MAP + -SEQ + -DOC + -STR + dump: | + --- + - ? - a + - - ? - - b + - c + : d + - e + : 23 diff --git a/src/4GC6.yaml b/src/4GC6.yaml new file mode 100644 index 0000000..732618b --- /dev/null +++ b/src/4GC6.yaml @@ -0,0 +1,14 @@ +--- +- name: Spec Example 7.7. Single Quoted Characters + from: http://www.yaml.org/spec/1.2/spec.html#id2788307 + tags: spec scalar 1.3-err + yaml: | + 'here''s to "quotes"' + tree: | + +STR + +DOC + =VAL 'here's to "quotes" + -DOC + -STR + json: | + "here's to \"quotes\"" diff --git a/src/4H7K.yaml b/src/4H7K.yaml new file mode 100644 index 0000000..66228b2 --- /dev/null +++ b/src/4H7K.yaml @@ -0,0 +1,17 @@ +--- +- name: Flow sequence with invalid extra closing bracket + from: '@perlpunk' + tags: error flow sequence + fail: true + yaml: | + --- + [ a, b, c ] ] + tree: | + +STR + +DOC --- + +SEQ + =VAL :a + =VAL :b + =VAL :c + -SEQ + -DOC diff --git a/src/4HVU.yaml b/src/4HVU.yaml new file mode 100644 index 0000000..dce4ae0 --- /dev/null +++ b/src/4HVU.yaml @@ -0,0 +1,19 @@ +--- +- name: Wrong indendation in Sequence + from: '@perlpunk' + tags: error sequence indent + fail: true + yaml: | + key: + - ok + - also ok + - wrong + tree: | + +STR + +DOC + +MAP + =VAL :key + +SEQ + =VAL :ok + =VAL :also ok + -SEQ diff --git a/src/4JVG.yaml b/src/4JVG.yaml new file mode 100644 index 0000000..69fff4f --- /dev/null +++ b/src/4JVG.yaml @@ -0,0 +1,20 @@ +--- +- name: Scalar value with two anchors + from: '@perlpunk' + tags: anchor error mapping + fail: true + yaml: | + top1: &node1 + &k1 key1: val1 + top2: &node2 + &v2 val2 + tree: | + +STR + +DOC + +MAP + =VAL :top1 + +MAP &node1 + =VAL &k1 :key1 + =VAL :val1 + -MAP + =VAL :top2 diff --git a/src/4MUZ.yaml b/src/4MUZ.yaml new file mode 100644 index 0000000..758db65 --- /dev/null +++ b/src/4MUZ.yaml @@ -0,0 +1,56 @@ +--- +- name: Flow mapping colon on line after key + from: '@ingydotnet' + tags: flow mapping + yaml: | + {"foo" + : "bar"} + tree: | + +STR + +DOC + +MAP {} + =VAL "foo + =VAL "bar + -MAP + -DOC + -STR + json: | + { + "foo": "bar" + } + emit: | + "foo": "bar" + +- yaml: | + {"foo" + : bar} + tree: | + +STR + +DOC + +MAP {} + =VAL "foo + =VAL :bar + -MAP + -DOC + -STR + emit: | + "foo": bar + +- yaml: | + {foo + : bar} + tree: | + +STR + +DOC + +MAP {} + =VAL :foo + =VAL :bar + -MAP + -DOC + -STR + json: | + { + "foo": "bar" + } + emit: | + foo: bar diff --git a/src/4Q9F.yaml b/src/4Q9F.yaml new file mode 100644 index 0000000..a0f663a --- /dev/null +++ b/src/4Q9F.yaml @@ -0,0 +1,29 @@ +--- +- name: Folded Block Scalar [1.3] + from: TS54, modified for YAML 1.3 + tags: folded scalar 1.3-mod whitespace + yaml: | + --- > + ab + cd + ␣ + ef + + + gh + tree: | + +STR + +DOC --- + =VAL >ab cd\nef\n\ngh\n + -DOC + -STR + json: | + "ab cd\nef\n\ngh\n" + dump: | + --- > + ab cd + + ef + + + gh diff --git a/src/4QFQ.yaml b/src/4QFQ.yaml new file mode 100644 index 0000000..5fac10d --- /dev/null +++ b/src/4QFQ.yaml @@ -0,0 +1,44 @@ +--- +- name: Spec Example 8.2. Block Indentation Indicator [1.3] + from: R4YG, modified for YAML 1.3 + tags: spec literal folded scalar libyaml-err 1.3-mod whitespace + yaml: | + - | + detected + - > + ␣ + ␣␣ + # detected + - |1 + explicit + - > + detected + tree: | + +STR + +DOC + +SEQ + =VAL |detected\n + =VAL >\n\n# detected\n + =VAL | explicit\n + =VAL >detected\n + -SEQ + -DOC + -STR + json: | + [ + "detected\n", + "\n\n# detected\n", + " explicit\n", + "detected\n" + ] + emit: | + - | + detected + - >2 + + + # detected + - |2 + explicit + - > + detected diff --git a/src/4RWC.yaml b/src/4RWC.yaml new file mode 100644 index 0000000..4e800b5 --- /dev/null +++ b/src/4RWC.yaml @@ -0,0 +1,27 @@ +--- +- name: Trailing spaces after flow collection + tags: flow whitespace + from: '@ingydotnet' + yaml: |2 + [1, 2, 3]␣␣ + ␣␣∎ + tree: | + +STR + +DOC + +SEQ [] + =VAL :1 + =VAL :2 + =VAL :3 + -SEQ + -DOC + -STR + json: | + [ + 1, + 2, + 3 + ] + dump: | + - 1 + - 2 + - 3 diff --git a/src/4UYU.yaml b/src/4UYU.yaml new file mode 100644 index 0000000..6b28d53 --- /dev/null +++ b/src/4UYU.yaml @@ -0,0 +1,14 @@ +--- +- name: Colon in Double Quoted String + from: NimYAML tests + tags: mapping scalar 1.3-err + yaml: | + "foo: bar\": baz" + tree: | + +STR + +DOC + =VAL "foo: bar": baz + -DOC + -STR + json: | + "foo: bar\": baz" diff --git a/src/4V8U.yaml b/src/4V8U.yaml new file mode 100644 index 0000000..26561ec --- /dev/null +++ b/src/4V8U.yaml @@ -0,0 +1,17 @@ +--- +- name: Plain scalar with backslashes + from: '@perlpunk' + tags: scalar + yaml: | + --- + plain\value\with\backslashes + tree: | + +STR + +DOC --- + =VAL :plain\\value\\with\\backslashes + -DOC + -STR + json: | + "plain\\value\\with\\backslashes" + dump: | + --- plain\value\with\backslashes diff --git a/src/4WA9.yaml b/src/4WA9.yaml new file mode 100644 index 0000000..4f9be4a --- /dev/null +++ b/src/4WA9.yaml @@ -0,0 +1,40 @@ +--- +- name: Literal scalars + from: '@ingydotnet' + tags: indent literal + yaml: | + - aaa: |2 + xxx + bbb: | + xxx + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL :aaa + =VAL |xxx\n + =VAL :bbb + =VAL |xxx\n + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "aaa" : "xxx\n", + "bbb" : "xxx\n" + } + ] + dump: | + --- + - aaa: | + xxx + bbb: | + xxx + emit: | + - aaa: | + xxx + bbb: | + xxx diff --git a/src/4ZYM.yaml b/src/4ZYM.yaml new file mode 100644 index 0000000..c57907e --- /dev/null +++ b/src/4ZYM.yaml @@ -0,0 +1,41 @@ +--- +- name: Spec Example 6.4. Line Prefixes + from: http://www.yaml.org/spec/1.2/spec.html#id2778720 + tags: spec scalar literal double upto-1.2 whitespace + yaml: | + plain: text + lines + quoted: "text + —»lines" + block: | + text + »lines + tree: | + +STR + +DOC + +MAP + =VAL :plain + =VAL :text lines + =VAL :quoted + =VAL "text lines + =VAL :block + =VAL |text\n \tlines\n + -MAP + -DOC + -STR + json: | + { + "plain": "text lines", + "quoted": "text lines", + "block": "text\n \tlines\n" + } + dump: | + plain: text lines + quoted: "text lines" + block: "text\n \tlines\n" + emit: | + plain: text lines + quoted: "text lines" + block: | + text + »lines diff --git a/src/52DL.yaml b/src/52DL.yaml new file mode 100644 index 0000000..42749d3 --- /dev/null +++ b/src/52DL.yaml @@ -0,0 +1,17 @@ +--- +- name: Explicit Non-Specific Tag [1.3] + from: 8MK2, modified for YAML 1.3 + tags: tag 1.3-mod + yaml: | + --- + ! a + tree: | + +STR + +DOC --- + =VAL :a + -DOC + -STR + json: | + "a" + dump: | + --- ! a diff --git a/src/54T7.yaml b/src/54T7.yaml new file mode 100644 index 0000000..d08227d --- /dev/null +++ b/src/54T7.yaml @@ -0,0 +1,25 @@ +--- +- name: Flow Mapping + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml + tags: flow mapping + yaml: | + {foo: you, bar: far} + tree: | + +STR + +DOC + +MAP {} + =VAL :foo + =VAL :you + =VAL :bar + =VAL :far + -MAP + -DOC + -STR + json: | + { + "foo": "you", + "bar": "far" + } + dump: | + foo: you + bar: far diff --git a/src/55WF.yaml b/src/55WF.yaml new file mode 100644 index 0000000..88d84e5 --- /dev/null +++ b/src/55WF.yaml @@ -0,0 +1,11 @@ +--- +- name: Invalid escape in double quoted string + from: '@perlpunk' + tags: error double + fail: true + yaml: | + --- + "\." + tree: | + +STR + +DOC --- diff --git a/src/565N.yaml b/src/565N.yaml new file mode 100644 index 0000000..d2986b4 --- /dev/null +++ b/src/565N.yaml @@ -0,0 +1,36 @@ +--- +- name: Construct Binary + from: https://github.com/yaml/pyyaml/blob/master/tests/data/construct-binary-py2.data + tags: tag unknown-tag + yaml: | + canonical: !!binary "\ + R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\ + OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\ + +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\ + AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=" + generic: !!binary | + R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5 + OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+ + +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC + AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs= + description: + The binary value above is a tiny arrow encoded as a gif image. + tree: | + +STR + +DOC + +MAP + =VAL :canonical + =VAL "R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLCAgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs= + =VAL :generic + =VAL |R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\nOTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\n+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\nAgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=\n + =VAL :description + =VAL :The binary value above is a tiny arrow encoded as a gif image. + -MAP + -DOC + -STR + json: | + { + "canonical": "R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLCAgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=", + "generic": "R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\nOTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\n+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\nAgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=\n", + "description": "The binary value above is a tiny arrow encoded as a gif image." + } diff --git a/src/57H4.yaml b/src/57H4.yaml new file mode 100644 index 0000000..d16f095 --- /dev/null +++ b/src/57H4.yaml @@ -0,0 +1,49 @@ +--- +- name: Spec Example 8.22. Block Collection Nodes + from: http://www.yaml.org/spec/1.2/spec.html#id2800008 + tags: sequence mapping tag + yaml: | + sequence: !!seq + - entry + - !!seq + - nested + mapping: !!map + foo: bar + tree: | + +STR + +DOC + +MAP + =VAL :sequence + +SEQ + =VAL :entry + +SEQ + =VAL :nested + -SEQ + -SEQ + =VAL :mapping + +MAP + =VAL :foo + =VAL :bar + -MAP + -MAP + -DOC + -STR + json: | + { + "sequence": [ + "entry", + [ + "nested" + ] + ], + "mapping": { + "foo": "bar" + } + } + dump: | + sequence: !!seq + - entry + - !!seq + - nested + mapping: !!map + foo: bar diff --git a/src/58MP.yaml b/src/58MP.yaml new file mode 100644 index 0000000..485e5ae --- /dev/null +++ b/src/58MP.yaml @@ -0,0 +1,21 @@ +--- +- name: Flow mapping edge cases + from: '@ingydotnet' + tags: edge flow mapping + yaml: | + {x: :x} + tree: | + +STR + +DOC + +MAP {} + =VAL :x + =VAL ::x + -MAP + -DOC + -STR + json: | + { + "x": ":x" + } + dump: | + x: :x diff --git a/src/5BVJ.yaml b/src/5BVJ.yaml new file mode 100644 index 0000000..1aebbce --- /dev/null +++ b/src/5BVJ.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 5.7. Block Scalar Indicators + from: http://www.yaml.org/spec/1.2/spec.html#id2773653 + tags: spec literal folded scalar + yaml: | + literal: | + some + text + folded: > + some + text + tree: | + +STR + +DOC + +MAP + =VAL :literal + =VAL |some\ntext\n + =VAL :folded + =VAL >some text\n + -MAP + -DOC + -STR + json: | + { + "literal": "some\ntext\n", + "folded": "some text\n" + } + dump: | + literal: | + some + text + folded: > + some text diff --git a/src/5C5M.yaml b/src/5C5M.yaml new file mode 100644 index 0000000..d9f7803 --- /dev/null +++ b/src/5C5M.yaml @@ -0,0 +1,42 @@ +--- +- name: Spec Example 7.15. Flow Mappings + from: http://www.yaml.org/spec/1.2/spec.html#id2791018 + tags: spec flow mapping + yaml: | + - { one : two , three: four , } + - {five: six,seven : eight} + tree: | + +STR + +DOC + +SEQ + +MAP {} + =VAL :one + =VAL :two + =VAL :three + =VAL :four + -MAP + +MAP {} + =VAL :five + =VAL :six + =VAL :seven + =VAL :eight + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "one": "two", + "three": "four" + }, + { + "five": "six", + "seven": "eight" + } + ] + dump: | + - one: two + three: four + - five: six + seven: eight diff --git a/src/5GBF.yaml b/src/5GBF.yaml new file mode 100644 index 0000000..98cd36e --- /dev/null +++ b/src/5GBF.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 6.5. Empty Lines + from: http://www.yaml.org/spec/1.2/spec.html#id2778971 + tags: double literal spec scalar upto-1.2 whitespace + yaml: | + Folding: + "Empty line + » + as a line feed" + Chomping: | + Clipped empty lines + ␣ + ↵ + tree: | + +STR + +DOC + +MAP + =VAL :Folding + =VAL "Empty line\nas a line feed + =VAL :Chomping + =VAL |Clipped empty lines\n + -MAP + -DOC + -STR + json: | + { + "Folding": "Empty line\nas a line feed", + "Chomping": "Clipped empty lines\n" + } + dump: | + Folding: "Empty line\nas a line feed" + Chomping: | + Clipped empty lines diff --git a/src/5KJE.yaml b/src/5KJE.yaml new file mode 100644 index 0000000..1239c55 --- /dev/null +++ b/src/5KJE.yaml @@ -0,0 +1,38 @@ +--- +- name: Spec Example 7.13. Flow Sequence + from: http://www.yaml.org/spec/1.2/spec.html#id2790506 + tags: spec flow sequence + yaml: | + - [ one, two, ] + - [three ,four] + tree: | + +STR + +DOC + +SEQ + +SEQ [] + =VAL :one + =VAL :two + -SEQ + +SEQ [] + =VAL :three + =VAL :four + -SEQ + -SEQ + -DOC + -STR + json: | + [ + [ + "one", + "two" + ], + [ + "three", + "four" + ] + ] + dump: | + - - one + - two + - - three + - four diff --git a/src/5LLU.yaml b/src/5LLU.yaml new file mode 100644 index 0000000..46685ff --- /dev/null +++ b/src/5LLU.yaml @@ -0,0 +1,16 @@ +--- +- name: Block scalar with wrong indented line after spaces only + from: '@perlpunk' + tags: error folded whitespace + fail: true + yaml: | + block scalar: > + ␣ + ␣␣ + ␣␣␣ + invalid + tree: | + +STR + +DOC + +MAP + =VAL :block scalar diff --git a/src/5MUD.yaml b/src/5MUD.yaml new file mode 100644 index 0000000..b327acf --- /dev/null +++ b/src/5MUD.yaml @@ -0,0 +1,24 @@ +--- +- name: Colon and adjacent value on next line + from: '@perlpunk' + tags: double flow mapping + yaml: | + --- + { "foo" + :bar } + tree: | + +STR + +DOC --- + +MAP {} + =VAL "foo + =VAL :bar + -MAP + -DOC + -STR + json: | + { + "foo": "bar" + } + dump: | + --- + "foo": bar diff --git a/src/5NYZ.yaml b/src/5NYZ.yaml new file mode 100644 index 0000000..7e09408 --- /dev/null +++ b/src/5NYZ.yaml @@ -0,0 +1,22 @@ +--- +- name: Spec Example 6.9. Separated Comment + from: http://www.yaml.org/spec/1.2/spec.html#id2780342 + tags: mapping spec comment + yaml: | + key: # Comment + value + tree: | + +STR + +DOC + +MAP + =VAL :key + =VAL :value + -MAP + -DOC + -STR + json: | + { + "key": "value" + } + dump: | + key: value diff --git a/src/5T43.yaml b/src/5T43.yaml new file mode 100644 index 0000000..5b6ceee --- /dev/null +++ b/src/5T43.yaml @@ -0,0 +1,37 @@ +--- +- name: Colon at the beginning of adjacent flow scalar + from: '@perlpunk' + tags: flow mapping scalar + yaml: | + - { "key":value } + - { "key"::value } + tree: | + +STR + +DOC + +SEQ + +MAP {} + =VAL "key + =VAL :value + -MAP + +MAP {} + =VAL "key + =VAL ::value + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "key": "value" + }, + { + "key": ":value" + } + ] + dump: | + - key: value + - key: :value + emit: | + - "key": value + - "key": :value diff --git a/src/5TRB.yaml b/src/5TRB.yaml new file mode 100644 index 0000000..3cf6470 --- /dev/null +++ b/src/5TRB.yaml @@ -0,0 +1,13 @@ +--- +- name: Invalid document-start marker in doublequoted tring + from: '@perlpunk' + tags: header double error + fail: true + yaml: | + --- + " + --- + " + tree: | + +STR + +DOC --- diff --git a/src/5TYM.yaml b/src/5TYM.yaml new file mode 100644 index 0000000..be41933 --- /dev/null +++ b/src/5TYM.yaml @@ -0,0 +1,24 @@ +--- +- name: Spec Example 6.21. Local Tag Prefix + from: http://www.yaml.org/spec/1.2/spec.html#id2783499 + tags: local-tag spec directive tag + yaml: | + %TAG !m! !my- + --- # Bulb here + !m!light fluorescent + ... + %TAG !m! !my- + --- # Color here + !m!light green + tree: | + +STR + +DOC --- + =VAL :fluorescent + -DOC ... + +DOC --- + =VAL :green + -DOC + -STR + json: | + "fluorescent" + "green" diff --git a/src/5U3A.yaml b/src/5U3A.yaml new file mode 100644 index 0000000..c7642cc --- /dev/null +++ b/src/5U3A.yaml @@ -0,0 +1,13 @@ +--- +- name: Sequence on same Line as Mapping Key + from: '@perlpunk' + tags: error sequence mapping + fail: true + yaml: | + key: - a + - b + tree: | + +STR + +DOC + +MAP + =VAL :key diff --git a/src/5WE3.yaml b/src/5WE3.yaml new file mode 100644 index 0000000..95b643b --- /dev/null +++ b/src/5WE3.yaml @@ -0,0 +1,38 @@ +--- +- name: Spec Example 8.17. Explicit Block Mapping Entries + from: http://www.yaml.org/spec/1.2/spec.html#id2798425 + tags: explicit-key spec mapping comment literal sequence + yaml: | + ? explicit key # Empty value + ? | + block key + : - one # Explicit compact + - two # block value + tree: | + +STR + +DOC + +MAP + =VAL :explicit key + =VAL : + =VAL |block key\n + +SEQ + =VAL :one + =VAL :two + -SEQ + -MAP + -DOC + -STR + json: | + { + "explicit key": null, + "block key\n": [ + "one", + "two" + ] + } + dump: | + explicit key: + ? | + block key + : - one + - two diff --git a/src/62EZ.yaml b/src/62EZ.yaml new file mode 100644 index 0000000..b517ecf --- /dev/null +++ b/src/62EZ.yaml @@ -0,0 +1,17 @@ +--- +- name: Invalid block mapping key on same line as previous key + from: '@perlpunk' + tags: error flow mapping + fail: true + yaml: | + --- + x: { y: z }in: valid + tree: | + +STR + +DOC --- + +MAP + =VAL :x + +MAP {} + =VAL :y + =VAL :z + -MAP diff --git a/src/652Z.yaml b/src/652Z.yaml new file mode 100644 index 0000000..afdc01b --- /dev/null +++ b/src/652Z.yaml @@ -0,0 +1,31 @@ +--- +- name: Question mark at start of flow key + from: '@ingydotnet' + tags: flow + yaml: | + { ?foo: bar, + bar: 42 + } + tree: | + +STR + +DOC + +MAP {} + =VAL :?foo + =VAL :bar + =VAL :bar + =VAL :42 + -MAP + -DOC + -STR + json: | + { + "?foo" : "bar", + "bar" : 42 + } + dump: | + --- + ?foo: bar + bar: 42 + emit: | + ?foo: bar + bar: 42 diff --git a/src/65WH.yaml b/src/65WH.yaml new file mode 100644 index 0000000..be1c765 --- /dev/null +++ b/src/65WH.yaml @@ -0,0 +1,18 @@ +--- +- name: Single Entry Block Sequence + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/sequence.tml + tags: sequence + yaml: | + - foo + tree: | + +STR + +DOC + +SEQ + =VAL :foo + -SEQ + -DOC + -STR + json: | + [ + "foo" + ] diff --git a/src/6BCT.yaml b/src/6BCT.yaml new file mode 100644 index 0000000..7a0bb52 --- /dev/null +++ b/src/6BCT.yaml @@ -0,0 +1,37 @@ +--- +- name: Spec Example 6.3. Separation Spaces + from: http://www.yaml.org/spec/1.2/spec.html#id2778394 + tags: spec libyaml-err sequence whitespace upto-1.2 + yaml: | + - foo:—» bar + - - baz + -»baz + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL :foo + =VAL :bar + -MAP + +SEQ + =VAL :baz + =VAL :baz + -SEQ + -SEQ + -DOC + -STR + json: | + [ + { + "foo": "bar" + }, + [ + "baz", + "baz" + ] + ] + dump: | + - foo: bar + - - baz + - baz diff --git a/src/6BFJ.yaml b/src/6BFJ.yaml new file mode 100644 index 0000000..4c084d3 --- /dev/null +++ b/src/6BFJ.yaml @@ -0,0 +1,28 @@ +--- +- name: Mapping, key and flow sequence item anchors + from: '@perlpunk' + tags: anchor complex-key flow mapping sequence + yaml: | + --- + &mapping + &key [ &item a, b, c ]: value + tree: | + +STR + +DOC --- + +MAP &mapping + +SEQ [] &key + =VAL &item :a + =VAL :b + =VAL :c + -SEQ + =VAL :value + -MAP + -DOC + -STR + dump: | + --- &mapping + ? &key + - &item a + - b + - c + : value diff --git a/src/6CA3.yaml b/src/6CA3.yaml new file mode 100644 index 0000000..b16e19c --- /dev/null +++ b/src/6CA3.yaml @@ -0,0 +1,18 @@ +--- +- name: Tab indented top flow + from: '@ingydotnet' + tags: indent whitespace + yaml: | + ————»[ + ————»] + tree: | + +STR + +DOC + +SEQ [] + -SEQ + -DOC + -STR + json: | + [] + emit: | + --- [] diff --git a/src/6CK3.yaml b/src/6CK3.yaml new file mode 100644 index 0000000..5908c82 --- /dev/null +++ b/src/6CK3.yaml @@ -0,0 +1,26 @@ +--- +- name: Spec Example 6.26. Tag Shorthands + from: http://www.yaml.org/spec/1.2/spec.html#id2785009 + tags: spec tag local-tag + yaml: | + %TAG !e! tag:example.com,2000:app/ + --- + - !local foo + - !!str bar + - !e!tag%21 baz + tree: | + +STR + +DOC --- + +SEQ + =VAL :foo + =VAL :bar + =VAL :baz + -SEQ + -DOC + -STR + json: | + [ + "foo", + "bar", + "baz" + ] diff --git a/src/6FWR.yaml b/src/6FWR.yaml new file mode 100644 index 0000000..b5660e2 --- /dev/null +++ b/src/6FWR.yaml @@ -0,0 +1,27 @@ +--- +- name: Block Scalar Keep + from: NimYAML tests + tags: literal scalar whitespace + yaml: | + --- |+ + ab + ␣ + ␣␣ + ... + tree: | + +STR + +DOC --- + =VAL |ab\n\n \n + -DOC ... + -STR + json: | + "ab\n\n \n" + dump: | + "ab\n\n \n" + ... + emit: | + --- | + ab + + ␣␣␣ + ... diff --git a/src/6H3V.yaml b/src/6H3V.yaml new file mode 100644 index 0000000..858613d --- /dev/null +++ b/src/6H3V.yaml @@ -0,0 +1,21 @@ +--- +- name: Backslashes in singlequotes + from: '@perlpunk' + tags: scalar single + yaml: | + 'foo: bar\': baz' + tree: | + +STR + +DOC + +MAP + =VAL 'foo: bar\\ + =VAL :baz' + -MAP + -DOC + -STR + json: | + { + "foo: bar\\": "baz'" + } + dump: | + 'foo: bar\': baz' diff --git a/src/6HB6.yaml b/src/6HB6.yaml new file mode 100644 index 0000000..96d25c8 --- /dev/null +++ b/src/6HB6.yaml @@ -0,0 +1,55 @@ +--- +- name: Spec Example 6.1. Indentation Spaces + from: http://www.yaml.org/spec/1.2/spec.html#id2777865 + tags: comment flow spec indent upto-1.2 whitespace + yaml: |2 + # Leading comment line spaces are + # neither content nor indentation. + ␣␣␣␣ + Not indented: + By one space: | + By four + spaces + Flow style: [ # Leading spaces + By two, # in flow style + Also by two, # are neither + —»Still by two # content nor + ] # indentation. + tree: | + +STR + +DOC + +MAP + =VAL :Not indented + +MAP + =VAL :By one space + =VAL |By four\n spaces\n + =VAL :Flow style + +SEQ [] + =VAL :By two + =VAL :Also by two + =VAL :Still by two + -SEQ + -MAP + -MAP + -DOC + -STR + json: | + { + "Not indented": { + "By one space": "By four\n spaces\n", + "Flow style": [ + "By two", + "Also by two", + "Still by two" + ] + } + } + dump: | + Not indented: + By one space: | + By four + spaces + Flow style: + - By two + - Also by two + - Still by two diff --git a/src/6JQW.yaml b/src/6JQW.yaml new file mode 100644 index 0000000..34b8463 --- /dev/null +++ b/src/6JQW.yaml @@ -0,0 +1,21 @@ +--- +- name: Spec Example 2.13. In literals, newlines are preserved + from: http://www.yaml.org/spec/1.2/spec.html#id2759963 + tags: spec scalar literal comment + yaml: | + # ASCII Art + --- | + \//||\/|| + // || ||__ + tree: | + +STR + +DOC --- + =VAL |\\//||\\/||\n// || ||__\n + -DOC + -STR + json: | + "\\//||\\/||\n// || ||__\n" + dump: | + --- | + \//||\/|| + // || ||__ diff --git a/src/6JTT.yaml b/src/6JTT.yaml new file mode 100644 index 0000000..a06cb73 --- /dev/null +++ b/src/6JTT.yaml @@ -0,0 +1,17 @@ +--- +- name: Flow sequence without closing bracket + from: '@perlpunk' + tags: error flow sequence + fail: true + yaml: | + --- + [ [ a, b, c ] + tree: | + +STR + +DOC --- + +SEQ [] + +SEQ [] + =VAL :a + =VAL :b + =VAL :c + -SEQ diff --git a/src/6JWB.yaml b/src/6JWB.yaml new file mode 100644 index 0000000..5c376b6 --- /dev/null +++ b/src/6JWB.yaml @@ -0,0 +1,38 @@ +--- +- name: Tags for Block Objects + from: NimYAML tests + tags: mapping sequence tag + yaml: | + foo: !!seq + - !!str a + - !!map + key: !!str value + tree: | + +STR + +DOC + +MAP + =VAL :foo + +SEQ + =VAL :a + +MAP + =VAL :key + =VAL :value + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "foo": [ + "a", + { + "key": "value" + } + ] + } + dump: | + foo: !!seq + - !!str a + - !!map + key: !!str value diff --git a/src/6KGN.yaml b/src/6KGN.yaml new file mode 100644 index 0000000..dac198d --- /dev/null +++ b/src/6KGN.yaml @@ -0,0 +1,28 @@ +--- +- name: Anchor for empty node + from: https://github.com/nodeca/js-yaml/issues/301 + tags: alias anchor + yaml: | + --- + a: &anchor + b: *anchor + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL &anchor : + =VAL :b + =ALI *anchor + -MAP + -DOC + -STR + json: | + { + "a": null, + "b": null + } + dump: | + --- + a: &anchor + b: *anchor diff --git a/src/6LVF.yaml b/src/6LVF.yaml new file mode 100644 index 0000000..4ea8f74 --- /dev/null +++ b/src/6LVF.yaml @@ -0,0 +1,18 @@ +--- +- name: Spec Example 6.13. Reserved Directives + from: http://www.yaml.org/spec/1.2/spec.html#id2781445 + tags: spec directive header double 1.3-err + yaml: | + %FOO bar baz # Should be ignored + # with a warning. + --- "foo" + tree: | + +STR + +DOC --- + =VAL "foo + -DOC + -STR + json: | + "foo" + dump: | + --- "foo" diff --git a/src/6M2F.yaml b/src/6M2F.yaml new file mode 100644 index 0000000..a2f357e --- /dev/null +++ b/src/6M2F.yaml @@ -0,0 +1,22 @@ +--- +- name: Aliases in Explicit Block Mapping + from: NimYAML tests + tags: alias explicit-key empty-key + yaml: | + ? &a a + : &b b + : *a + tree: | + +STR + +DOC + +MAP + =VAL &a :a + =VAL &b :b + =VAL : + =ALI *a + -MAP + -DOC + -STR + dump: | + &a a: &b b + : *a diff --git a/src/6PBE.yaml b/src/6PBE.yaml new file mode 100644 index 0000000..39edcf9 --- /dev/null +++ b/src/6PBE.yaml @@ -0,0 +1,33 @@ +--- +- name: Zero-indented sequences in explicit mapping keys + from: '@perlpunk' + tags: explicit-key mapping sequence + yaml: | + --- + ? + - a + - b + : + - c + - d + tree: | + +STR + +DOC --- + +MAP + +SEQ + =VAL :a + =VAL :b + -SEQ + +SEQ + =VAL :c + =VAL :d + -SEQ + -MAP + -DOC + -STR + emit: | + --- + ? - a + - b + : - c + - d diff --git a/src/6S55.yaml b/src/6S55.yaml new file mode 100644 index 0000000..61907b2 --- /dev/null +++ b/src/6S55.yaml @@ -0,0 +1,18 @@ +--- +- name: Invalid scalar at the end of sequence + from: '@perlpunk' + tags: error mapping sequence + fail: true + yaml: | + key: + - bar + - baz + invalid + tree: | + +STR + +DOC + +MAP + =VAL :key + +SEQ + =VAL :bar + =VAL :baz diff --git a/src/6SLA.yaml b/src/6SLA.yaml new file mode 100644 index 0000000..426c195 --- /dev/null +++ b/src/6SLA.yaml @@ -0,0 +1,27 @@ +--- +- name: Allowed characters in quoted mapping key + from: '@perlpunk' + tags: mapping single double + yaml: | + "foo\nbar:baz\tx \\$%^&*()x": 23 + 'x\ny:z\tx $%^&*()x': 24 + tree: | + +STR + +DOC + +MAP + =VAL "foo\nbar:baz\tx \\$%^&*()x + =VAL :23 + =VAL 'x\\ny:z\\tx $%^&*()x + =VAL :24 + -MAP + -DOC + -STR + json: | + { + "foo\nbar:baz\tx \\$%^&*()x": 23, + "x\\ny:z\\tx $%^&*()x": 24 + } + dump: | + ? "foo\nbar:baz\tx \\$%^&*()x" + : 23 + 'x\ny:z\tx $%^&*()x': 24 diff --git a/src/6VJK.yaml b/src/6VJK.yaml new file mode 100644 index 0000000..ccfcf67 --- /dev/null +++ b/src/6VJK.yaml @@ -0,0 +1,29 @@ +--- +- name: Spec Example 2.15. Folded newlines are preserved for "more indented" and blank lines + from: http://www.yaml.org/spec/1.2/spec.html#id2761056 + tags: spec folded scalar 1.3-err + yaml: | + > + Sammy Sosa completed another + fine season with great stats. + + 63 Home Runs + 0.288 Batting Average + + What a year! + tree: | + +STR + +DOC + =VAL >Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n + -DOC + -STR + json: | + "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n" + dump: | + > + Sammy Sosa completed another fine season with great stats. + + 63 Home Runs + 0.288 Batting Average + + What a year! diff --git a/src/6WLZ.yaml b/src/6WLZ.yaml new file mode 100644 index 0000000..f229cc6 --- /dev/null +++ b/src/6WLZ.yaml @@ -0,0 +1,35 @@ +--- +- name: Spec Example 6.18. Primary Tag Handle [1.3] + from: 9WXW, modified for YAML 1.3 + tags: local-tag spec directive tag 1.3-mod + yaml: | + # Private + --- + !foo "bar" + ... + # Global + %TAG ! tag:example.com,2000:app/ + --- + !foo "bar" + tree: | + +STR + +DOC --- + =VAL "bar + -DOC ... + +DOC --- + =VAL "bar + -DOC + -STR + json: | + "bar" + "bar" + dump: | + --- + !foo "bar" + ... + --- ! + "bar" + emit: | + --- !foo "bar" + ... + --- ! "bar" diff --git a/src/6WPF.yaml b/src/6WPF.yaml new file mode 100644 index 0000000..9aa2cc0 --- /dev/null +++ b/src/6WPF.yaml @@ -0,0 +1,25 @@ +--- +- name: Spec Example 6.8. Flow Folding [1.3] + from: TL85, modified for YAML 1.3 + tags: double spec whitespace scalar 1.3-mod + yaml: | + --- + " + foo␣ + ␣ + bar + + baz + " + tree: | + +STR + +DOC --- + =VAL " foo\nbar\nbaz␣ + -DOC + -STR + json: | + " foo\nbar\nbaz " + dump: | + " foo\nbar\nbaz " + emit: | + --- " foo\nbar\nbaz " diff --git a/src/6XDY.yaml b/src/6XDY.yaml new file mode 100644 index 0000000..92441ab --- /dev/null +++ b/src/6XDY.yaml @@ -0,0 +1,22 @@ +--- +- name: Two document start markers + from: '@perlpunk' + tags: header + yaml: | + --- + --- + tree: | + +STR + +DOC --- + =VAL : + -DOC + +DOC --- + =VAL : + -DOC + -STR + json: | + null + null + dump: | + --- + --- diff --git a/src/6ZKB.yaml b/src/6ZKB.yaml new file mode 100644 index 0000000..d376f3a --- /dev/null +++ b/src/6ZKB.yaml @@ -0,0 +1,40 @@ +--- +- name: Spec Example 9.6. Stream + from: http://www.yaml.org/spec/1.2/spec.html#id2801896 + tags: spec header 1.3-err + yaml: | + Document + --- + # Empty + ... + %YAML 1.2 + --- + matches %: 20 + tree: | + +STR + +DOC + =VAL :Document + -DOC + +DOC --- + =VAL : + -DOC ... + +DOC --- + +MAP + =VAL :matches % + =VAL :20 + -MAP + -DOC + -STR + json: | + "Document" + null + { + "matches %": 20 + } + emit: | + Document + --- + ... + %YAML 1.2 + --- + matches %: 20 diff --git a/src/735Y.yaml b/src/735Y.yaml new file mode 100644 index 0000000..fb24919 --- /dev/null +++ b/src/735Y.yaml @@ -0,0 +1,38 @@ +--- +- name: Spec Example 8.20. Block Node Types + from: http://www.yaml.org/spec/1.2/spec.html#id2799426 + tags: comment double spec folded tag + yaml: | + - + "flow in block" + - > + Block scalar + - !!map # Block collection + foo : bar + tree: | + +STR + +DOC + +SEQ + =VAL "flow in block + =VAL >Block scalar\n + +MAP + =VAL :foo + =VAL :bar + -MAP + -SEQ + -DOC + -STR + json: | + [ + "flow in block", + "Block scalar\n", + { + "foo": "bar" + } + ] + dump: | + - "flow in block" + - > + Block scalar + - !!map + foo: bar diff --git a/src/74H7.yaml b/src/74H7.yaml new file mode 100644 index 0000000..8e5a1c4 --- /dev/null +++ b/src/74H7.yaml @@ -0,0 +1,41 @@ +--- +- name: Tags in Implicit Mapping + from: NimYAML tests + tags: tag mapping + yaml: | + !!str a: b + c: !!int 42 + e: !!str f + g: h + !!str 23: !!bool false + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL :b + =VAL :c + =VAL :42 + =VAL :e + =VAL :f + =VAL :g + =VAL :h + =VAL :23 + =VAL :false + -MAP + -DOC + -STR + json: | + { + "a": "b", + "c": 42, + "e": "f", + "g": "h", + "23": false + } + dump: | + !!str a: b + c: !!int 42 + e: !!str f + g: h + !!str 23: !!bool false diff --git a/src/753E.yaml b/src/753E.yaml new file mode 100644 index 0000000..cc1de02 --- /dev/null +++ b/src/753E.yaml @@ -0,0 +1,22 @@ +--- +- name: Block Scalar Strip [1.3] + from: MYW6, modified for YAML 1.3 + tags: literal scalar 1.3-mod whitespace + yaml: | + --- |- + ab + ␣ + ␣ + ... + tree: | + +STR + +DOC --- + =VAL |ab + -DOC ... + -STR + json: | + "ab" + dump: | + --- |- + ab + ... diff --git a/src/7A4E.yaml b/src/7A4E.yaml new file mode 100644 index 0000000..4c8afc6 --- /dev/null +++ b/src/7A4E.yaml @@ -0,0 +1,19 @@ +--- +- name: Spec Example 7.6. Double Quoted Lines + from: http://www.yaml.org/spec/1.2/spec.html#id2787994 + tags: spec scalar upto-1.2 whitespace + yaml: | + " 1st non-empty + + 2nd non-empty␣ + ———»3rd non-empty " + tree: | + +STR + +DOC + =VAL " 1st non-empty\n2nd non-empty 3rd non-empty␣ + -DOC + -STR + json: | + " 1st non-empty\n2nd non-empty 3rd non-empty " + dump: | + " 1st non-empty\n2nd non-empty 3rd non-empty " diff --git a/src/7BMT.yaml b/src/7BMT.yaml new file mode 100644 index 0000000..442862c --- /dev/null +++ b/src/7BMT.yaml @@ -0,0 +1,90 @@ +--- +- name: Node and Mapping Key Anchors [1.3] + from: U3XV, modified for YAML 1.3 + tags: anchor comment mapping 1.3-mod + yaml: | + --- + top1: &node1 + &k1 key1: one + top2: &node2 # comment + key2: two + top3: + &k3 key3: three + top4: &node4 + &k4 key4: four + top5: &node5 + key5: five + top6: &val6 + six + top7: + &val7 seven + tree: | + +STR + +DOC --- + +MAP + =VAL :top1 + +MAP &node1 + =VAL &k1 :key1 + =VAL :one + -MAP + =VAL :top2 + +MAP &node2 + =VAL :key2 + =VAL :two + -MAP + =VAL :top3 + +MAP + =VAL &k3 :key3 + =VAL :three + -MAP + =VAL :top4 + +MAP &node4 + =VAL &k4 :key4 + =VAL :four + -MAP + =VAL :top5 + +MAP &node5 + =VAL :key5 + =VAL :five + -MAP + =VAL :top6 + =VAL &val6 :six + =VAL :top7 + =VAL &val7 :seven + -MAP + -DOC + -STR + json: | + { + "top1": { + "key1": "one" + }, + "top2": { + "key2": "two" + }, + "top3": { + "key3": "three" + }, + "top4": { + "key4": "four" + }, + "top5": { + "key5": "five" + }, + "top6": "six", + "top7": "seven" + } + dump: | + --- + top1: &node1 + &k1 key1: one + top2: &node2 + key2: two + top3: + &k3 key3: three + top4: &node4 + &k4 key4: four + top5: &node5 + key5: five + top6: &val6 six + top7: &val7 seven diff --git a/src/7BUB.yaml b/src/7BUB.yaml new file mode 100644 index 0000000..a52d72d --- /dev/null +++ b/src/7BUB.yaml @@ -0,0 +1,49 @@ +--- +- name: Spec Example 2.10. Node for “Sammy Sosa” appears twice in this document + from: http://www.yaml.org/spec/1.2/spec.html#id2760658 + tags: mapping sequence spec alias + yaml: | + --- + hr: + - Mark McGwire + # Following node labeled SS + - &SS Sammy Sosa + rbi: + - *SS # Subsequent occurrence + - Ken Griffey + tree: | + +STR + +DOC --- + +MAP + =VAL :hr + +SEQ + =VAL :Mark McGwire + =VAL &SS :Sammy Sosa + -SEQ + =VAL :rbi + +SEQ + =ALI *SS + =VAL :Ken Griffey + -SEQ + -MAP + -DOC + -STR + json: | + { + "hr": [ + "Mark McGwire", + "Sammy Sosa" + ], + "rbi": [ + "Sammy Sosa", + "Ken Griffey" + ] + } + dump: | + --- + hr: + - Mark McGwire + - &SS Sammy Sosa + rbi: + - *SS + - Ken Griffey diff --git a/src/7FWL.yaml b/src/7FWL.yaml new file mode 100644 index 0000000..b1251b4 --- /dev/null +++ b/src/7FWL.yaml @@ -0,0 +1,22 @@ +--- +- name: Spec Example 6.24. Verbatim Tags + from: http://www.yaml.org/spec/1.2/spec.html#id2784370 + tags: mapping spec tag unknown-tag + yaml: | + ! foo : + ! baz + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :baz + -MAP + -DOC + -STR + json: | + { + "foo": "baz" + } + dump: | + !!str foo: !bar baz diff --git a/src/7LBH.yaml b/src/7LBH.yaml new file mode 100644 index 0000000..1d65357 --- /dev/null +++ b/src/7LBH.yaml @@ -0,0 +1,15 @@ +--- +- name: Multiline double quoted implicit keys + from: '@perlpunk' + tags: error double + fail: true + yaml: | + "a\nb": 1 + "c + d": 1 + tree: | + +STR + +DOC + +MAP + =VAL "a\nb + =VAL :1 diff --git a/src/7MNF.yaml b/src/7MNF.yaml new file mode 100644 index 0000000..91bafac --- /dev/null +++ b/src/7MNF.yaml @@ -0,0 +1,18 @@ +--- +- name: Missing colon + from: '@perlpunk' + tags: error mapping + fail: true + yaml: | + top1: + key1: val1 + top2 + tree: | + +STR + +DOC + +MAP + =VAL :top1 + +MAP + =VAL :key1 + =VAL :val1 + -MAP diff --git a/src/7T8X.yaml b/src/7T8X.yaml new file mode 100644 index 0000000..66e3919 --- /dev/null +++ b/src/7T8X.yaml @@ -0,0 +1,41 @@ +--- +- name: Spec Example 8.10. Folded Lines - 8.13. Final Empty Lines + from: http://www.yaml.org/spec/1.2/spec.html#id2796543 + tags: spec folded scalar comment 1.3-err + yaml: | + > + + folded + line + + next + line + * bullet + + * list + * lines + + last + line + + # Comment + tree: | + +STR + +DOC + =VAL >\nfolded line\nnext line\n * bullet\n\n * list\n * lines\n\nlast line\n + -DOC + -STR + json: | + "\nfolded line\nnext line\n * bullet\n\n * list\n * lines\n\nlast line\n" + dump: | + > + + folded line + + next line + * bullet + + * list + * lines + + last line diff --git a/src/7TMG.yaml b/src/7TMG.yaml new file mode 100644 index 0000000..14c0f47 --- /dev/null +++ b/src/7TMG.yaml @@ -0,0 +1,27 @@ +--- +- name: Comment in flow sequence before comma + from: '@perlpunk' + tags: comment flow sequence + yaml: | + --- + [ word1 + # comment + , word2] + tree: | + +STR + +DOC --- + +SEQ [] + =VAL :word1 + =VAL :word2 + -SEQ + -DOC + -STR + json: | + [ + "word1", + "word2" + ] + dump: | + --- + - word1 + - word2 diff --git a/src/7W2P.yaml b/src/7W2P.yaml new file mode 100644 index 0000000..5fe8606 --- /dev/null +++ b/src/7W2P.yaml @@ -0,0 +1,31 @@ +--- +- name: Block Mapping with Missing Values + from: NimYAML tests + tags: explicit-key mapping + yaml: | + ? a + ? b + c: + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL : + =VAL :b + =VAL : + =VAL :c + =VAL : + -MAP + -DOC + -STR + json: | + { + "a": null, + "b": null, + "c": null + } + dump: | + a: + b: + c: diff --git a/src/7Z25.yaml b/src/7Z25.yaml new file mode 100644 index 0000000..fafbbf6 --- /dev/null +++ b/src/7Z25.yaml @@ -0,0 +1,30 @@ +--- +- name: Bare document after document end marker + from: '@perlpunk' + tags: footer + yaml: | + --- + scalar1 + ... + key: value + tree: | + +STR + +DOC --- + =VAL :scalar1 + -DOC ... + +DOC + +MAP + =VAL :key + =VAL :value + -MAP + -DOC + -STR + json: | + "scalar1" + { + "key": "value" + } + dump: | + --- scalar1 + ... + key: value diff --git a/src/7ZZ5.yaml b/src/7ZZ5.yaml new file mode 100644 index 0000000..ffbeae6 --- /dev/null +++ b/src/7ZZ5.yaml @@ -0,0 +1,63 @@ +--- +- name: Empty flow collections + from: '@perlpunk' + tags: flow mapping sequence + yaml: | + --- + nested sequences: + - - - [] + - - - {} + key1: [] + key2: {} + tree: | + +STR + +DOC --- + +MAP + =VAL :nested sequences + +SEQ + +SEQ + +SEQ + +SEQ [] + -SEQ + -SEQ + -SEQ + +SEQ + +SEQ + +MAP {} + -MAP + -SEQ + -SEQ + -SEQ + =VAL :key1 + +SEQ [] + -SEQ + =VAL :key2 + +MAP {} + -MAP + -MAP + -DOC + -STR + json: | + { + "nested sequences": [ + [ + [ + [] + ] + ], + [ + [ + {} + ] + ] + ], + "key1": [], + "key2": {} + } + dump: | + --- + nested sequences: + - - - [] + - - - {} + key1: [] + key2: {} diff --git a/src/82AN.yaml b/src/82AN.yaml new file mode 100644 index 0000000..9ab1cf0 --- /dev/null +++ b/src/82AN.yaml @@ -0,0 +1,17 @@ +--- +- name: Three dashes and content without space + from: '@perlpunk' + tags: scalar 1.3-err + yaml: | + ---word1 + word2 + tree: | + +STR + +DOC + =VAL :---word1 word2 + -DOC + -STR + json: | + "---word1 word2" + dump: | + '---word1 word2' diff --git a/src/87E4.yaml b/src/87E4.yaml new file mode 100644 index 0000000..4ca0ad8 --- /dev/null +++ b/src/87E4.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 7.8. Single Quoted Implicit Keys + from: http://www.yaml.org/spec/1.2/spec.html#id2788496 + tags: spec flow sequence mapping + yaml: | + 'implicit block key' : [ + 'implicit flow key' : value, + ] + tree: | + +STR + +DOC + +MAP + =VAL 'implicit block key + +SEQ [] + +MAP {} + =VAL 'implicit flow key + =VAL :value + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "implicit block key": [ + { + "implicit flow key": "value" + } + ] + } + dump: | + 'implicit block key': + - 'implicit flow key': value diff --git a/src/8CWC.yaml b/src/8CWC.yaml new file mode 100644 index 0000000..ba29815 --- /dev/null +++ b/src/8CWC.yaml @@ -0,0 +1,23 @@ +--- +- name: Plain mapping key ending with colon + from: '@perlpunk' + tags: mapping scalar + yaml: | + --- + key ends with two colons::: value + tree: | + +STR + +DOC --- + +MAP + =VAL :key ends with two colons:: + =VAL :value + -MAP + -DOC + -STR + json: | + { + "key ends with two colons::": "value" + } + dump: | + --- + 'key ends with two colons::': value diff --git a/src/8G76.yaml b/src/8G76.yaml new file mode 100644 index 0000000..48bc590 --- /dev/null +++ b/src/8G76.yaml @@ -0,0 +1,14 @@ +--- +- name: Spec Example 6.10. Comment Lines + from: http://www.yaml.org/spec/1.2/spec.html#id2780544 + tags: spec comment empty scalar whitespace + yaml: |2 + # Comment + ␣␣␣ + ↵ + ↵ + tree: | + +STR + -STR + json: '' + dump: '' diff --git a/src/8KB6.yaml b/src/8KB6.yaml new file mode 100644 index 0000000..a4090d1 --- /dev/null +++ b/src/8KB6.yaml @@ -0,0 +1,45 @@ +--- +- name: Multiline plain flow mapping key without value + from: '@perlpunk' + tags: flow mapping + yaml: | + --- + - { single line, a: b} + - { multi + line, a: b} + tree: | + +STR + +DOC --- + +SEQ + +MAP {} + =VAL :single line + =VAL : + =VAL :a + =VAL :b + -MAP + +MAP {} + =VAL :multi line + =VAL : + =VAL :a + =VAL :b + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "single line": null, + "a": "b" + }, + { + "multi line": null, + "a": "b" + } + ] + dump: | + --- + - single line: + a: b + - multi line: + a: b diff --git a/src/8MK2.yaml b/src/8MK2.yaml new file mode 100644 index 0000000..b5ba6ff --- /dev/null +++ b/src/8MK2.yaml @@ -0,0 +1,14 @@ +--- +- name: Explicit Non-Specific Tag + from: NimYAML tests + tags: tag 1.3-err + yaml: | + ! a + tree: | + +STR + +DOC + =VAL :a + -DOC + -STR + json: | + "a" diff --git a/src/8QBE.yaml b/src/8QBE.yaml new file mode 100644 index 0000000..d0ee99c --- /dev/null +++ b/src/8QBE.yaml @@ -0,0 +1,31 @@ +--- +- name: Block Sequence in Block Mapping + from: NimYAML tests + tags: mapping sequence + yaml: | + key: + - item1 + - item2 + tree: | + +STR + +DOC + +MAP + =VAL :key + +SEQ + =VAL :item1 + =VAL :item2 + -SEQ + -MAP + -DOC + -STR + json: | + { + "key": [ + "item1", + "item2" + ] + } + dump: | + key: + - item1 + - item2 diff --git a/src/8UDB.yaml b/src/8UDB.yaml new file mode 100644 index 0000000..a8612d3 --- /dev/null +++ b/src/8UDB.yaml @@ -0,0 +1,48 @@ +--- +- name: Spec Example 7.14. Flow Sequence Entries + from: http://www.yaml.org/spec/1.2/spec.html#id2790726 + tags: spec flow sequence + yaml: | + [ + "double + quoted", 'single + quoted', + plain + text, [ nested ], + single: pair, + ] + tree: | + +STR + +DOC + +SEQ [] + =VAL "double quoted + =VAL 'single quoted + =VAL :plain text + +SEQ [] + =VAL :nested + -SEQ + +MAP {} + =VAL :single + =VAL :pair + -MAP + -SEQ + -DOC + -STR + json: | + [ + "double quoted", + "single quoted", + "plain text", + [ + "nested" + ], + { + "single": "pair" + } + ] + dump: | + - "double quoted" + - 'single quoted' + - plain text + - - nested + - single: pair diff --git a/src/8XDJ.yaml b/src/8XDJ.yaml new file mode 100644 index 0000000..bdba6f1 --- /dev/null +++ b/src/8XDJ.yaml @@ -0,0 +1,15 @@ +--- +- name: Comment in plain multiline value + from: https://gist.github.com/anonymous/deeb1ace28d5bf21fb56d80c13e2dc69 via @ingydotnet + tags: error comment scalar + fail: true + yaml: | + key: word1 + # xxx + word2 + tree: | + +STR + +DOC + +MAP + =VAL :key + =VAL :word1 diff --git a/src/8XYN.yaml b/src/8XYN.yaml new file mode 100644 index 0000000..bdd99a9 --- /dev/null +++ b/src/8XYN.yaml @@ -0,0 +1,22 @@ +--- +- name: Anchor with unicode character + from: https://github.com/yaml/pyyaml/issues/94 + tags: anchor + yaml: | + --- + - &😁 unicode anchor + tree: | + +STR + +DOC --- + +SEQ + =VAL &😁 :unicode anchor + -SEQ + -DOC + -STR + json: | + [ + "unicode anchor" + ] + dump: | + --- + - &😁 unicode anchor diff --git a/src/93JH.yaml b/src/93JH.yaml new file mode 100644 index 0000000..1a9d434 --- /dev/null +++ b/src/93JH.yaml @@ -0,0 +1,40 @@ +--- +- name: Block Mappings in Block Sequence + from: NimYAML tests + tags: mapping sequence + yaml: |2 + - key: value + key2: value2 + - + key3: value3 + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL :key + =VAL :value + =VAL :key2 + =VAL :value2 + -MAP + +MAP + =VAL :key3 + =VAL :value3 + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "key": "value", + "key2": "value2" + }, + { + "key3": "value3" + } + ] + dump: | + - key: value + key2: value2 + - key3: value3 diff --git a/src/93WF.yaml b/src/93WF.yaml new file mode 100644 index 0000000..49b82f1 --- /dev/null +++ b/src/93WF.yaml @@ -0,0 +1,27 @@ +--- +- name: Spec Example 6.6. Line Folding [1.3] + from: K527, modified for YAML 1.3 + tags: folded spec whitespace scalar 1.3-mod + yaml: | + --- >- + trimmed + ␣␣ + ␣ + + as + space + tree: | + +STR + +DOC --- + =VAL >trimmed\n\n\nas space + -DOC + -STR + json: | + "trimmed\n\n\nas space" + dump: | + --- >- + trimmed + + + + as space diff --git a/src/96L6.yaml b/src/96L6.yaml new file mode 100644 index 0000000..53a2cdc --- /dev/null +++ b/src/96L6.yaml @@ -0,0 +1,20 @@ +--- +- name: Spec Example 2.14. In the folded scalars, newlines become spaces + from: http://www.yaml.org/spec/1.2/spec.html#id2761032 + tags: spec folded scalar + yaml: | + --- > + Mark McGwire's + year was crippled + by a knee injury. + tree: | + +STR + +DOC --- + =VAL >Mark McGwire's year was crippled by a knee injury.\n + -DOC + -STR + json: | + "Mark McGwire's year was crippled by a knee injury.\n" + dump: | + --- > + Mark McGwire's year was crippled by a knee injury. diff --git a/src/96NN.yaml b/src/96NN.yaml new file mode 100644 index 0000000..3f75b37 --- /dev/null +++ b/src/96NN.yaml @@ -0,0 +1,25 @@ +--- +- name: Leading tab content in literals + from: '@ingydotnet' + tags: indent literal whitespace + yaml: | + foo: |- + ——»bar + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL |\tbar + -MAP + -DOC + -STR + json: | + {"foo":"\tbar"} + dump: | + foo: |- + ——»bar + +- yaml: | + foo: |- + ——»bar∎ diff --git a/src/98YD.yaml b/src/98YD.yaml new file mode 100644 index 0000000..9faa967 --- /dev/null +++ b/src/98YD.yaml @@ -0,0 +1,11 @@ +--- +- name: Spec Example 5.5. Comment Indicator + from: http://www.yaml.org/spec/1.2/spec.html#id2773032 + tags: spec comment empty + yaml: | + # Comment only. + tree: | + +STR + -STR + json: '' + dump: '' diff --git a/src/9BXH.yaml b/src/9BXH.yaml new file mode 100644 index 0000000..506e9b4 --- /dev/null +++ b/src/9BXH.yaml @@ -0,0 +1,45 @@ +--- +- name: Multiline doublequoted flow mapping key without value + from: '@perlpunk' + tags: double flow mapping + yaml: | + --- + - { "single line", a: b} + - { "multi + line", a: b} + tree: | + +STR + +DOC --- + +SEQ + +MAP {} + =VAL "single line + =VAL : + =VAL :a + =VAL :b + -MAP + +MAP {} + =VAL "multi line + =VAL : + =VAL :a + =VAL :b + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "single line": null, + "a": "b" + }, + { + "multi line": null, + "a": "b" + } + ] + dump: | + --- + - "single line": + a: b + - "multi line": + a: b diff --git a/src/9C9N.yaml b/src/9C9N.yaml new file mode 100644 index 0000000..6c82ee6 --- /dev/null +++ b/src/9C9N.yaml @@ -0,0 +1,17 @@ +--- +- name: Wrong indented flow sequence + from: '@perlpunk' + tags: error flow indent sequence + fail: true + yaml: | + --- + flow: [a, + b, + c] + tree: | + +STR + +DOC --- + +MAP + =VAL :flow + +SEQ [] + =VAL :a diff --git a/src/9CWY.yaml b/src/9CWY.yaml new file mode 100644 index 0000000..7fa2584 --- /dev/null +++ b/src/9CWY.yaml @@ -0,0 +1,19 @@ +--- +- name: Invalid scalar at the end of mapping + from: '@perlpunk' + tags: error mapping sequence + fail: true + yaml: | + key: + - item1 + - item2 + invalid + tree: | + +STR + +DOC + +MAP + =VAL :key + +SEQ + =VAL :item1 + =VAL :item2 + -SEQ diff --git a/src/9DXL.yaml b/src/9DXL.yaml new file mode 100644 index 0000000..59e47f8 --- /dev/null +++ b/src/9DXL.yaml @@ -0,0 +1,45 @@ +--- +- name: Spec Example 9.6. Stream [1.3] + from: 6ZKB, modified for YAML 1.3 + tags: spec header 1.3-mod + yaml: | + Mapping: Document + --- + # Empty + ... + %YAML 1.2 + --- + matches %: 20 + tree: | + +STR + +DOC + +MAP + =VAL :Mapping + =VAL :Document + -MAP + -DOC + +DOC --- + =VAL : + -DOC ... + +DOC --- + +MAP + =VAL :matches % + =VAL :20 + -MAP + -DOC + -STR + json: | + { + "Mapping": "Document" + } + null + { + "matches %": 20 + } + emit: | + Mapping: Document + --- + ... + %YAML 1.2 + --- + matches %: 20 diff --git a/src/9FMG.yaml b/src/9FMG.yaml new file mode 100644 index 0000000..f5433d5 --- /dev/null +++ b/src/9FMG.yaml @@ -0,0 +1,45 @@ +--- +- name: Multi-level Mapping Indent + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/indent.tml + tags: mapping indent + yaml: | + a: + b: + c: d + e: + f: g + h: i + tree: | + +STR + +DOC + +MAP + =VAL :a + +MAP + =VAL :b + +MAP + =VAL :c + =VAL :d + -MAP + =VAL :e + +MAP + =VAL :f + =VAL :g + -MAP + -MAP + =VAL :h + =VAL :i + -MAP + -DOC + -STR + json: | + { + "a": { + "b": { + "c": "d" + }, + "e": { + "f": "g" + } + }, + "h": "i" + } diff --git a/src/9HCY.yaml b/src/9HCY.yaml new file mode 100644 index 0000000..86fb3a9 --- /dev/null +++ b/src/9HCY.yaml @@ -0,0 +1,14 @@ +--- +- name: Need document footer before directives + from: '@ingydotnet' + tags: directive error footer tag unknown-tag + fail: true + yaml: | + !foo "bar" + %TAG ! tag:example.com,2000:app/ + --- + !foo "bar" + tree: | + +STR + +DOC + =VAL "bar diff --git a/src/9J7A.yaml b/src/9J7A.yaml new file mode 100644 index 0000000..dfe0925 --- /dev/null +++ b/src/9J7A.yaml @@ -0,0 +1,25 @@ +--- +- name: Simple Mapping Indent + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/indent.tml + tags: simple mapping indent + yaml: | + foo: + bar: baz + tree: | + +STR + +DOC + +MAP + =VAL :foo + +MAP + =VAL :bar + =VAL :baz + -MAP + -MAP + -DOC + -STR + json: | + { + "foo": { + "bar": "baz" + } + } diff --git a/src/9JBA.yaml b/src/9JBA.yaml new file mode 100644 index 0000000..fba48b2 --- /dev/null +++ b/src/9JBA.yaml @@ -0,0 +1,16 @@ +--- +- name: Invalid comment after end of flow sequence + from: '@perlpunk' + tags: comment error flow sequence + fail: true + yaml: | + --- + [ a, b, c, ]#invalid + tree: | + +STR + +DOC --- + +SEQ [] + =VAL :a + =VAL :b + =VAL :c + -SEQ diff --git a/src/9KAX.yaml b/src/9KAX.yaml new file mode 100644 index 0000000..2ef2808 --- /dev/null +++ b/src/9KAX.yaml @@ -0,0 +1,104 @@ +--- +- name: Various combinations of tags and anchors + from: '@perlpunk' + tags: anchor mapping 1.3-err tag + yaml: | + --- + &a1 + !!str + scalar1 + --- + !!str + &a2 + scalar2 + --- + &a3 + !!str scalar3 + --- + &a4 !!map + &a5 !!str key5: value4 + --- + a6: 1 + &anchor6 b6: 2 + --- + !!map + &a8 !!str key8: value7 + --- + !!map + !!str &a10 key10: value9 + --- + !!str &a11 + value11 + tree: | + +STR + +DOC --- + =VAL &a1 :scalar1 + -DOC + +DOC --- + =VAL &a2 :scalar2 + -DOC + +DOC --- + =VAL &a3 :scalar3 + -DOC + +DOC --- + +MAP &a4 + =VAL &a5 :key5 + =VAL :value4 + -MAP + -DOC + +DOC --- + +MAP + =VAL :a6 + =VAL :1 + =VAL &anchor6 :b6 + =VAL :2 + -MAP + -DOC + +DOC --- + +MAP + =VAL &a8 :key8 + =VAL :value7 + -MAP + -DOC + +DOC --- + +MAP + =VAL &a10 :key10 + =VAL :value9 + -MAP + -DOC + +DOC --- + =VAL &a11 :value11 + -DOC + -STR + json: | + "scalar1" + "scalar2" + "scalar3" + { + "key5": "value4" + } + { + "a6": 1, + "b6": 2 + } + { + "key8": "value7" + } + { + "key10": "value9" + } + "value11" + dump: | + --- &a1 !!str scalar1 + --- &a2 !!str scalar2 + --- &a3 !!str scalar3 + --- &a4 !!map + &a5 !!str key5: value4 + --- + a6: 1 + &anchor6 b6: 2 + --- !!map + &a8 !!str key8: value7 + --- !!map + &a10 !!str key10: value9 + --- &a11 !!str value11 diff --git a/src/9KBC.yaml b/src/9KBC.yaml new file mode 100644 index 0000000..8819e58 --- /dev/null +++ b/src/9KBC.yaml @@ -0,0 +1,11 @@ +--- +- name: Mapping starting at --- line + from: https://gist.github.com/anonymous/c728390e92ec93fb371ac77f21435cca via @ingydotnet + tags: error header mapping + fail: true + yaml: | + --- key1: value1 + key2: value2 + tree: | + +STR + +DOC --- diff --git a/src/9MAG.yaml b/src/9MAG.yaml new file mode 100644 index 0000000..424083f --- /dev/null +++ b/src/9MAG.yaml @@ -0,0 +1,12 @@ +--- +- name: Flow sequence with invalid comma at the beginning + from: '@perlpunk' + tags: error flow sequence + fail: true + yaml: | + --- + [ , a, b, c ] + tree: | + +STR + +DOC --- + +SEQ [] diff --git a/src/9MMA.yaml b/src/9MMA.yaml new file mode 100644 index 0000000..5795696 --- /dev/null +++ b/src/9MMA.yaml @@ -0,0 +1,9 @@ +--- +- name: Directive by itself with no document + from: '@ingydotnet' + tags: error directive + fail: true + yaml: | + %YAML 1.2 + tree: | + +STR diff --git a/src/9MMW.yaml b/src/9MMW.yaml new file mode 100644 index 0000000..f887d5e --- /dev/null +++ b/src/9MMW.yaml @@ -0,0 +1,41 @@ +--- +- name: Single Pair Implicit Entries + from: '@perlpunk, Spec Example 7.21' + tags: flow mapping sequence + yaml: | + - [ YAML : separate ] + - [ "JSON like":adjacent ] + - [ {JSON: like}:adjacent ] + tree: | + +STR + +DOC + +SEQ + +SEQ [] + +MAP {} + =VAL :YAML + =VAL :separate + -MAP + -SEQ + +SEQ [] + +MAP {} + =VAL "JSON like + =VAL :adjacent + -MAP + -SEQ + +SEQ [] + +MAP {} + +MAP {} + =VAL :JSON + =VAL :like + -MAP + =VAL :adjacent + -MAP + -SEQ + -SEQ + -DOC + -STR + dump: | + - - YAML: separate + - - "JSON like": adjacent + - - ? JSON: like + : adjacent diff --git a/src/9MQT.yaml b/src/9MQT.yaml new file mode 100644 index 0000000..3c315cf --- /dev/null +++ b/src/9MQT.yaml @@ -0,0 +1,31 @@ +--- +- name: Scalar doc with '...' in content + from: '@ingydotnet' + tags: double scalar + yaml: | + --- "a + ...x + b" + tree: | + +STR + +DOC --- + =VAL "a ...x b + -DOC + -STR + json: | + "a ...x b" + dump: | + --- a ...x b + emit: | + --- "a ...x b" + +- fail: true + yaml: | + --- "a + ... x + b" + tree: | + +STR + +DOC --- + dump: null + emit: null diff --git a/src/9SA2.yaml b/src/9SA2.yaml new file mode 100644 index 0000000..d0d0f0f --- /dev/null +++ b/src/9SA2.yaml @@ -0,0 +1,37 @@ +--- +- name: Multiline double quoted flow mapping key + from: '@perlpunk' + tags: double flow mapping + yaml: | + --- + - { "single line": value} + - { "multi + line": value} + tree: | + +STR + +DOC --- + +SEQ + +MAP {} + =VAL "single line + =VAL :value + -MAP + +MAP {} + =VAL "multi line + =VAL :value + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "single line": "value" + }, + { + "multi line": "value" + } + ] + dump: | + --- + - "single line": value + - "multi line": value diff --git a/src/9SHH.yaml b/src/9SHH.yaml new file mode 100644 index 0000000..6f24a68 --- /dev/null +++ b/src/9SHH.yaml @@ -0,0 +1,23 @@ +--- +- name: Spec Example 5.8. Quoted Scalar Indicators + from: http://www.yaml.org/spec/1.2/spec.html#id2773890 + tags: spec scalar + yaml: | + single: 'text' + double: "text" + tree: | + +STR + +DOC + +MAP + =VAL :single + =VAL 'text + =VAL :double + =VAL "text + -MAP + -DOC + -STR + json: | + { + "single": "text", + "double": "text" + } diff --git a/src/9TFX.yaml b/src/9TFX.yaml new file mode 100644 index 0000000..e9ba6b8 --- /dev/null +++ b/src/9TFX.yaml @@ -0,0 +1,22 @@ +--- +- name: Spec Example 7.6. Double Quoted Lines [1.3] + from: 7A4E, modified for YAML 1.3 + tags: double spec scalar whitespace 1.3-mod + yaml: | + --- + " 1st non-empty + + 2nd non-empty␣ + 3rd non-empty " + tree: | + +STR + +DOC --- + =VAL " 1st non-empty\n2nd non-empty 3rd non-empty␣ + -DOC + -STR + json: | + " 1st non-empty\n2nd non-empty 3rd non-empty " + dump: | + " 1st non-empty\n2nd non-empty 3rd non-empty " + emit: | + --- " 1st non-empty\n2nd non-empty 3rd non-empty " diff --git a/src/9U5K.yaml b/src/9U5K.yaml new file mode 100644 index 0000000..75af536 --- /dev/null +++ b/src/9U5K.yaml @@ -0,0 +1,61 @@ +--- +- name: Spec Example 2.12. Compact Nested Mapping + from: http://www.yaml.org/spec/1.2/spec.html#id2760821 + tags: spec mapping sequence + yaml: | + --- + # Products purchased + - item : Super Hoop + quantity: 1 + - item : Basketball + quantity: 4 + - item : Big Shoes + quantity: 1 + tree: | + +STR + +DOC --- + +SEQ + +MAP + =VAL :item + =VAL :Super Hoop + =VAL :quantity + =VAL :1 + -MAP + +MAP + =VAL :item + =VAL :Basketball + =VAL :quantity + =VAL :4 + -MAP + +MAP + =VAL :item + =VAL :Big Shoes + =VAL :quantity + =VAL :1 + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "item": "Super Hoop", + "quantity": 1 + }, + { + "item": "Basketball", + "quantity": 4 + }, + { + "item": "Big Shoes", + "quantity": 1 + } + ] + dump: | + --- + - item: Super Hoop + quantity: 1 + - item: Basketball + quantity: 4 + - item: Big Shoes + quantity: 1 diff --git a/src/9WXW.yaml b/src/9WXW.yaml new file mode 100644 index 0000000..5ee5c16 --- /dev/null +++ b/src/9WXW.yaml @@ -0,0 +1,28 @@ +--- +- name: Spec Example 6.18. Primary Tag Handle + from: http://www.yaml.org/spec/1.2/spec.html#id2782728 + tags: local-tag spec directive tag unknown-tag 1.3-err + yaml: | + # Private + !foo "bar" + ... + # Global + %TAG ! tag:example.com,2000:app/ + --- + !foo "bar" + tree: | + +STR + +DOC + =VAL "bar + -DOC ... + +DOC --- + =VAL "bar + -DOC + -STR + json: | + "bar" + "bar" + dump: | + !foo "bar" + ... + --- ! "bar" diff --git a/src/9YRD.yaml b/src/9YRD.yaml new file mode 100644 index 0000000..8396a94 --- /dev/null +++ b/src/9YRD.yaml @@ -0,0 +1,23 @@ +--- +- name: Multiline Scalar at Top Level + from: NimYAML tests + tags: scalar whitespace 1.3-err + yaml: | + a + b␣␣ + c + d + + e + tree: | + +STR + +DOC + =VAL :a b c d\ne + -DOC + -STR + json: | + "a b c d\ne" + dump: | + 'a b c d + + e' diff --git a/src/A2M4.yaml b/src/A2M4.yaml new file mode 100644 index 0000000..03954d3 --- /dev/null +++ b/src/A2M4.yaml @@ -0,0 +1,39 @@ +--- +- name: Spec Example 6.2. Indentation Indicators + from: http://www.yaml.org/spec/1.2/spec.html#id2778101 + tags: explicit-key spec libyaml-err indent whitespace sequence upto-1.2 + yaml: | + ? a + : -»b + - -—»c + - d + tree: | + +STR + +DOC + +MAP + =VAL :a + +SEQ + =VAL :b + +SEQ + =VAL :c + =VAL :d + -SEQ + -SEQ + -MAP + -DOC + -STR + json: | + { + "a": [ + "b", + [ + "c", + "d" + ] + ] + } + dump: | + a: + - b + - - c + - d diff --git a/src/A6F9.yaml b/src/A6F9.yaml new file mode 100644 index 0000000..5b11980 --- /dev/null +++ b/src/A6F9.yaml @@ -0,0 +1,37 @@ +--- +- name: Spec Example 8.4. Chomping Final Line Break + from: http://www.yaml.org/spec/1.2/spec.html#id2795034 + tags: spec literal scalar + yaml: | + strip: |- + text + clip: | + text + keep: |+ + text + tree: | + +STR + +DOC + +MAP + =VAL :strip + =VAL |text + =VAL :clip + =VAL |text\n + =VAL :keep + =VAL |text\n + -MAP + -DOC + -STR + json: | + { + "strip": "text", + "clip": "text\n", + "keep": "text\n" + } + dump: | + strip: |- + text + clip: | + text + keep: | + text diff --git a/src/A984.yaml b/src/A984.yaml new file mode 100644 index 0000000..2ac0454 --- /dev/null +++ b/src/A984.yaml @@ -0,0 +1,29 @@ +--- +- name: Multiline Scalar in Mapping + from: NimYAML tests + tags: scalar + yaml: | + a: b + c + d: + e + f + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL :b c + =VAL :d + =VAL :e f + -MAP + -DOC + -STR + json: | + { + "a": "b c", + "d": "e f" + } + dump: | + a: b c + d: e f diff --git a/src/AB8U.yaml b/src/AB8U.yaml new file mode 100644 index 0000000..29cbb31 --- /dev/null +++ b/src/AB8U.yaml @@ -0,0 +1,21 @@ +--- +- name: Sequence entry that looks like two with wrong indentation + from: '@perlpunk' + tags: scalar sequence + yaml: | + - single multiline + - sequence entry + tree: | + +STR + +DOC + +SEQ + =VAL :single multiline - sequence entry + -SEQ + -DOC + -STR + json: | + [ + "single multiline - sequence entry" + ] + dump: | + - single multiline - sequence entry diff --git a/src/AVM7.yaml b/src/AVM7.yaml new file mode 100644 index 0000000..7c3ce73 --- /dev/null +++ b/src/AVM7.yaml @@ -0,0 +1,10 @@ +--- +- name: Empty Stream + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/misc.tml + tags: edge + yaml: | + ∎ + tree: | + +STR + -STR + json: '' diff --git a/src/AZ63.yaml b/src/AZ63.yaml new file mode 100644 index 0000000..7cc4ef9 --- /dev/null +++ b/src/AZ63.yaml @@ -0,0 +1,31 @@ +--- +- name: Sequence With Same Indentation as Parent Mapping + from: NimYAML tests + tags: indent mapping sequence + yaml: | + one: + - 2 + - 3 + four: 5 + tree: | + +STR + +DOC + +MAP + =VAL :one + +SEQ + =VAL :2 + =VAL :3 + -SEQ + =VAL :four + =VAL :5 + -MAP + -DOC + -STR + json: | + { + "one": [ + 2, + 3 + ], + "four": 5 + } diff --git a/src/AZW3.yaml b/src/AZW3.yaml new file mode 100644 index 0000000..1acb2c4 --- /dev/null +++ b/src/AZW3.yaml @@ -0,0 +1,31 @@ +--- +- name: Lookahead test cases + from: NimYAML tests + tags: mapping edge + yaml: | + - bla"keks: foo + - bla]keks: foo + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL :bla"keks + =VAL :foo + -MAP + +MAP + =VAL :bla]keks + =VAL :foo + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "bla\"keks": "foo" + }, + { + "bla]keks": "foo" + } + ] diff --git a/src/B3HG.yaml b/src/B3HG.yaml new file mode 100644 index 0000000..637c562 --- /dev/null +++ b/src/B3HG.yaml @@ -0,0 +1,24 @@ +--- +- name: Spec Example 8.9. Folded Scalar [1.3] + from: G992, modified for YAML 1.3 + tags: spec folded scalar 1.3-mod + yaml: | + --- > + folded + text + ↵ + ↵ + tree: | + +STR + +DOC --- + =VAL >folded text\n + -DOC + -STR + json: | + "folded text\n" + dump: | + > + folded text + emit: | + --- > + folded text diff --git a/src/B63P.yaml b/src/B63P.yaml new file mode 100644 index 0000000..b89402d --- /dev/null +++ b/src/B63P.yaml @@ -0,0 +1,10 @@ +--- +- name: Directive without document + from: AdaYaml tests + tags: error directive document + fail: true + yaml: | + %YAML 1.2 + ... + tree: | + +STR diff --git a/src/BD7L.yaml b/src/BD7L.yaml new file mode 100644 index 0000000..9ccbdaf --- /dev/null +++ b/src/BD7L.yaml @@ -0,0 +1,15 @@ +--- +- name: Invalid mapping after sequence + from: '@perlpunk' + tags: error mapping sequence + fail: true + yaml: | + - item1 + - item2 + invalid: x + tree: | + +STR + +DOC + +SEQ + =VAL :item1 + =VAL :item2 diff --git a/src/BEC7.yaml b/src/BEC7.yaml new file mode 100644 index 0000000..26f0ba6 --- /dev/null +++ b/src/BEC7.yaml @@ -0,0 +1,19 @@ +--- +- name: Spec Example 6.14. “YAML” directive + from: http://www.yaml.org/spec/1.2/spec.html#id2781929 + tags: spec directive + yaml: | + %YAML 1.3 # Attempt parsing + # with a warning + --- + "foo" + tree: | + +STR + +DOC --- + =VAL "foo + -DOC + -STR + json: | + "foo" + dump: | + --- "foo" diff --git a/src/BF9H.yaml b/src/BF9H.yaml new file mode 100644 index 0000000..fbae34a --- /dev/null +++ b/src/BF9H.yaml @@ -0,0 +1,16 @@ +--- +- name: Trailing comment in multiline plain scalar + from: '@perlpunk' + tags: comment error scalar + fail: true + yaml: | + --- + plain: a + b # end of scalar + c + tree: | + +STR + +DOC --- + +MAP + =VAL :plain + =VAL :a b diff --git a/src/BS4K.yaml b/src/BS4K.yaml new file mode 100644 index 0000000..519b9f2 --- /dev/null +++ b/src/BS4K.yaml @@ -0,0 +1,13 @@ +--- +- name: Comment between plain scalar lines + from: https://gist.github.com/anonymous/269f16d582fdd30a7dcf8c9249c5da7f via @ingydotnet + tags: error scalar + fail: true + yaml: | + word1 # comment + word2 + tree: | + +STR + +DOC + =VAL :word1 + -DOC diff --git a/src/BU8L.yaml b/src/BU8L.yaml new file mode 100644 index 0000000..d126897 --- /dev/null +++ b/src/BU8L.yaml @@ -0,0 +1,29 @@ +--- +- name: Node Anchor and Tag on Seperate Lines + from: https://gist.github.com/anonymous/f192e7dab6da31831f264dbf1947cb83 via @ingydotnet + tags: anchor indent 1.3-err tag + yaml: | + key: &anchor + !!map + a: b + tree: | + +STR + +DOC + +MAP + =VAL :key + +MAP &anchor + =VAL :a + =VAL :b + -MAP + -MAP + -DOC + -STR + json: | + { + "key": { + "a": "b" + } + } + dump: | + key: &anchor !!map + a: b diff --git a/src/C2DT.yaml b/src/C2DT.yaml new file mode 100644 index 0000000..f9950eb --- /dev/null +++ b/src/C2DT.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 7.18. Flow Mapping Adjacent Values + from: http://www.yaml.org/spec/1.2/spec.html#id2792073 + tags: spec flow mapping + yaml: | + { + "adjacent":value, + "readable": value, + "empty": + } + tree: | + +STR + +DOC + +MAP {} + =VAL "adjacent + =VAL :value + =VAL "readable + =VAL :value + =VAL "empty + =VAL : + -MAP + -DOC + -STR + json: | + { + "adjacent": "value", + "readable": "value", + "empty": null + } + dump: | + "adjacent": value + "readable": value + "empty": diff --git a/src/C2SP.yaml b/src/C2SP.yaml new file mode 100644 index 0000000..2ad9de9 --- /dev/null +++ b/src/C2SP.yaml @@ -0,0 +1,13 @@ +--- +- name: Flow Mapping Key on two lines + from: '@perlpunk' + tags: error flow mapping + fail: true + yaml: | + [23 + ]: 42 + tree: | + +STR + +DOC + +SEQ [] + =VAL :23 diff --git a/src/C4HZ.yaml b/src/C4HZ.yaml new file mode 100644 index 0000000..765040e --- /dev/null +++ b/src/C4HZ.yaml @@ -0,0 +1,100 @@ +--- +- name: Spec Example 2.24. Global Tags + from: http://www.yaml.org/spec/1.2/spec.html#id2761719 + tags: spec tag alias directive local-tag + yaml: | + %TAG ! tag:clarkevans.com,2002: + --- !shape + # Use the ! handle for presenting + # tag:clarkevans.com,2002:circle + - !circle + center: &ORIGIN {x: 73, y: 129} + radius: 7 + - !line + start: *ORIGIN + finish: { x: 89, y: 102 } + - !label + start: *ORIGIN + color: 0xFFEEBB + text: Pretty vector drawing. + tree: | + +STR + +DOC --- + +SEQ + +MAP + =VAL :center + +MAP {} &ORIGIN + =VAL :x + =VAL :73 + =VAL :y + =VAL :129 + -MAP + =VAL :radius + =VAL :7 + -MAP + +MAP + =VAL :start + =ALI *ORIGIN + =VAL :finish + +MAP {} + =VAL :x + =VAL :89 + =VAL :y + =VAL :102 + -MAP + -MAP + +MAP + =VAL :start + =ALI *ORIGIN + =VAL :color + =VAL :0xFFEEBB + =VAL :text + =VAL :Pretty vector drawing. + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "center": { + "x": 73, + "y": 129 + }, + "radius": 7 + }, + { + "start": { + "x": 73, + "y": 129 + }, + "finish": { + "x": 89, + "y": 102 + } + }, + { + "start": { + "x": 73, + "y": 129 + }, + "color": 16772795, + "text": "Pretty vector drawing." + } + ] + dump: | + --- ! + - ! + center: &ORIGIN + x: 73 + y: 129 + radius: 7 + - ! + start: *ORIGIN + finish: + x: 89 + y: 102 + - ! + start: *ORIGIN + color: 0xFFEEBB + text: Pretty vector drawing. diff --git a/src/CC74.yaml b/src/CC74.yaml new file mode 100644 index 0000000..b5bfc0a --- /dev/null +++ b/src/CC74.yaml @@ -0,0 +1,18 @@ +--- +- name: Spec Example 6.20. Tag Handles + from: http://www.yaml.org/spec/1.2/spec.html#id2783195 + tags: spec directive tag unknown-tag + yaml: | + %TAG !e! tag:example.com,2000:app/ + --- + !e!foo "bar" + tree: | + +STR + +DOC --- + =VAL "bar + -DOC + -STR + json: | + "bar" + dump: | + --- ! "bar" diff --git a/src/CFD4.yaml b/src/CFD4.yaml new file mode 100644 index 0000000..5a6e7d6 --- /dev/null +++ b/src/CFD4.yaml @@ -0,0 +1,29 @@ +--- +- name: Empty implicit key in single pair flow sequences + from: '@perlpunk' + tags: empty-key flow sequence + yaml: | + - [ : empty key ] + - [: another empty key] + tree: | + +STR + +DOC + +SEQ + +SEQ [] + +MAP {} + =VAL : + =VAL :empty key + -MAP + -SEQ + +SEQ [] + +MAP {} + =VAL : + =VAL :another empty key + -MAP + -SEQ + -SEQ + -DOC + -STR + dump: | + - - : empty key + - - : another empty key diff --git a/src/CML9.yaml b/src/CML9.yaml new file mode 100644 index 0000000..20ad32a --- /dev/null +++ b/src/CML9.yaml @@ -0,0 +1,16 @@ +--- +- name: Missing comma in flow + from: ihttps://gist.github.com/anonymous/4ba3365607cc14b4f656e391b45bf4f4 via @ingydotnet + tags: error flow comment + fail: true + yaml: | + key: [ word1 + # xxx + word2 ] + tree: | + +STR + +DOC + +MAP + =VAL :key + +SEQ [] + =VAL :word1 diff --git a/src/CN3R.yaml b/src/CN3R.yaml new file mode 100644 index 0000000..38e6db7 --- /dev/null +++ b/src/CN3R.yaml @@ -0,0 +1,56 @@ +--- +- name: Various location of anchors in flow sequence + from: '@perlpunk' + tags: anchor flow mapping sequence + yaml: | + &flowseq [ + a: b, + &c c: d, + { &e e: f }, + &g { g: h } + ] + tree: | + +STR + +DOC + +SEQ [] &flowseq + +MAP {} + =VAL :a + =VAL :b + -MAP + +MAP {} + =VAL &c :c + =VAL :d + -MAP + +MAP {} + =VAL &e :e + =VAL :f + -MAP + +MAP {} &g + =VAL :g + =VAL :h + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "a": "b" + }, + { + "c": "d" + }, + { + "e": "f" + }, + { + "g": "h" + } + ] + dump: | + &flowseq + - a: b + - &c c: d + - &e e: f + - &g + g: h diff --git a/src/CPZ3.yaml b/src/CPZ3.yaml new file mode 100644 index 0000000..a0ea0a5 --- /dev/null +++ b/src/CPZ3.yaml @@ -0,0 +1,23 @@ +--- +- name: Doublequoted scalar starting with a tab + from: '@perlpunk' + tags: double scalar + yaml: | + --- + tab: "\tstring" + tree: | + +STR + +DOC --- + +MAP + =VAL :tab + =VAL "\tstring + -MAP + -DOC + -STR + json: | + { + "tab": "\tstring" + } + dump: | + --- + tab: "\tstring" diff --git a/src/CQ3W.yaml b/src/CQ3W.yaml new file mode 100644 index 0000000..a1e614f --- /dev/null +++ b/src/CQ3W.yaml @@ -0,0 +1,13 @@ +--- +- name: Double quoted string without closing quote + from: '@perlpunk' + tags: error double + fail: true + yaml: | + --- + key: "missing closing quote + tree: | + +STR + +DOC --- + +MAP + =VAL :key diff --git a/src/CT4Q.yaml b/src/CT4Q.yaml new file mode 100644 index 0000000..de1285f --- /dev/null +++ b/src/CT4Q.yaml @@ -0,0 +1,28 @@ +--- +- name: Spec Example 7.20. Single Pair Explicit Entry + from: http://www.yaml.org/spec/1.2/spec.html#id2792424 + tags: explicit-key spec flow mapping + yaml: | + [ + ? foo + bar : baz + ] + tree: | + +STR + +DOC + +SEQ [] + +MAP {} + =VAL :foo bar + =VAL :baz + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "foo bar": "baz" + } + ] + dump: | + - foo bar: baz diff --git a/src/CTN5.yaml b/src/CTN5.yaml new file mode 100644 index 0000000..84b0be5 --- /dev/null +++ b/src/CTN5.yaml @@ -0,0 +1,15 @@ +--- +- name: Flow sequence with invalid extra comma + from: '@perlpunk' + tags: error flow sequence + fail: true + yaml: | + --- + [ a, b, c, , ] + tree: | + +STR + +DOC --- + +SEQ [] + =VAL :a + =VAL :b + =VAL :c diff --git a/src/CUP7.yaml b/src/CUP7.yaml new file mode 100644 index 0000000..10a4f88 --- /dev/null +++ b/src/CUP7.yaml @@ -0,0 +1,26 @@ +--- +- name: Spec Example 5.6. Node Property Indicators + from: http://www.yaml.org/spec/1.2/spec.html#id2773402 + tags: local-tag spec tag alias + yaml: | + anchored: !local &anchor value + alias: *anchor + tree: | + +STR + +DOC + +MAP + =VAL :anchored + =VAL &anchor :value + =VAL :alias + =ALI *anchor + -MAP + -DOC + -STR + json: | + { + "anchored": "value", + "alias": "value" + } + dump: | + anchored: &anchor !local value + alias: *anchor diff --git a/src/CVW2.yaml b/src/CVW2.yaml new file mode 100644 index 0000000..786ba11 --- /dev/null +++ b/src/CVW2.yaml @@ -0,0 +1,16 @@ +--- +- name: Invalid comment after comma + from: '@perlpunk' + tags: comment error flow sequence + fail: true + yaml: | + --- + [ a, b, c,#invalid + ] + tree: | + +STR + +DOC --- + +SEQ [] + =VAL :a + =VAL :b + =VAL :c diff --git a/src/CXX2.yaml b/src/CXX2.yaml new file mode 100644 index 0000000..31fda0a --- /dev/null +++ b/src/CXX2.yaml @@ -0,0 +1,10 @@ +--- +- name: Mapping with anchor on document start line + from: '@perlpunk' + tags: anchor error header mapping + fail: true + yaml: | + --- &anchor a: b + tree: | + +STR + +DOC --- diff --git a/src/D49Q.yaml b/src/D49Q.yaml new file mode 100644 index 0000000..0c32fd1 --- /dev/null +++ b/src/D49Q.yaml @@ -0,0 +1,15 @@ +--- +- name: Multiline single quoted implicit keys + from: '@perlpunk' + tags: error single mapping + fail: true + yaml: | + 'a\nb': 1 + 'c + d': 1 + tree: | + +STR + +DOC + +MAP + =VAL 'a\\nb + =VAL :1 diff --git a/src/D83L.yaml b/src/D83L.yaml new file mode 100644 index 0000000..be87a1f --- /dev/null +++ b/src/D83L.yaml @@ -0,0 +1,28 @@ +--- +- name: Block scalar indicator order + from: '@perlpunk' + tags: indent literal + yaml: | + - |2- + explicit indent and chomp + - |-2 + chomp and explicit indent + tree: | + +STR + +DOC + +SEQ + =VAL |explicit indent and chomp + =VAL |chomp and explicit indent + -SEQ + -DOC + -STR + json: | + [ + "explicit indent and chomp", + "chomp and explicit indent" + ] + dump: | + - |- + explicit indent and chomp + - |- + chomp and explicit indent diff --git a/src/D88J.yaml b/src/D88J.yaml new file mode 100644 index 0000000..a69a0e2 --- /dev/null +++ b/src/D88J.yaml @@ -0,0 +1,29 @@ +--- +- name: Flow Sequence in Block Mapping + from: NimYAML tests + tags: flow sequence mapping + yaml: | + a: [b, c] + tree: | + +STR + +DOC + +MAP + =VAL :a + +SEQ [] + =VAL :b + =VAL :c + -SEQ + -MAP + -DOC + -STR + json: | + { + "a": [ + "b", + "c" + ] + } + dump: | + a: + - b + - c diff --git a/src/D9TU.yaml b/src/D9TU.yaml new file mode 100644 index 0000000..21fb988 --- /dev/null +++ b/src/D9TU.yaml @@ -0,0 +1,19 @@ +--- +- name: Single Pair Block Mapping + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml + tags: simple mapping + yaml: | + foo: bar + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :bar + -MAP + -DOC + -STR + json: | + { + "foo": "bar" + } diff --git a/src/DBG4.yaml b/src/DBG4.yaml new file mode 100644 index 0000000..304d834 --- /dev/null +++ b/src/DBG4.yaml @@ -0,0 +1,62 @@ +--- +- name: Spec Example 7.10. Plain Characters + from: http://www.yaml.org/spec/1.2/spec.html#id2789510 + tags: spec flow sequence scalar + yaml: | + # Outside flow collection: + - ::vector + - ": - ()" + - Up, up, and away! + - -123 + - http://example.com/foo#bar + # Inside flow collection: + - [ ::vector, + ": - ()", + "Up, up and away!", + -123, + http://example.com/foo#bar ] + tree: | + +STR + +DOC + +SEQ + =VAL :::vector + =VAL ": - () + =VAL :Up, up, and away! + =VAL :-123 + =VAL :http://example.com/foo#bar + +SEQ [] + =VAL :::vector + =VAL ": - () + =VAL "Up, up and away! + =VAL :-123 + =VAL :http://example.com/foo#bar + -SEQ + -SEQ + -DOC + -STR + json: | + [ + "::vector", + ": - ()", + "Up, up, and away!", + -123, + "http://example.com/foo#bar", + [ + "::vector", + ": - ()", + "Up, up and away!", + -123, + "http://example.com/foo#bar" + ] + ] + dump: | + - ::vector + - ": - ()" + - Up, up, and away! + - -123 + - http://example.com/foo#bar + - - ::vector + - ": - ()" + - "Up, up and away!" + - -123 + - http://example.com/foo#bar diff --git a/src/DC7X.yaml b/src/DC7X.yaml new file mode 100644 index 0000000..ada199e --- /dev/null +++ b/src/DC7X.yaml @@ -0,0 +1,37 @@ +--- +- name: Various trailing tabs + from: '@perlpunk' + tags: comment whitespace + yaml: | + a: b———» + seq:———» + - a———» + c: d———»#X + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL :b + =VAL :seq + +SEQ + =VAL :a + -SEQ + =VAL :c + =VAL :d + -MAP + -DOC + -STR + json: | + { + "a": "b", + "seq": [ + "a" + ], + "c": "d" + } + dump: | + a: b + seq: + - a + c: d diff --git a/src/DE56.yaml b/src/DE56.yaml new file mode 100644 index 0000000..74f5b52 --- /dev/null +++ b/src/DE56.yaml @@ -0,0 +1,87 @@ +--- +- name: Trailing tabs in double quoted + from: '@ingydotnet' + tags: double whitespace + yaml: | + "1 trailing\t + tab" + tree: | + +STR + +DOC + =VAL "1 trailing\t tab + -DOC + -STR + json: | + "1 trailing\t tab" + dump: | + "1 trailing\t tab" + +- yaml: | + "2 trailing\t␣␣ + tab" + tree: | + +STR + +DOC + =VAL "2 trailing\t tab + -DOC + -STR + json: | + "2 trailing\t tab" + dump: | + "2 trailing\t tab" + +- yaml: | + "3 trailing\————» + tab" + tree: | + +STR + +DOC + =VAL "3 trailing\t tab + -DOC + -STR + json: | + "3 trailing\t tab" + dump: | + "3 trailing\t tab" + +- yaml: | + "4 trailing\————»␣␣ + tab" + tree: | + +STR + +DOC + =VAL "4 trailing\t tab + -DOC + -STR + json: | + "4 trailing\t tab" + dump: | + "4 trailing\t tab" + +- yaml: | + "5 trailing—» + tab" + tree: | + +STR + +DOC + =VAL "5 trailing tab + -DOC + -STR + json: | + "5 trailing tab" + dump: | + "5 trailing tab" + +- yaml: | + "6 trailing—»␣␣ + tab" + tree: | + +STR + +DOC + =VAL "6 trailing tab + -DOC + -STR + json: | + "6 trailing tab" + dump: | + "6 trailing tab" diff --git a/src/DFF7.yaml b/src/DFF7.yaml new file mode 100644 index 0000000..d081f31 --- /dev/null +++ b/src/DFF7.yaml @@ -0,0 +1,27 @@ +--- +- name: Spec Example 7.16. Flow Mapping Entries + from: http://www.yaml.org/spec/1.2/spec.html#id2791260 + tags: explicit-key spec flow mapping + yaml: | + { + ? explicit: entry, + implicit: entry, + ? + } + tree: | + +STR + +DOC + +MAP {} + =VAL :explicit + =VAL :entry + =VAL :implicit + =VAL :entry + =VAL : + =VAL : + -MAP + -DOC + -STR + dump: | + explicit: entry + implicit: entry + : diff --git a/src/DHP8.yaml b/src/DHP8.yaml new file mode 100644 index 0000000..b3c25da --- /dev/null +++ b/src/DHP8.yaml @@ -0,0 +1,26 @@ +--- +- name: Flow Sequence + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/sequence.tml + tags: flow sequence + yaml: | + [foo, bar, 42] + tree: | + +STR + +DOC + +SEQ [] + =VAL :foo + =VAL :bar + =VAL :42 + -SEQ + -DOC + -STR + json: | + [ + "foo", + "bar", + 42 + ] + dump: | + - foo + - bar + - 42 diff --git a/src/DK3J.yaml b/src/DK3J.yaml new file mode 100644 index 0000000..fc01be3 --- /dev/null +++ b/src/DK3J.yaml @@ -0,0 +1,20 @@ +--- +- name: Zero indented block scalar with line that looks like a comment + from: '@perlpunk' + tags: comment folded scalar + yaml: | + --- > + line1 + # no comment + line3 + tree: | + +STR + +DOC --- + =VAL >line1 # no comment line3\n + -DOC + -STR + json: | + "line1 # no comment line3\n" + dump: | + --- > + line1 # no comment line3 diff --git a/src/DK4H.yaml b/src/DK4H.yaml new file mode 100644 index 0000000..558e468 --- /dev/null +++ b/src/DK4H.yaml @@ -0,0 +1,14 @@ +--- +- name: Implicit key followed by newline + from: '@perlpunk' + tags: error flow mapping sequence + fail: true + yaml: | + --- + [ key + : value ] + tree: | + +STR + +DOC --- + +SEQ [] + =VAL :key diff --git a/src/DK95.yaml b/src/DK95.yaml new file mode 100644 index 0000000..eb80249 --- /dev/null +++ b/src/DK95.yaml @@ -0,0 +1,172 @@ +--- +- name: Tabs that look like indentation + from: '@ingydotnet' + tags: indent whitespace + yaml: | + foo: + ———»bar + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :bar + -MAP + -DOC + -STR + json: | + { + "foo" : "bar" + } + emit: | + --- + foo: bar + +- fail: true + yaml: | + foo: "bar + ————»baz" + tree: | + +STR + +DOC + +MAP + =VAL :foo + +- yaml: | + foo: "bar + ——»baz" + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL "bar baz + -MAP + -DOC + -STR + json: | + { + "foo" : "bar baz" + } + emit: | + --- + foo: "bar baz" + +- yaml: |2 + ———» + foo: 1 + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :1 + -MAP + -DOC + -STR + json: | + { + "foo" : 1 + } + emit: | + --- + foo: 1 + +- yaml: | + foo: 1 + ————» + bar: 2 + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :1 + =VAL :bar + =VAL :2 + -MAP + -DOC + -STR + json: | + { + "foo" : 1, + "bar" : 2 + } + emit: | + --- + foo: 1 + bar: 2 + +- yaml: | + foo: 1 + ———» + bar: 2 + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :1 + =VAL :bar + =VAL :2 + -MAP + -DOC + -STR + json: | + { + "foo" : 1, + "bar" : 2 + } + emit: | + --- + foo: 1 + bar: 2 + +- fail: true + yaml: | + foo: + a: 1 + ——»b: 2 + tree: | + +STR + +DOC + +MAP + =VAL :foo + +MAP + =VAL :a + =VAL :1 + +- yaml: | + %YAML 1.2 + ————» + --- + tree: | + +STR + +DOC --- + =VAL : + -DOC + -STR + json: | + null + emit: | + --- null + +- yaml: | + foo: "bar + ———» ——» baz ——» ——» " + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL "bar baz \t \t␣ + -MAP + -DOC + -STR + json: | + { + "foo" : "bar baz \t \t " + } + emit: | + --- + foo: "bar baz \t \t " diff --git a/src/DMG6.yaml b/src/DMG6.yaml new file mode 100644 index 0000000..8a89d28 --- /dev/null +++ b/src/DMG6.yaml @@ -0,0 +1,18 @@ +--- +- name: Wrong indendation in Map + from: '@perlpunk' + tags: error mapping indent + fail: true + yaml: | + key: + ok: 1 + wrong: 2 + tree: | + +STR + +DOC + +MAP + =VAL :key + +MAP + =VAL :ok + =VAL :1 + -MAP diff --git a/src/DWX9.yaml b/src/DWX9.yaml new file mode 100644 index 0000000..672a43e --- /dev/null +++ b/src/DWX9.yaml @@ -0,0 +1,32 @@ +--- +- name: Spec Example 8.8. Literal Content + from: http://www.yaml.org/spec/1.2/spec.html#id2796118 + tags: spec literal scalar comment whitespace 1.3-err + yaml: | + | + ␣ + ␣␣ + literal + ␣␣␣ + ␣␣ + text + + # Comment + tree: | + +STR + +DOC + =VAL |\n\nliteral\n \n\ntext\n + -DOC + -STR + json: | + "\n\nliteral\n \n\ntext\n" + dump: | + "\n\nliteral\n \n\ntext\n" + emit: | + | + + + literal + ␣␣␣ + + text diff --git a/src/E76Z.yaml b/src/E76Z.yaml new file mode 100644 index 0000000..06f28e3 --- /dev/null +++ b/src/E76Z.yaml @@ -0,0 +1,26 @@ +--- +- name: Aliases in Implicit Block Mapping + from: NimYAML tests + tags: mapping alias + yaml: | + &a a: &b b + *b : *a + tree: | + +STR + +DOC + +MAP + =VAL &a :a + =VAL &b :b + =ALI *b + =ALI *a + -MAP + -DOC + -STR + json: | + { + "a": "b", + "b": "a" + } + dump: | + &a a: &b b + *b : *a diff --git a/src/EB22.yaml b/src/EB22.yaml new file mode 100644 index 0000000..d96d9bb --- /dev/null +++ b/src/EB22.yaml @@ -0,0 +1,16 @@ +--- +- name: Missing document-end marker before directive + from: '@perlpunk' + tags: error directive footer + fail: true + yaml: | + --- + scalar1 # comment + %YAML 1.2 + --- + scalar2 + tree: | + +STR + +DOC --- + =VAL :scalar1 + -DOC diff --git a/src/EHF6.yaml b/src/EHF6.yaml new file mode 100644 index 0000000..b4e22fb --- /dev/null +++ b/src/EHF6.yaml @@ -0,0 +1,33 @@ +--- +- name: Tags for Flow Objects + from: NimYAML tests + tags: tag flow mapping sequence + yaml: | + !!map { + k: !!seq + [ a, !!str b] + } + tree: | + +STR + +DOC + +MAP {} + =VAL :k + +SEQ [] + =VAL :a + =VAL :b + -SEQ + -MAP + -DOC + -STR + json: | + { + "k": [ + "a", + "b" + ] + } + dump: | + !!map + k: !!seq + - a + - !!str b diff --git a/src/EW3V.yaml b/src/EW3V.yaml new file mode 100644 index 0000000..0a21a49 --- /dev/null +++ b/src/EW3V.yaml @@ -0,0 +1,13 @@ +--- +- name: Wrong indendation in mapping + from: '@perlpunk' + tags: error mapping indent + fail: true + yaml: | + k1: v1 + k2: v2 + tree: | + +STR + +DOC + +MAP + =VAL :k1 diff --git a/src/EX5H.yaml b/src/EX5H.yaml new file mode 100644 index 0000000..a27ba11 --- /dev/null +++ b/src/EX5H.yaml @@ -0,0 +1,28 @@ +--- +- name: Multiline Scalar at Top Level [1.3] + from: 9YRD, modified for YAML 1.3 + tags: scalar whitespace 1.3-mod + yaml: | + --- + a + b␣␣ + c + d + + e + tree: | + +STR + +DOC --- + =VAL :a b c d\ne + -DOC + -STR + json: | + "a b c d\ne" + dump: | + 'a b c d + + e' + emit: | + --- a b c d + + e diff --git a/src/EXG3.yaml b/src/EXG3.yaml new file mode 100644 index 0000000..18745e6 --- /dev/null +++ b/src/EXG3.yaml @@ -0,0 +1,20 @@ +--- +- name: Three dashes and content without space [1.3] + from: 82AN, modified for YAML 1.3 + tags: scalar 1.3-mod + yaml: | + --- + ---word1 + word2 + tree: | + +STR + +DOC --- + =VAL :---word1 word2 + -DOC + -STR + json: | + "---word1 word2" + dump: | + '---word1 word2' + emit: | + --- '---word1 word2' diff --git a/src/F2C7.yaml b/src/F2C7.yaml new file mode 100644 index 0000000..8e46129 --- /dev/null +++ b/src/F2C7.yaml @@ -0,0 +1,32 @@ +--- +- name: Anchors and Tags + from: NimYAML tests + tags: anchor tag + yaml: |2 + - &a !!str a + - !!int 2 + - !!int &c 4 + - &d d + tree: | + +STR + +DOC + +SEQ + =VAL &a :a + =VAL :2 + =VAL &c :4 + =VAL &d :d + -SEQ + -DOC + -STR + json: | + [ + "a", + 2, + 4, + "d" + ] + dump: | + - &a !!str a + - !!int 2 + - &c !!int 4 + - &d d diff --git a/src/F3CP.yaml b/src/F3CP.yaml new file mode 100644 index 0000000..71b0b89 --- /dev/null +++ b/src/F3CP.yaml @@ -0,0 +1,47 @@ +--- +- name: Nested flow collections on one line + from: '@perlpunk' + tags: flow mapping sequence + yaml: | + --- + { a: [b, c, { d: [e, f] } ] } + tree: | + +STR + +DOC --- + +MAP {} + =VAL :a + +SEQ [] + =VAL :b + =VAL :c + +MAP {} + =VAL :d + +SEQ [] + =VAL :e + =VAL :f + -SEQ + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "a": [ + "b", + "c", + { + "d": [ + "e", + "f" + ] + } + ] + } + dump: | + --- + a: + - b + - c + - d: + - e + - f diff --git a/src/F6MC.yaml b/src/F6MC.yaml new file mode 100644 index 0000000..e246e85 --- /dev/null +++ b/src/F6MC.yaml @@ -0,0 +1,40 @@ +--- +- name: More indented lines at the beginning of folded block scalars + from: '@perlpunk' + tags: folded indent + yaml: | + --- + a: >2 + more indented + regular + b: >2 + + + more indented + regular + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL > more indented\nregular\n + =VAL :b + =VAL >\n\n more indented\nregular\n + -MAP + -DOC + -STR + json: | + { + "a": " more indented\nregular\n", + "b": "\n\n more indented\nregular\n" + } + emit: | + --- + a: >2 + more indented + regular + b: >2 + + + more indented + regular diff --git a/src/F8F9.yaml b/src/F8F9.yaml new file mode 100644 index 0000000..8fd5f71 --- /dev/null +++ b/src/F8F9.yaml @@ -0,0 +1,52 @@ +--- +- name: Spec Example 8.5. Chomping Trailing Lines + from: http://www.yaml.org/spec/1.2/spec.html#id2795435 + tags: spec literal scalar comment + yaml: |2 + # Strip + # Comments: + strip: |- + # text + ␣␣ + # Clip + # comments: + + clip: | + # text + ␣ + # Keep + # comments: + + keep: |+ + # text + + # Trail + # comments. + tree: | + +STR + +DOC + +MAP + =VAL :strip + =VAL |# text + =VAL :clip + =VAL |# text\n + =VAL :keep + =VAL |# text\n\n + -MAP + -DOC + -STR + json: | + { + "strip": "# text", + "clip": "# text\n", + "keep": "# text\n\n" + } + dump: | + strip: |- + # text + clip: | + # text + keep: |+ + # text + + ... diff --git a/src/FBC9.yaml b/src/FBC9.yaml new file mode 100644 index 0000000..9f69b72 --- /dev/null +++ b/src/FBC9.yaml @@ -0,0 +1,37 @@ +--- +- name: Allowed characters in plain scalars + from: '@perlpunk' + tags: scalar + yaml: | + safe: a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~ + !"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~ + safe question mark: ?foo + safe colon: :foo + safe dash: -foo + tree: | + +STR + +DOC + +MAP + =VAL :safe + =VAL :a!"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~ !"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~ + =VAL :safe question mark + =VAL :?foo + =VAL :safe colon + =VAL ::foo + =VAL :safe dash + =VAL :-foo + -MAP + -DOC + -STR + json: | + { + "safe": "a!\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~ !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~", + "safe question mark": "?foo", + "safe colon": ":foo", + "safe dash": "-foo" + } + dump: | + safe: a!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~ !"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~ + safe question mark: ?foo + safe colon: :foo + safe dash: -foo diff --git a/src/FH7J.yaml b/src/FH7J.yaml new file mode 100644 index 0000000..04e887b --- /dev/null +++ b/src/FH7J.yaml @@ -0,0 +1,33 @@ +--- +- name: Tags on Empty Scalars + from: NimYAML tests + tags: tag scalar + yaml: | + - !!str + - + !!null : a + b: !!str + - !!str : !!null + tree: | + +STR + +DOC + +SEQ + =VAL : + +MAP + =VAL : + =VAL :a + =VAL :b + =VAL : + -MAP + +MAP + =VAL : + =VAL : + -MAP + -SEQ + -DOC + -STR + dump: | + - !!str + - !!null : a + b: !!str + - !!str : !!null diff --git a/src/FP8R.yaml b/src/FP8R.yaml new file mode 100644 index 0000000..9da8017 --- /dev/null +++ b/src/FP8R.yaml @@ -0,0 +1,20 @@ +--- +- name: Zero indented block scalar + from: '@perlpunk' + tags: folded indent scalar + yaml: | + --- > + line1 + line2 + line3 + tree: | + +STR + +DOC --- + =VAL >line1 line2 line3\n + -DOC + -STR + json: | + "line1 line2 line3\n" + dump: | + --- > + line1 line2 line3 diff --git a/src/FQ7F.yaml b/src/FQ7F.yaml new file mode 100644 index 0000000..f0afa4b --- /dev/null +++ b/src/FQ7F.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 2.1. Sequence of Scalars + from: http://www.yaml.org/spec/1.2/spec.html#id2759963 + tags: spec sequence + yaml: | + - Mark McGwire + - Sammy Sosa + - Ken Griffey + tree: | + +STR + +DOC + +SEQ + =VAL :Mark McGwire + =VAL :Sammy Sosa + =VAL :Ken Griffey + -SEQ + -DOC + -STR + json: | + [ + "Mark McGwire", + "Sammy Sosa", + "Ken Griffey" + ] + toke: | + SEQ-MARK 0 1 1 1 + WS-SPACE 1 1 1 2 + TEXT-VAL 2 12 1 3 :Mark McGwire + WS-NEWLN 14 1 1 15 + SEQ-MARK 15 1 2 1 + WS-SPACE 1 1 1 2 + TEXT-VAL 2 12 1 3 :Sammy Sosa + WS-NEWLN 14 1 1 15 diff --git a/src/FRK4.yaml b/src/FRK4.yaml new file mode 100644 index 0000000..a8734d0 --- /dev/null +++ b/src/FRK4.yaml @@ -0,0 +1,20 @@ +--- +- name: Spec Example 7.3. Completely Empty Flow Nodes + from: http://www.yaml.org/spec/1.2/spec.html#id2786868 + tags: empty-key explicit-key spec flow mapping + yaml: | + { + ? foo :, + : bar, + } + tree: | + +STR + +DOC + +MAP {} + =VAL :foo + =VAL : + =VAL : + =VAL :bar + -MAP + -DOC + -STR diff --git a/src/FTA2.yaml b/src/FTA2.yaml new file mode 100644 index 0000000..9e0c2f7 --- /dev/null +++ b/src/FTA2.yaml @@ -0,0 +1,22 @@ +--- +- name: Single block sequence with anchor and explicit document start + from: '@perlpunk' + tags: anchor header sequence + yaml: | + --- &sequence + - a + tree: | + +STR + +DOC --- + +SEQ &sequence + =VAL :a + -SEQ + -DOC + -STR + json: | + [ + "a" + ] + dump: | + --- &sequence + - a diff --git a/src/FUP4.yaml b/src/FUP4.yaml new file mode 100644 index 0000000..8d84b4d --- /dev/null +++ b/src/FUP4.yaml @@ -0,0 +1,30 @@ +--- +- name: Flow Sequence in Flow Sequence + from: NimYAML tests + tags: sequence flow + yaml: | + [a, [b, c]] + tree: | + +STR + +DOC + +SEQ [] + =VAL :a + +SEQ [] + =VAL :b + =VAL :c + -SEQ + -SEQ + -DOC + -STR + json: | + [ + "a", + [ + "b", + "c" + ] + ] + dump: | + - a + - - b + - c diff --git a/src/G4RS.yaml b/src/G4RS.yaml new file mode 100644 index 0000000..c468cd5 --- /dev/null +++ b/src/G4RS.yaml @@ -0,0 +1,47 @@ +--- +- name: Spec Example 2.17. Quoted Scalars + from: http://www.yaml.org/spec/1.2/spec.html#id2761245 + tags: spec scalar + yaml: | + unicode: "Sosa did fine.\u263A" + control: "\b1998\t1999\t2000\n" + hex esc: "\x0d\x0a is \r\n" + + single: '"Howdy!" he cried.' + quoted: ' # Not a ''comment''.' + tie-fighter: '|\-*-/|' + tree: | + +STR + +DOC + +MAP + =VAL :unicode + =VAL "Sosa did fine.☺ + =VAL :control + =VAL "\b1998\t1999\t2000\n + =VAL :hex esc + =VAL "\r\n is \r\n + =VAL :single + =VAL '"Howdy!" he cried. + =VAL :quoted + =VAL ' # Not a 'comment'. + =VAL :tie-fighter + =VAL '|\\-*-/| + -MAP + -DOC + -STR + json: | + { + "unicode": "Sosa did fine.☺", + "control": "\b1998\t1999\t2000\n", + "hex esc": "\r\n is \r\n", + "single": "\"Howdy!\" he cried.", + "quoted": " # Not a 'comment'.", + "tie-fighter": "|\\-*-/|" + } + dump: | + unicode: "Sosa did fine.\u263A" + control: "\b1998\t1999\t2000\n" + hex esc: "\r\n is \r\n" + single: '"Howdy!" he cried.' + quoted: ' # Not a ''comment''.' + tie-fighter: '|\-*-/|' diff --git a/src/G5U8.yaml b/src/G5U8.yaml new file mode 100644 index 0000000..ad8f4b9 --- /dev/null +++ b/src/G5U8.yaml @@ -0,0 +1,13 @@ +--- +- name: Plain dashes in flow sequence + from: '@ingydotnet' + tags: flow sequence + fail: true + yaml: | + --- + - [-, -] + tree: | + +STR + +DOC --- + +SEQ + +SEQ [] diff --git a/src/G7JE.yaml b/src/G7JE.yaml new file mode 100644 index 0000000..6c075a0 --- /dev/null +++ b/src/G7JE.yaml @@ -0,0 +1,15 @@ +--- +- name: Multiline implicit keys + from: '@perlpunk' + tags: error mapping + fail: true + yaml: | + a\nb: 1 + c + d: 1 + tree: | + +STR + +DOC + +MAP + =VAL :a\\nb + =VAL :1 diff --git a/src/G992.yaml b/src/G992.yaml new file mode 100644 index 0000000..8a57df8 --- /dev/null +++ b/src/G992.yaml @@ -0,0 +1,21 @@ +--- +- name: Spec Example 8.9. Folded Scalar + from: http://www.yaml.org/spec/1.2/spec.html#id2796371 + tags: spec folded scalar 1.3-err + yaml: | + > + folded + text + ↵ + ↵ + tree: | + +STR + +DOC + =VAL >folded text\n + -DOC + -STR + json: | + "folded text\n" + dump: | + > + folded text diff --git a/src/G9HC.yaml b/src/G9HC.yaml new file mode 100644 index 0000000..227a6ed --- /dev/null +++ b/src/G9HC.yaml @@ -0,0 +1,16 @@ +--- +- name: Invalid anchor in zero indented sequence + from: '@perlpunk' + tags: anchor error sequence + fail: true + yaml: | + --- + seq: + &anchor + - a + - b + tree: | + +STR + +DOC --- + +MAP + =VAL :seq diff --git a/src/GDY7.yaml b/src/GDY7.yaml new file mode 100644 index 0000000..6962ecc --- /dev/null +++ b/src/GDY7.yaml @@ -0,0 +1,14 @@ +--- +- name: Comment that looks like a mapping key + from: '@perlpunk' + tags: comment error mapping + fail: true + yaml: | + key: value + this is #not a: key + tree: | + +STR + +DOC + +MAP + =VAL :key + =VAL :value diff --git a/src/GH63.yaml b/src/GH63.yaml new file mode 100644 index 0000000..fda8c77 --- /dev/null +++ b/src/GH63.yaml @@ -0,0 +1,27 @@ +--- +- name: Mixed Block Mapping (explicit to implicit) + from: NimYAML tests + tags: explicit-key mapping + yaml: | + ? a + : 1.3 + fifteen: d + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL :1.3 + =VAL :fifteen + =VAL :d + -MAP + -DOC + -STR + json: | + { + "a": 1.3, + "fifteen": "d" + } + dump: | + a: 1.3 + fifteen: d diff --git a/src/GT5M.yaml b/src/GT5M.yaml new file mode 100644 index 0000000..9c951af --- /dev/null +++ b/src/GT5M.yaml @@ -0,0 +1,14 @@ +--- +- name: Node anchor in sequence + from: '@perlpunk' + tags: anchor error sequence + fail: true + yaml: | + - item1 + &node + - item2 + tree: | + +STR + +DOC + +SEQ + =VAL :item1 diff --git a/src/H2RW.yaml b/src/H2RW.yaml new file mode 100644 index 0000000..1a65a14 --- /dev/null +++ b/src/H2RW.yaml @@ -0,0 +1,51 @@ +--- +- name: Blank lines + from: IRC discussion with leont + tags: comment literal scalar whitespace + yaml: | + foo: 1 + + bar: 2 + ␣␣␣␣ + text: | + a + ␣␣␣␣ + b + + c + ␣ + d + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :1 + =VAL :bar + =VAL :2 + =VAL :text + =VAL |a\n \nb\n\nc\n\nd\n + -MAP + -DOC + -STR + json: | + { + "foo": 1, + "bar": 2, + "text": "a\n \nb\n\nc\n\nd\n" + } + dump: | + foo: 1 + bar: 2 + text: "a\n \nb\n\nc\n\nd\n" + emit: | + foo: 1 + bar: 2 + text: | + a + ␣␣␣␣ + b + + c + + d diff --git a/src/H3Z8.yaml b/src/H3Z8.yaml new file mode 100644 index 0000000..ff988d2 --- /dev/null +++ b/src/H3Z8.yaml @@ -0,0 +1,23 @@ +--- +- name: Literal unicode + from: '@perlpunk' + tags: scalar + yaml: | + --- + wanted: love ♥ and peace ☮ + tree: | + +STR + +DOC --- + +MAP + =VAL :wanted + =VAL :love ♥ and peace ☮ + -MAP + -DOC + -STR + json: | + { + "wanted": "love ♥ and peace ☮" + } + dump: | + --- + wanted: "love \u2665 and peace \u262E" diff --git a/src/H7J7.yaml b/src/H7J7.yaml new file mode 100644 index 0000000..009d9e3 --- /dev/null +++ b/src/H7J7.yaml @@ -0,0 +1,15 @@ +--- +- name: Node anchor not indented + from: https://gist.github.com/anonymous/f192e7dab6da31831f264dbf1947cb83 via @ingydotnet + tags: anchor error indent tag + fail: true + yaml: | + key: &x + !!map + a: b + tree: | + +STR + +DOC + +MAP + =VAL :key + =VAL &x : diff --git a/src/H7TQ.yaml b/src/H7TQ.yaml new file mode 100644 index 0000000..c8d4065 --- /dev/null +++ b/src/H7TQ.yaml @@ -0,0 +1,10 @@ +--- +- name: Extra words on %YAML directive + from: '@ingydotnet' + tags: directive + fail: true + yaml: | + %YAML 1.2 foo + --- + tree: | + +STR diff --git a/src/HM87.yaml b/src/HM87.yaml new file mode 100644 index 0000000..7b54f49 --- /dev/null +++ b/src/HM87.yaml @@ -0,0 +1,37 @@ +--- +- name: Scalars in flow start with syntax char + from: '@ingydotnet' + tags: flow scalar + yaml: | + [:x] + tree: | + +STR + +DOC + +SEQ [] + =VAL ::x + -SEQ + -DOC + -STR + json: | + [ + ":x" + ] + dump: | + - :x + +- yaml: | + [?x] + tree: | + +STR + +DOC + +SEQ [] + =VAL :?x + -SEQ + -DOC + -STR + json: | + [ + "?x" + ] + dump: | + - ?x diff --git a/src/HMK4.yaml b/src/HMK4.yaml new file mode 100644 index 0000000..c4c248b --- /dev/null +++ b/src/HMK4.yaml @@ -0,0 +1,38 @@ +--- +- name: Spec Example 2.16. Indentation determines scope + from: http://www.yaml.org/spec/1.2/spec.html#id2761083 + tags: spec folded literal + yaml: | + name: Mark McGwire + accomplishment: > + Mark set a major league + home run record in 1998. + stats: | + 65 Home Runs + 0.278 Batting Average + tree: | + +STR + +DOC + +MAP + =VAL :name + =VAL :Mark McGwire + =VAL :accomplishment + =VAL >Mark set a major league home run record in 1998.\n + =VAL :stats + =VAL |65 Home Runs\n0.278 Batting Average\n + -MAP + -DOC + -STR + json: | + { + "name": "Mark McGwire", + "accomplishment": "Mark set a major league home run record in 1998.\n", + "stats": "65 Home Runs\n0.278 Batting Average\n" + } + dump: | + name: Mark McGwire + accomplishment: > + Mark set a major league home run record in 1998. + stats: | + 65 Home Runs + 0.278 Batting Average diff --git a/src/HMQ5.yaml b/src/HMQ5.yaml new file mode 100644 index 0000000..a645764 --- /dev/null +++ b/src/HMQ5.yaml @@ -0,0 +1,27 @@ +--- +- name: Spec Example 6.23. Node Properties + from: http://www.yaml.org/spec/1.2/spec.html#id2783940 + tags: spec tag alias + yaml: | + !!str &a1 "foo": + !!str bar + &a2 baz : *a1 + tree: | + +STR + +DOC + +MAP + =VAL &a1 "foo + =VAL :bar + =VAL &a2 :baz + =ALI *a1 + -MAP + -DOC + -STR + json: | + { + "foo": "bar", + "baz": "foo" + } + dump: | + &a1 !!str "foo": !!str bar + &a2 baz: *a1 diff --git a/src/HRE5.yaml b/src/HRE5.yaml new file mode 100644 index 0000000..f4d4236 --- /dev/null +++ b/src/HRE5.yaml @@ -0,0 +1,13 @@ +--- +- name: Double quoted scalar with escaped single quote + from: https://github.com/yaml/libyaml/issues/68 + tags: double error single + fail: true + yaml: | + --- + double: "quoted \' scalar" + tree: | + +STR + +DOC --- + +MAP + =VAL :double diff --git a/src/HS5T.yaml b/src/HS5T.yaml new file mode 100644 index 0000000..9a24d17 --- /dev/null +++ b/src/HS5T.yaml @@ -0,0 +1,21 @@ +--- +- name: Spec Example 7.12. Plain Lines + from: http://www.yaml.org/spec/1.2/spec.html#id2789986 + tags: spec scalar whitespace upto-1.2 + yaml: | + 1st non-empty + + 2nd non-empty␣ + ———»3rd non-empty + tree: | + +STR + +DOC + =VAL :1st non-empty\n2nd non-empty 3rd non-empty + -DOC + -STR + json: | + "1st non-empty\n2nd non-empty 3rd non-empty" + dump: | + '1st non-empty + + 2nd non-empty 3rd non-empty' diff --git a/src/HU3P.yaml b/src/HU3P.yaml new file mode 100644 index 0000000..537d97a --- /dev/null +++ b/src/HU3P.yaml @@ -0,0 +1,14 @@ +--- +- name: Invalid Mapping in plain scalar + from: https://gist.github.com/anonymous/d305fd8e54cfe7a484088c91a8a2e533 via @ingydotnet + tags: error mapping scalar + fail: true + yaml: | + key: + word1 word2 + no: key + tree: | + +STR + +DOC + +MAP + =VAL :key diff --git a/src/HWV9.yaml b/src/HWV9.yaml new file mode 100644 index 0000000..1e8264d --- /dev/null +++ b/src/HWV9.yaml @@ -0,0 +1,11 @@ +--- +- name: Document-end marker + from: '@perlpunk' + tags: footer + yaml: | + ... + tree: | + +STR + -STR + json: '' + dump: '' diff --git a/src/J3BT.yaml b/src/J3BT.yaml new file mode 100644 index 0000000..f7d766d --- /dev/null +++ b/src/J3BT.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 5.12. Tabs and Spaces + from: http://www.yaml.org/spec/1.2/spec.html#id2775350 + tags: spec whitespace upto-1.2 + yaml: | + # Tabs and spaces + quoted: "Quoted ———»" + block:—»| + void main() { + —»printf("Hello, world!\n"); + } + tree: | + +STR + +DOC + +MAP + =VAL :quoted + =VAL "Quoted \t + =VAL :block + =VAL |void main() {\n\tprintf("Hello, world!\\n");\n}\n + -MAP + -DOC + -STR + json: | + { + "quoted": "Quoted \t", + "block": "void main() {\n\tprintf(\"Hello, world!\\n\");\n}\n" + } + dump: | + quoted: "Quoted \t" + block: | + void main() { + —»printf("Hello, world!\n"); + } diff --git a/src/J5UC.yaml b/src/J5UC.yaml new file mode 100644 index 0000000..6690568 --- /dev/null +++ b/src/J5UC.yaml @@ -0,0 +1,27 @@ +--- +- name: Multiple Pair Block Mapping + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml + tags: mapping + yaml: | + foo: blue + bar: arrr + baz: jazz + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL :blue + =VAL :bar + =VAL :arrr + =VAL :baz + =VAL :jazz + -MAP + -DOC + -STR + json: | + { + "foo": "blue", + "bar": "arrr", + "baz": "jazz" + } diff --git a/src/J7PZ.yaml b/src/J7PZ.yaml new file mode 100644 index 0000000..9183bae --- /dev/null +++ b/src/J7PZ.yaml @@ -0,0 +1,52 @@ +--- +- name: Spec Example 2.26. Ordered Mappings + from: http://www.yaml.org/spec/1.2/spec.html#id2761780 + tags: spec mapping tag unknown-tag + yaml: | + # The !!omap tag is one of the optional types + # introduced for YAML 1.1. In 1.2, it is not + # part of the standard tags and should not be + # enabled by default. + # Ordered maps are represented as + # A sequence of mappings, with + # each mapping having one key + --- !!omap + - Mark McGwire: 65 + - Sammy Sosa: 63 + - Ken Griffy: 58 + tree: | + +STR + +DOC --- + +SEQ + +MAP + =VAL :Mark McGwire + =VAL :65 + -MAP + +MAP + =VAL :Sammy Sosa + =VAL :63 + -MAP + +MAP + =VAL :Ken Griffy + =VAL :58 + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "Mark McGwire": 65 + }, + { + "Sammy Sosa": 63 + }, + { + "Ken Griffy": 58 + } + ] + dump: | + --- !!omap + - Mark McGwire: 65 + - Sammy Sosa: 63 + - Ken Griffy: 58 diff --git a/src/J7VC.yaml b/src/J7VC.yaml new file mode 100644 index 0000000..1676809 --- /dev/null +++ b/src/J7VC.yaml @@ -0,0 +1,28 @@ +--- +- name: Empty Lines Between Mapping Elements + from: NimYAML tests + tags: whitespace mapping + yaml: | + one: 2 + + + three: 4 + tree: | + +STR + +DOC + +MAP + =VAL :one + =VAL :2 + =VAL :three + =VAL :4 + -MAP + -DOC + -STR + json: | + { + "one": 2, + "three": 4 + } + dump: | + one: 2 + three: 4 diff --git a/src/J9HZ.yaml b/src/J9HZ.yaml new file mode 100644 index 0000000..85ddbdf --- /dev/null +++ b/src/J9HZ.yaml @@ -0,0 +1,49 @@ +--- +- name: Spec Example 2.9. Single Document with Two Comments + from: http://www.yaml.org/spec/1.2/spec.html#id2760633 + tags: mapping sequence spec comment + yaml: | + --- + hr: # 1998 hr ranking + - Mark McGwire + - Sammy Sosa + rbi: + # 1998 rbi ranking + - Sammy Sosa + - Ken Griffey + tree: | + +STR + +DOC --- + +MAP + =VAL :hr + +SEQ + =VAL :Mark McGwire + =VAL :Sammy Sosa + -SEQ + =VAL :rbi + +SEQ + =VAL :Sammy Sosa + =VAL :Ken Griffey + -SEQ + -MAP + -DOC + -STR + json: | + { + "hr": [ + "Mark McGwire", + "Sammy Sosa" + ], + "rbi": [ + "Sammy Sosa", + "Ken Griffey" + ] + } + dump: | + --- + hr: + - Mark McGwire + - Sammy Sosa + rbi: + - Sammy Sosa + - Ken Griffey diff --git a/src/JEF9.yaml b/src/JEF9.yaml new file mode 100644 index 0000000..9dd0d72 --- /dev/null +++ b/src/JEF9.yaml @@ -0,0 +1,53 @@ +--- +- name: Trailing whitespace in streams + from: '@ingydotnet' + tags: literal + yaml: | + - |+ + ↵ + ↵ + tree: | + +STR + +DOC + +SEQ + =VAL |\n\n + -SEQ + -DOC + -STR + json: | + [ + "\n\n" + ] + dump: | + - |+ + ↵ + ↵ + ... + +- yaml: | + - |+ + ␣␣␣ + tree: | + +STR + +DOC + +SEQ + =VAL |\n + -SEQ + -DOC + -STR + json: | + [ + "\n" + ] + dump: | + - |+ + + ... + +- yaml: | + - |+ + ␣␣␣∎ + dump: | + - |+ + + ... diff --git a/src/JHB9.yaml b/src/JHB9.yaml new file mode 100644 index 0000000..c09dee0 --- /dev/null +++ b/src/JHB9.yaml @@ -0,0 +1,49 @@ +--- +- name: Spec Example 2.7. Two Documents in a Stream + from: http://www.yaml.org/spec/1.2/spec.html#id2760493 + tags: spec header + yaml: | + # Ranking of 1998 home runs + --- + - Mark McGwire + - Sammy Sosa + - Ken Griffey + + # Team ranking + --- + - Chicago Cubs + - St Louis Cardinals + tree: | + +STR + +DOC --- + +SEQ + =VAL :Mark McGwire + =VAL :Sammy Sosa + =VAL :Ken Griffey + -SEQ + -DOC + +DOC --- + +SEQ + =VAL :Chicago Cubs + =VAL :St Louis Cardinals + -SEQ + -DOC + -STR + json: | + [ + "Mark McGwire", + "Sammy Sosa", + "Ken Griffey" + ] + [ + "Chicago Cubs", + "St Louis Cardinals" + ] + dump: | + --- + - Mark McGwire + - Sammy Sosa + - Ken Griffey + --- + - Chicago Cubs + - St Louis Cardinals diff --git a/src/JKF3.yaml b/src/JKF3.yaml new file mode 100644 index 0000000..b387deb --- /dev/null +++ b/src/JKF3.yaml @@ -0,0 +1,13 @@ +--- +- name: Multiline unidented double quoted block key + from: '@ingydotnet' + tags: indent + fail: true + yaml: | + - - "bar + bar": x + tree: | + +STR + +DOC + +SEQ + +SEQ diff --git a/src/JQ4R.yaml b/src/JQ4R.yaml new file mode 100644 index 0000000..f14ed82 --- /dev/null +++ b/src/JQ4R.yaml @@ -0,0 +1,36 @@ +--- +- name: Spec Example 8.14. Block Sequence + from: http://www.yaml.org/spec/1.2/spec.html#id2797596 + tags: mapping spec sequence + yaml: | + block sequence: + - one + - two : three + tree: | + +STR + +DOC + +MAP + =VAL :block sequence + +SEQ + =VAL :one + +MAP + =VAL :two + =VAL :three + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "block sequence": [ + "one", + { + "two": "three" + } + ] + } + dump: | + block sequence: + - one + - two: three diff --git a/src/JR7V.yaml b/src/JR7V.yaml new file mode 100644 index 0000000..3971f8b --- /dev/null +++ b/src/JR7V.yaml @@ -0,0 +1,76 @@ +--- +- name: Question marks in scalars + from: '@perlpunk' + tags: flow scalar + yaml: | + - a?string + - another ? string + - key: value? + - [a?string] + - [another ? string] + - {key: value? } + - {key: value?} + - {key?: value } + tree: | + +STR + +DOC + +SEQ + =VAL :a?string + =VAL :another ? string + +MAP + =VAL :key + =VAL :value? + -MAP + +SEQ [] + =VAL :a?string + -SEQ + +SEQ [] + =VAL :another ? string + -SEQ + +MAP {} + =VAL :key + =VAL :value? + -MAP + +MAP {} + =VAL :key + =VAL :value? + -MAP + +MAP {} + =VAL :key? + =VAL :value + -MAP + -SEQ + -DOC + -STR + json: | + [ + "a?string", + "another ? string", + { + "key": "value?" + }, + [ + "a?string" + ], + [ + "another ? string" + ], + { + "key": "value?" + }, + { + "key": "value?" + }, + { + "key?": "value" + } + ] + dump: | + - a?string + - another ? string + - key: value? + - - a?string + - - another ? string + - key: value? + - key: value? + - key?: value diff --git a/src/JS2J.yaml b/src/JS2J.yaml new file mode 100644 index 0000000..3545da3 --- /dev/null +++ b/src/JS2J.yaml @@ -0,0 +1,23 @@ +--- +- name: Spec Example 6.29. Node Anchors + from: http://www.yaml.org/spec/1.2/spec.html#id2785977 + tags: spec alias + yaml: | + First occurrence: &anchor Value + Second occurrence: *anchor + tree: | + +STR + +DOC + +MAP + =VAL :First occurrence + =VAL &anchor :Value + =VAL :Second occurrence + =ALI *anchor + -MAP + -DOC + -STR + json: | + { + "First occurrence": "Value", + "Second occurrence": "Value" + } diff --git a/src/JTV5.yaml b/src/JTV5.yaml new file mode 100644 index 0000000..e099a3a --- /dev/null +++ b/src/JTV5.yaml @@ -0,0 +1,30 @@ +--- +- name: Block Mapping with Multiline Scalars + from: NimYAML tests + tags: explicit-key mapping scalar + yaml: | + ? a + true + : null + d + ? e + 42 + tree: | + +STR + +DOC + +MAP + =VAL :a true + =VAL :null d + =VAL :e 42 + =VAL : + -MAP + -DOC + -STR + json: | + { + "a true": "null d", + "e 42": null + } + dump: | + a true: null d + e 42: diff --git a/src/JY7Z.yaml b/src/JY7Z.yaml new file mode 100644 index 0000000..fb4dfae --- /dev/null +++ b/src/JY7Z.yaml @@ -0,0 +1,17 @@ +--- +- name: Trailing content that looks like a mapping + from: '@perlpunk' + tags: error mapping double + fail: true + yaml: | + key1: "quoted1" + key2: "quoted2" no key: nor value + key3: "quoted3" + tree: | + +STR + +DOC + +MAP + =VAL :key1 + =VAL "quoted1 + =VAL :key2 + =VAL "quoted2 diff --git a/src/K3WX.yaml b/src/K3WX.yaml new file mode 100644 index 0000000..5de2c1c --- /dev/null +++ b/src/K3WX.yaml @@ -0,0 +1,24 @@ +--- +- name: Colon and adjacent value after comment on next line + from: + tags: comment flow mapping + yaml: | + --- + { "foo" # comment + :bar } + tree: | + +STR + +DOC --- + +MAP {} + =VAL "foo + =VAL :bar + -MAP + -DOC + -STR + json: | + { + "foo": "bar" + } + dump: | + --- + "foo": bar diff --git a/src/K4SU.yaml b/src/K4SU.yaml new file mode 100644 index 0000000..c67005a --- /dev/null +++ b/src/K4SU.yaml @@ -0,0 +1,24 @@ +--- +- name: Multiple Entry Block Sequence + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/sequence.tml + tags: sequence + yaml: | + - foo + - bar + - 42 + tree: | + +STR + +DOC + +SEQ + =VAL :foo + =VAL :bar + =VAL :42 + -SEQ + -DOC + -STR + json: | + [ + "foo", + "bar", + 42 + ] diff --git a/src/K527.yaml b/src/K527.yaml new file mode 100644 index 0000000..1fd0e8c --- /dev/null +++ b/src/K527.yaml @@ -0,0 +1,27 @@ +--- +- name: Spec Example 6.6. Line Folding + from: http://www.yaml.org/spec/1.2/spec.html#id2779289 + tags: folded spec whitespace scalar 1.3-err + yaml: | + >- + trimmed + ␣␣ + ␣ + + as + space + tree: | + +STR + +DOC + =VAL >trimmed\n\n\nas space + -DOC + -STR + json: | + "trimmed\n\n\nas space" + dump: | + >- + trimmed + + + + as space diff --git a/src/K54U.yaml b/src/K54U.yaml new file mode 100644 index 0000000..63f6da8 --- /dev/null +++ b/src/K54U.yaml @@ -0,0 +1,17 @@ +--- +- name: Tab after document header + from: '@perlpunk' + tags: header whitespace + yaml: | + ---»scalar + tree: | + +STR + +DOC --- + =VAL :scalar + -DOC + -STR + json: | + "scalar" + dump: | + --- scalar + ... diff --git a/src/K858.yaml b/src/K858.yaml new file mode 100644 index 0000000..c7b077c --- /dev/null +++ b/src/K858.yaml @@ -0,0 +1,36 @@ +--- +- name: Spec Example 8.6. Empty Scalar Chomping + from: http://www.yaml.org/spec/1.2/spec.html#id2795596 + tags: spec folded literal whitespace + yaml: | + strip: >- + + clip: > + + keep: |+ + ↵ + tree: | + +STR + +DOC + +MAP + =VAL :strip + =VAL > + =VAL :clip + =VAL > + =VAL :keep + =VAL |\n + -MAP + -DOC + -STR + json: | + { + "strip": "", + "clip": "", + "keep": "\n" + } + dump: | + strip: "" + clip: "" + keep: |2+ + + ... diff --git a/src/KH5V.yaml b/src/KH5V.yaml new file mode 100644 index 0000000..9a87698 --- /dev/null +++ b/src/KH5V.yaml @@ -0,0 +1,40 @@ +--- +- name: Inline tabs in double quoted + from: '@ingydotnet' + tags: double whitespace + yaml: | + "1 inline\ttab" + tree: | + +STR + +DOC + =VAL "1 inline\ttab + -DOC + -STR + json: | + "1 inline\ttab" + +- yaml: | + "2 inline\——»tab" + tree: | + +STR + +DOC + =VAL "2 inline\ttab + -DOC + -STR + json: | + "2 inline\ttab" + dump: | + "2 inline\ttab" + +- yaml: | + "3 inline———»tab" + tree: | + +STR + +DOC + =VAL "3 inline\ttab + -DOC + -STR + json: | + "3 inline\ttab" + dump: | + "3 inline\ttab" diff --git a/src/KK5P.yaml b/src/KK5P.yaml new file mode 100644 index 0000000..ff564f2 --- /dev/null +++ b/src/KK5P.yaml @@ -0,0 +1,81 @@ +--- +- name: Various combinations of explicit block mappings + from: '@perlpunk' + tags: explicit-key mapping sequence + yaml: | + complex1: + ? - a + complex2: + ? - a + : b + complex3: + ? - a + : > + b + complex4: + ? > + a + : + complex5: + ? - a + : - b + tree: | + +STR + +DOC + +MAP + =VAL :complex1 + +MAP + +SEQ + =VAL :a + -SEQ + =VAL : + -MAP + =VAL :complex2 + +MAP + +SEQ + =VAL :a + -SEQ + =VAL :b + -MAP + =VAL :complex3 + +MAP + +SEQ + =VAL :a + -SEQ + =VAL >b\n + -MAP + =VAL :complex4 + +MAP + =VAL >a\n + =VAL : + -MAP + =VAL :complex5 + +MAP + +SEQ + =VAL :a + -SEQ + +SEQ + =VAL :b + -SEQ + -MAP + -MAP + -DOC + -STR + dump: | + complex1: + ? - a + : + complex2: + ? - a + : b + complex3: + ? - a + : > + b + complex4: + ? > + a + : + complex5: + ? - a + : - b diff --git a/src/KMK3.yaml b/src/KMK3.yaml new file mode 100644 index 0000000..4c6b460 --- /dev/null +++ b/src/KMK3.yaml @@ -0,0 +1,29 @@ +--- +- name: Block Submapping + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/mapping.tml + tags: mapping + yaml: | + foo: + bar: 1 + baz: 2 + tree: | + +STR + +DOC + +MAP + =VAL :foo + +MAP + =VAL :bar + =VAL :1 + -MAP + =VAL :baz + =VAL :2 + -MAP + -DOC + -STR + json: | + { + "foo": { + "bar": 1 + }, + "baz": 2 + } diff --git a/src/KS4U.yaml b/src/KS4U.yaml new file mode 100644 index 0000000..35c0a44 --- /dev/null +++ b/src/KS4U.yaml @@ -0,0 +1,17 @@ +--- +- name: Invalid item after end of flow sequence + from: '@perlpunk' + tags: error flow sequence + fail: true + yaml: | + --- + [ + sequence item + ] + invalid item + tree: | + +STR + +DOC --- + +SEQ [] + =VAL :sequence item + -SEQ diff --git a/src/KSS4.yaml b/src/KSS4.yaml new file mode 100644 index 0000000..518c20c --- /dev/null +++ b/src/KSS4.yaml @@ -0,0 +1,27 @@ +--- +- name: Scalars on --- line + from: '@perlpunk' + tags: anchor header scalar 1.3-err + yaml: | + --- "quoted + string" + --- &node foo + tree: | + +STR + +DOC --- + =VAL "quoted string + -DOC + +DOC --- + =VAL &node :foo + -DOC + -STR + json: | + "quoted string" + "foo" + dump: | + --- "quoted string" + --- &node foo + ... + emit: | + --- "quoted string" + --- &node foo diff --git a/src/L24T.yaml b/src/L24T.yaml new file mode 100644 index 0000000..a58e9b2 --- /dev/null +++ b/src/L24T.yaml @@ -0,0 +1,45 @@ +--- +- name: Trailing line of spaces + from: '@ingydotnet' + tags: whitespace + yaml: | + foo: | + x + ␣␣␣ + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL |x\n \n + -MAP + -DOC + -STR + json: | + { + "foo" : "x\n \n" + } + emit: | + --- + foo: "x\n \n" + +- yaml: | + foo: | + x + ␣␣␣∎ + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL |x\n \n + -MAP + -DOC + -STR + json: | + { + "foo" : "x\n \n" + } + emit: | + --- + foo: "x\n \n" diff --git a/src/L383.yaml b/src/L383.yaml new file mode 100644 index 0000000..c298919 --- /dev/null +++ b/src/L383.yaml @@ -0,0 +1,22 @@ +--- +- name: Two scalar docs with trailing comments + from: '@ingydotnet' + tags: comment + yaml: | + --- foo # comment + --- foo # comment + tree: | + +STR + +DOC --- + =VAL :foo + -DOC + +DOC --- + =VAL :foo + -DOC + -STR + json: | + "foo" + "foo" + dump: | + --- foo + --- foo diff --git a/src/L94M.yaml b/src/L94M.yaml new file mode 100644 index 0000000..2288c06 --- /dev/null +++ b/src/L94M.yaml @@ -0,0 +1,28 @@ +--- +- name: Tags in Explicit Mapping + from: NimYAML tests + tags: explicit-key tag mapping + yaml: | + ? !!str a + : !!int 47 + ? c + : !!str d + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL :47 + =VAL :c + =VAL :d + -MAP + -DOC + -STR + json: | + { + "a": 47, + "c": "d" + } + dump: | + !!str a: !!int 47 + c: !!str d diff --git a/src/L9U5.yaml b/src/L9U5.yaml new file mode 100644 index 0000000..5e2ed0c --- /dev/null +++ b/src/L9U5.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 7.11. Plain Implicit Keys + from: http://www.yaml.org/spec/1.2/spec.html#id2789794 + tags: spec flow mapping + yaml: | + implicit block key : [ + implicit flow key : value, + ] + tree: | + +STR + +DOC + +MAP + =VAL :implicit block key + +SEQ [] + +MAP {} + =VAL :implicit flow key + =VAL :value + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "implicit block key": [ + { + "implicit flow key": "value" + } + ] + } + dump: | + implicit block key: + - implicit flow key: value diff --git a/src/LE5A.yaml b/src/LE5A.yaml new file mode 100644 index 0000000..21e1576 --- /dev/null +++ b/src/LE5A.yaml @@ -0,0 +1,30 @@ +--- +- name: Spec Example 7.24. Flow Nodes + from: http://www.yaml.org/spec/1.2/spec.html#id2793490 + tags: spec tag alias + yaml: | + - !!str "a" + - 'b' + - &anchor "c" + - *anchor + - !!str + tree: | + +STR + +DOC + +SEQ + =VAL "a + =VAL 'b + =VAL &anchor "c + =ALI *anchor + =VAL : + -SEQ + -DOC + -STR + json: | + [ + "a", + "b", + "c", + "c", + "" + ] diff --git a/src/LHL4.yaml b/src/LHL4.yaml new file mode 100644 index 0000000..8ecc9e0 --- /dev/null +++ b/src/LHL4.yaml @@ -0,0 +1,11 @@ +--- +- name: Invalid tag + from: '@perlpunk' + tags: error tag + fail: true + yaml: | + --- + !invalid{}tag scalar + tree: | + +STR + +DOC --- diff --git a/src/LP6E.yaml b/src/LP6E.yaml new file mode 100644 index 0000000..52060f1 --- /dev/null +++ b/src/LP6E.yaml @@ -0,0 +1,55 @@ +--- +- name: Whitespace After Scalars in Flow + from: NimYAML tests + tags: flow scalar whitespace + yaml: | + - [a, b , c ] + - { "a" : b + , c : 'd' , + e : "f" + } + - [ ] + tree: | + +STR + +DOC + +SEQ + +SEQ [] + =VAL :a + =VAL :b + =VAL :c + -SEQ + +MAP {} + =VAL "a + =VAL :b + =VAL :c + =VAL 'd + =VAL :e + =VAL "f + -MAP + +SEQ [] + -SEQ + -SEQ + -DOC + -STR + json: | + [ + [ + "a", + "b", + "c" + ], + { + "a": "b", + "c": "d", + "e": "f" + }, + [] + ] + dump: | + - - a + - b + - c + - "a": b + c: 'd' + e: "f" + - [] diff --git a/src/LQZ7.yaml b/src/LQZ7.yaml new file mode 100644 index 0000000..5bb7576 --- /dev/null +++ b/src/LQZ7.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 7.4. Double Quoted Implicit Keys + from: http://www.yaml.org/spec/1.2/spec.html#id2787420 + tags: spec scalar flow + yaml: | + "implicit block key" : [ + "implicit flow key" : value, + ] + tree: | + +STR + +DOC + +MAP + =VAL "implicit block key + +SEQ [] + +MAP {} + =VAL "implicit flow key + =VAL :value + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "implicit block key": [ + { + "implicit flow key": "value" + } + ] + } + dump: | + "implicit block key": + - "implicit flow key": value diff --git a/src/LX3P.yaml b/src/LX3P.yaml new file mode 100644 index 0000000..e5ebb6b --- /dev/null +++ b/src/LX3P.yaml @@ -0,0 +1,20 @@ +--- +- name: Implicit Flow Mapping Key on one line + from: '@perlpunk' + tags: complex-key mapping flow sequence 1.3-err + yaml: | + [flow]: block + tree: | + +STR + +DOC + +MAP + +SEQ [] + =VAL :flow + -SEQ + =VAL :block + -MAP + -DOC + -STR + dump: | + ? - flow + : block diff --git a/src/M29M.yaml b/src/M29M.yaml new file mode 100644 index 0000000..370ff21 --- /dev/null +++ b/src/M29M.yaml @@ -0,0 +1,33 @@ +--- +- name: Literal Block Scalar + from: NimYAML tests + tags: literal scalar whitespace + yaml: | + a: | + ab + ␣ + cd + ef + ␣ + + ... + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL |ab\n\ncd\nef\n + -MAP + -DOC ... + -STR + json: | + { + "a": "ab\n\ncd\nef\n" + } + dump: | + a: | + ab + + cd + ef + ... diff --git a/src/M2N8.yaml b/src/M2N8.yaml new file mode 100644 index 0000000..3df5481 --- /dev/null +++ b/src/M2N8.yaml @@ -0,0 +1,42 @@ +--- +- name: Question mark edge cases + from: '@ingydotnet' + tags: edge empty-key + yaml: | + - ? : x + tree: | + +STR + +DOC + +SEQ + +MAP + +MAP + =VAL : + =VAL :x + -MAP + =VAL : + -MAP + -SEQ + -DOC + -STR + dump: | + - ? : x + : + +- yaml: | + ? []: x + tree: | + +STR + +DOC + +MAP + +MAP + +SEQ [] + -SEQ + =VAL :x + -MAP + =VAL : + -MAP + -DOC + -STR + dump: | + ? []: x + : diff --git a/src/M5C3.yaml b/src/M5C3.yaml new file mode 100644 index 0000000..c0075c1 --- /dev/null +++ b/src/M5C3.yaml @@ -0,0 +1,32 @@ +--- +- name: Spec Example 8.21. Block Scalar Nodes + from: http://www.yaml.org/spec/1.2/spec.html#id2799693 + tags: indent spec literal folded tag local-tag 1.3-err + yaml: | + literal: |2 + value + folded: + !foo + >1 + value + tree: | + +STR + +DOC + +MAP + =VAL :literal + =VAL |value\n + =VAL :folded + =VAL >value\n + -MAP + -DOC + -STR + json: | + { + "literal": "value\n", + "folded": "value\n" + } + dump: | + literal: | + value + folded: !foo > + value diff --git a/src/M5DY.yaml b/src/M5DY.yaml new file mode 100644 index 0000000..8a97c16 --- /dev/null +++ b/src/M5DY.yaml @@ -0,0 +1,46 @@ +--- +- name: Spec Example 2.11. Mapping between Sequences + from: http://www.yaml.org/spec/1.2/spec.html#id2760799 + tags: complex-key explicit-key spec mapping sequence + yaml: | + ? - Detroit Tigers + - Chicago cubs + : + - 2001-07-23 + + ? [ New York Yankees, + Atlanta Braves ] + : [ 2001-07-02, 2001-08-12, + 2001-08-14 ] + tree: | + +STR + +DOC + +MAP + +SEQ + =VAL :Detroit Tigers + =VAL :Chicago cubs + -SEQ + +SEQ + =VAL :2001-07-23 + -SEQ + +SEQ [] + =VAL :New York Yankees + =VAL :Atlanta Braves + -SEQ + +SEQ [] + =VAL :2001-07-02 + =VAL :2001-08-12 + =VAL :2001-08-14 + -SEQ + -MAP + -DOC + -STR + dump: | + ? - Detroit Tigers + - Chicago cubs + : - 2001-07-23 + ? - New York Yankees + - Atlanta Braves + : - 2001-07-02 + - 2001-08-12 + - 2001-08-14 diff --git a/src/M6YH.yaml b/src/M6YH.yaml new file mode 100644 index 0000000..97f7618 --- /dev/null +++ b/src/M6YH.yaml @@ -0,0 +1,41 @@ +--- +- name: Block sequence indentation + from: '@ingydotnet' + tags: indent + yaml: | + - | + x + - + foo: bar + - + - 42 + tree: | + +STR + +DOC + +SEQ + =VAL |x\n + +MAP + =VAL :foo + =VAL :bar + -MAP + +SEQ + =VAL :42 + -SEQ + -SEQ + -DOC + -STR + json: | + [ + "x\n", + { + "foo" : "bar" + }, + [ + 42 + ] + ] + dump: | + - | + x + - foo: bar + - - 42 diff --git a/src/M7A3.yaml b/src/M7A3.yaml new file mode 100644 index 0000000..65a7c49 --- /dev/null +++ b/src/M7A3.yaml @@ -0,0 +1,29 @@ +--- +- name: Spec Example 9.3. Bare Documents + from: http://www.yaml.org/spec/1.2/spec.html#id2801226 + tags: spec footer 1.3-err + yaml: | + Bare + document + ... + # No document + ... + | + %!PS-Adobe-2.0 # Not the first line + tree: | + +STR + +DOC + =VAL :Bare document + -DOC ... + +DOC + =VAL |%!PS-Adobe-2.0 # Not the first line\n + -DOC + -STR + json: | + "Bare document" + "%!PS-Adobe-2.0 # Not the first line\n" + emit: | + Bare document + ... + | + %!PS-Adobe-2.0 # Not the first line diff --git a/src/M7NX.yaml b/src/M7NX.yaml new file mode 100644 index 0000000..fa12450 --- /dev/null +++ b/src/M7NX.yaml @@ -0,0 +1,53 @@ +--- +- name: Nested flow collections + from: '@perlpunk' + tags: flow mapping sequence + yaml: | + --- + { + a: [ + b, c, { + d: [e, f] + } + ] + } + tree: | + +STR + +DOC --- + +MAP {} + =VAL :a + +SEQ [] + =VAL :b + =VAL :c + +MAP {} + =VAL :d + +SEQ [] + =VAL :e + =VAL :f + -SEQ + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "a": [ + "b", + "c", + { + "d": [ + "e", + "f" + ] + } + ] + } + dump: | + --- + a: + - b + - c + - d: + - e + - f diff --git a/src/M9B4.yaml b/src/M9B4.yaml new file mode 100644 index 0000000..910b0ce --- /dev/null +++ b/src/M9B4.yaml @@ -0,0 +1,22 @@ +--- +- name: Spec Example 8.7. Literal Scalar + from: http://www.yaml.org/spec/1.2/spec.html#id2795789 + tags: spec literal scalar whitespace 1.3-err + yaml: | + | + literal + ——»text + ↵ + ↵ + tree: | + +STR + +DOC + =VAL |literal\n\ttext\n + -DOC + -STR + json: | + "literal\n\ttext\n" + dump: | + | + literal + —»text diff --git a/src/MJS9.yaml b/src/MJS9.yaml new file mode 100644 index 0000000..d497410 --- /dev/null +++ b/src/MJS9.yaml @@ -0,0 +1,21 @@ +--- +- name: Spec Example 6.7. Block Folding + from: http://www.yaml.org/spec/1.2/spec.html#id2779603 + tags: folded spec scalar whitespace 1.3-err + yaml: | + > + foo␣ + ␣ + —» bar + + baz + tree: | + +STR + +DOC + =VAL >foo \n\n\t bar\n\nbaz\n + -DOC + -STR + json: | + "foo \n\n\t bar\n\nbaz\n" + dump: | + "foo \n\n\t bar\n\nbaz\n" diff --git a/src/MUS6.yaml b/src/MUS6.yaml new file mode 100644 index 0000000..9208fc7 --- /dev/null +++ b/src/MUS6.yaml @@ -0,0 +1,49 @@ +- name: Directive variants + from: '@ingydotnet' + tags: directive + also: ZYU8 + fail: true + yaml: | + %YAML 1.1#... + --- + tree: | + +STR + +- fail: true + yaml: | + %YAML 1.2 + --- + %YAML 1.2 + --- + dump: null + +- yaml: | + %YAML 1.1 + --- + tree: | + +STR + +DOC --- + =VAL : + -DOC + -STR + json: | + null + dump: | + --- + +- yaml: | + %YAML ——» 1.1 + --- + +- yaml: | + %YAML 1.1 # comment + --- + +- note: These 2 are reserved directives + yaml: | + %YAM 1.1 + --- + +- yaml: | + %YAMLL 1.1 + --- diff --git a/src/MXS3.yaml b/src/MXS3.yaml new file mode 100644 index 0000000..ceab9ec --- /dev/null +++ b/src/MXS3.yaml @@ -0,0 +1,25 @@ +--- +- name: Flow Mapping in Block Sequence + from: NimYAML tests + tags: mapping sequence flow + yaml: | + - {a: b} + tree: | + +STR + +DOC + +SEQ + +MAP {} + =VAL :a + =VAL :b + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "a": "b" + } + ] + dump: | + - a: b diff --git a/src/MYW6.yaml b/src/MYW6.yaml new file mode 100644 index 0000000..74fe5eb --- /dev/null +++ b/src/MYW6.yaml @@ -0,0 +1,22 @@ +--- +- name: Block Scalar Strip + from: NimYAML tests + tags: literal scalar whitespace 1.3-err + yaml: | + |- + ab + ␣ + ␣ + ... + tree: | + +STR + +DOC + =VAL |ab + -DOC ... + -STR + json: | + "ab" + dump: | + |- + ab + ... diff --git a/src/MZX3.yaml b/src/MZX3.yaml new file mode 100644 index 0000000..0b985b8 --- /dev/null +++ b/src/MZX3.yaml @@ -0,0 +1,31 @@ +--- +- name: Non-Specific Tags on Scalars + from: NimYAML tests + tags: folded scalar + yaml: | + - plain + - "double quoted" + - 'single quoted' + - > + block + - plain again + tree: | + +STR + +DOC + +SEQ + =VAL :plain + =VAL "double quoted + =VAL 'single quoted + =VAL >block\n + =VAL :plain again + -SEQ + -DOC + -STR + json: | + [ + "plain", + "double quoted", + "single quoted", + "block\n", + "plain again" + ] diff --git a/src/N4JP.yaml b/src/N4JP.yaml new file mode 100644 index 0000000..51abed3 --- /dev/null +++ b/src/N4JP.yaml @@ -0,0 +1,18 @@ +--- +- name: Bad indentation in mapping + from: '@perlpunk' + tags: error mapping indent double + fail: true + yaml: | + map: + key1: "quoted1" + key2: "bad indentation" + tree: | + +STR + +DOC + +MAP + =VAL :map + +MAP + =VAL :key1 + =VAL "quoted1 + -MAP diff --git a/src/N782.yaml b/src/N782.yaml new file mode 100644 index 0000000..e08267b --- /dev/null +++ b/src/N782.yaml @@ -0,0 +1,14 @@ +--- +- name: Invalid document markers in flow style + from: NimYAML tests + tags: flow edge header footer error + fail: true + yaml: | + [ + --- , + ... + ] + tree: | + +STR + +DOC + +SEQ [] diff --git a/src/NAT4.yaml b/src/NAT4.yaml new file mode 100644 index 0000000..379c940 --- /dev/null +++ b/src/NAT4.yaml @@ -0,0 +1,77 @@ +--- +- name: Various empty or newline only quoted strings + from: '@perlpunk' + tags: double scalar single whitespace + yaml: | + --- + a: ' + ' + b: '␣␣ + ' + c: " + " + d: "␣␣ + " + e: ' + + ' + f: " + + " + g: ' + + + ' + h: " + + + " + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL '␣ + =VAL :b + =VAL '␣ + =VAL :c + =VAL "␣ + =VAL :d + =VAL "␣ + =VAL :e + =VAL '\n + =VAL :f + =VAL "\n + =VAL :g + =VAL '\n\n + =VAL :h + =VAL "\n\n + -MAP + -DOC + -STR + json: | + { + "a": " ", + "b": " ", + "c": " ", + "d": " ", + "e": "\n", + "f": "\n", + "g": "\n\n", + "h": "\n\n" + } + emit: | + --- + a: ' ' + b: ' ' + c: " " + d: " " + e: ' + + ' + f: "\n" + g: ' + + + ' + h: "\n\n" diff --git a/src/NB6Z.yaml b/src/NB6Z.yaml new file mode 100644 index 0000000..0bc9f1e --- /dev/null +++ b/src/NB6Z.yaml @@ -0,0 +1,27 @@ +--- +- name: Multiline plain value with tabs on empty lines + from: '@perlpunk' + tags: scalar whitespace + yaml: | + key: + value + with + —» + tabs + tree: | + +STR + +DOC + +MAP + =VAL :key + =VAL :value with\ntabs + -MAP + -DOC + -STR + json: | + { + "key": "value with\ntabs" + } + dump: | + key: 'value with + + tabs' diff --git a/src/NHX8.yaml b/src/NHX8.yaml new file mode 100644 index 0000000..e8b9978 --- /dev/null +++ b/src/NHX8.yaml @@ -0,0 +1,19 @@ +--- +- name: Empty Lines at End of Document + from: NimYAML tests + tags: empty-key whitespace + yaml: | + : + ↵ + ↵ + tree: | + +STR + +DOC + +MAP + =VAL : + =VAL : + -MAP + -DOC + -STR + emit: | + : diff --git a/src/NJ66.yaml b/src/NJ66.yaml new file mode 100644 index 0000000..e7d98b3 --- /dev/null +++ b/src/NJ66.yaml @@ -0,0 +1,37 @@ +--- +- name: Multiline plain flow mapping key + from: '@perlpunk' + tags: flow mapping + yaml: | + --- + - { single line: value} + - { multi + line: value} + tree: | + +STR + +DOC --- + +SEQ + +MAP {} + =VAL :single line + =VAL :value + -MAP + +MAP {} + =VAL :multi line + =VAL :value + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "single line": "value" + }, + { + "multi line": "value" + } + ] + dump: | + --- + - single line: value + - multi line: value diff --git a/src/NKF9.yaml b/src/NKF9.yaml new file mode 100644 index 0000000..fede8e1 --- /dev/null +++ b/src/NKF9.yaml @@ -0,0 +1,60 @@ +--- +- name: Empty keys in block and flow mapping + from: '@perlpunk' + tags: empty-key mapping + yaml: | + --- + key: value + : empty key + --- + { + key: value, : empty key + } + --- + # empty key and value + : + --- + # empty key and value + { : } + tree: | + +STR + +DOC --- + +MAP + =VAL :key + =VAL :value + =VAL : + =VAL :empty key + -MAP + -DOC + +DOC --- + +MAP {} + =VAL :key + =VAL :value + =VAL : + =VAL :empty key + -MAP + -DOC + +DOC --- + +MAP + =VAL : + =VAL : + -MAP + -DOC + +DOC --- + +MAP {} + =VAL : + =VAL : + -MAP + -DOC + -STR + emit: | + --- + key: value + : empty key + --- + key: value + : empty key + --- + : + --- + : diff --git a/src/NP9H.yaml b/src/NP9H.yaml new file mode 100644 index 0000000..21d1354 --- /dev/null +++ b/src/NP9H.yaml @@ -0,0 +1,20 @@ +--- +- name: Spec Example 7.5. Double Quoted Line Breaks + from: http://www.yaml.org/spec/1.2/spec.html#id2787745 + tags: double spec scalar whitespace upto-1.2 + yaml: | + "folded␣ + to a space,» + ␣ + to a line feed, or »\ + \ »non-content" + tree: | + +STR + +DOC + =VAL "folded to a space,\nto a line feed, or \t \tnon-content + -DOC + -STR + json: | + "folded to a space,\nto a line feed, or \t \tnon-content" + dump: | + "folded to a space,\nto a line feed, or \t \tnon-content" diff --git a/src/P2AD.yaml b/src/P2AD.yaml new file mode 100644 index 0000000..0034d88 --- /dev/null +++ b/src/P2AD.yaml @@ -0,0 +1,42 @@ +--- +- name: Spec Example 8.1. Block Scalar Header + from: http://www.yaml.org/spec/1.2/spec.html#id2793888 + tags: spec literal folded comment scalar + yaml: | + - | # Empty header↓ + literal + - >1 # Indentation indicator↓ + folded + - |+ # Chomping indicator↓ + keep + + - >1- # Both indicators↓ + strip + tree: | + +STR + +DOC + +SEQ + =VAL |literal\n + =VAL > folded\n + =VAL |keep\n\n + =VAL > strip + -SEQ + -DOC + -STR + json: | + [ + "literal\n", + " folded\n", + "keep\n\n", + " strip" + ] + dump: | + - | + literal + - >2 + folded + - |+ + keep + + - >2- + strip diff --git a/src/P2EQ.yaml b/src/P2EQ.yaml new file mode 100644 index 0000000..26e8e66 --- /dev/null +++ b/src/P2EQ.yaml @@ -0,0 +1,16 @@ +--- +- name: Invalid sequene item on same line as previous item + from: '@perlpunk' + tags: error flow mapping sequence + fail: true + yaml: | + --- + - { y: z }- invalid + tree: | + +STR + +DOC --- + +SEQ + +MAP {} + =VAL :y + =VAL :z + -MAP diff --git a/src/P76L.yaml b/src/P76L.yaml new file mode 100644 index 0000000..2d36d3f --- /dev/null +++ b/src/P76L.yaml @@ -0,0 +1,18 @@ +--- +- name: Spec Example 6.19. Secondary Tag Handle + from: http://www.yaml.org/spec/1.2/spec.html#id2782940 + tags: spec header tag unknown-tag + yaml: | + %TAG !! tag:example.com,2000:app/ + --- + !!int 1 - 3 # Interval, not integer + tree: | + +STR + +DOC --- + =VAL :1 - 3 + -DOC + -STR + json: | + "1 - 3" + dump: | + --- ! 1 - 3 diff --git a/src/P94K.yaml b/src/P94K.yaml new file mode 100644 index 0000000..d7ba5d9 --- /dev/null +++ b/src/P94K.yaml @@ -0,0 +1,25 @@ +--- +- name: Spec Example 6.11. Multi-Line Comments + from: http://www.yaml.org/spec/1.2/spec.html#id2780696 + tags: spec comment + yaml: | + key: # Comment + # lines + value + ↵ + ↵ + tree: | + +STR + +DOC + +MAP + =VAL :key + =VAL :value + -MAP + -DOC + -STR + json: | + { + "key": "value" + } + dump: | + key: value diff --git a/src/PBJ2.yaml b/src/PBJ2.yaml new file mode 100644 index 0000000..41ece10 --- /dev/null +++ b/src/PBJ2.yaml @@ -0,0 +1,54 @@ +--- +- name: Spec Example 2.3. Mapping Scalars to Sequences + from: http://www.yaml.org/spec/1.2/spec.html#id2759963 + tags: spec mapping sequence + yaml: | + american: + - Boston Red Sox + - Detroit Tigers + - New York Yankees + national: + - New York Mets + - Chicago Cubs + - Atlanta Braves + tree: | + +STR + +DOC + +MAP + =VAL :american + +SEQ + =VAL :Boston Red Sox + =VAL :Detroit Tigers + =VAL :New York Yankees + -SEQ + =VAL :national + +SEQ + =VAL :New York Mets + =VAL :Chicago Cubs + =VAL :Atlanta Braves + -SEQ + -MAP + -DOC + -STR + json: | + { + "american": [ + "Boston Red Sox", + "Detroit Tigers", + "New York Yankees" + ], + "national": [ + "New York Mets", + "Chicago Cubs", + "Atlanta Braves" + ] + } + dump: | + american: + - Boston Red Sox + - Detroit Tigers + - New York Yankees + national: + - New York Mets + - Chicago Cubs + - Atlanta Braves diff --git a/src/PRH3.yaml b/src/PRH3.yaml new file mode 100644 index 0000000..5e6f914 --- /dev/null +++ b/src/PRH3.yaml @@ -0,0 +1,25 @@ +--- +- name: Spec Example 7.9. Single Quoted Lines + from: http://www.yaml.org/spec/1.2/spec.html#id2788756 + tags: single spec scalar whitespace upto-1.2 + yaml: | + ' 1st non-empty + + 2nd non-empty␣ + ———»3rd non-empty ' + tree: | + +STR + +DOC + =VAL ' 1st non-empty\n2nd non-empty 3rd non-empty␣ + -DOC + -STR + json: | + " 1st non-empty\n2nd non-empty 3rd non-empty " + dump: | + ' 1st non-empty + + 2nd non-empty 3rd non-empty ' + emit: | + ' 1st non-empty + + 2nd non-empty 3rd non-empty ' diff --git a/src/PUW8.yaml b/src/PUW8.yaml new file mode 100644 index 0000000..d327368 --- /dev/null +++ b/src/PUW8.yaml @@ -0,0 +1,30 @@ +--- +- name: Document start on last line + from: '@perlpunk' + tags: header + yaml: | + --- + a: b + --- + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL :b + -MAP + -DOC + +DOC --- + =VAL : + -DOC + -STR + json: | + { + "a": "b" + } + null + dump: | + --- + a: b + --- + ... diff --git a/src/PW8X.yaml b/src/PW8X.yaml new file mode 100644 index 0000000..0c4f7ff --- /dev/null +++ b/src/PW8X.yaml @@ -0,0 +1,52 @@ +--- +- name: Anchors on Empty Scalars + from: NimYAML tests + tags: anchor explicit-key + yaml: | + - &a + - a + - + &a : a + b: &b + - + &c : &a + - + ? &d + - + ? &e + : &a + tree: | + +STR + +DOC + +SEQ + =VAL &a : + =VAL :a + +MAP + =VAL &a : + =VAL :a + =VAL :b + =VAL &b : + -MAP + +MAP + =VAL &c : + =VAL &a : + -MAP + +MAP + =VAL &d : + =VAL : + -MAP + +MAP + =VAL &e : + =VAL &a : + -MAP + -SEQ + -DOC + -STR + dump: | + - &a + - a + - &a : a + b: &b + - &c : &a + - &d : + - &e : &a diff --git a/src/Q4CL.yaml b/src/Q4CL.yaml new file mode 100644 index 0000000..69eda79 --- /dev/null +++ b/src/Q4CL.yaml @@ -0,0 +1,17 @@ +--- +- name: Trailing content after quoted value + from: '@perlpunk' + tags: error mapping double + fail: true + yaml: | + key1: "quoted1" + key2: "quoted2" trailing content + key3: "quoted3" + tree: | + +STR + +DOC + +MAP + =VAL :key1 + =VAL "quoted1 + =VAL :key2 + =VAL "quoted2 diff --git a/src/Q5MG.yaml b/src/Q5MG.yaml new file mode 100644 index 0000000..5748250 --- /dev/null +++ b/src/Q5MG.yaml @@ -0,0 +1,17 @@ +--- +- name: Tab at beginning of line followed by a flow mapping + from: IRC + tags: flow whitespace + yaml: | + ———»{} + tree: | + +STR + +DOC + +MAP {} + -MAP + -DOC + -STR + json: | + {} + dump: | + {} diff --git a/src/Q88A.yaml b/src/Q88A.yaml new file mode 100644 index 0000000..acadda8 --- /dev/null +++ b/src/Q88A.yaml @@ -0,0 +1,48 @@ +--- +- name: Spec Example 7.23. Flow Content + from: http://www.yaml.org/spec/1.2/spec.html#id2793163 + tags: spec flow sequence mapping + yaml: | + - [ a, b ] + - { a: b } + - "a" + - 'b' + - c + tree: | + +STR + +DOC + +SEQ + +SEQ [] + =VAL :a + =VAL :b + -SEQ + +MAP {} + =VAL :a + =VAL :b + -MAP + =VAL "a + =VAL 'b + =VAL :c + -SEQ + -DOC + -STR + json: | + [ + [ + "a", + "b" + ], + { + "a": "b" + }, + "a", + "b", + "c" + ] + dump: | + - - a + - b + - a: b + - "a" + - 'b' + - c diff --git a/src/Q8AD.yaml b/src/Q8AD.yaml new file mode 100644 index 0000000..2d14859 --- /dev/null +++ b/src/Q8AD.yaml @@ -0,0 +1,23 @@ +--- +- name: Spec Example 7.5. Double Quoted Line Breaks [1.3] + from: NP9H, modified for YAML 1.3 + tags: double spec scalar whitespace 1.3-mod + yaml: | + --- + "folded␣ + to a space, + ␣ + to a line feed, or »\ + \ »non-content" + tree: | + +STR + +DOC --- + =VAL "folded to a space,\nto a line feed, or \t \tnon-content + -DOC + -STR + json: | + "folded to a space,\nto a line feed, or \t \tnon-content" + dump: | + "folded to a space,\nto a line feed, or \t \tnon-content" + emit: | + --- "folded to a space,\nto a line feed, or \t \tnon-content" diff --git a/src/Q9WF.yaml b/src/Q9WF.yaml new file mode 100644 index 0000000..d2d99f5 --- /dev/null +++ b/src/Q9WF.yaml @@ -0,0 +1,35 @@ +--- +- name: Spec Example 6.12. Separation Spaces + from: http://www.yaml.org/spec/1.2/spec.html#id2780989 + tags: complex-key flow spec comment whitespace 1.3-err + yaml: | + { first: Sammy, last: Sosa }: + # Statistics: + hr: # Home runs + 65 + avg: # Average + 0.278 + tree: | + +STR + +DOC + +MAP + +MAP {} + =VAL :first + =VAL :Sammy + =VAL :last + =VAL :Sosa + -MAP + +MAP + =VAL :hr + =VAL :65 + =VAL :avg + =VAL :0.278 + -MAP + -MAP + -DOC + -STR + dump: | + ? first: Sammy + last: Sosa + : hr: 65 + avg: 0.278 diff --git a/src/QB6E.yaml b/src/QB6E.yaml new file mode 100644 index 0000000..0f9efca --- /dev/null +++ b/src/QB6E.yaml @@ -0,0 +1,15 @@ +--- +- name: Wrong indented multiline quoted scalar + from: '@perlpunk' + tags: double error indent + fail: true + yaml: | + --- + quoted: "a + b + c" + tree: | + +STR + +DOC --- + +MAP + =VAL :quoted diff --git a/src/QF4Y.yaml b/src/QF4Y.yaml new file mode 100644 index 0000000..986849f --- /dev/null +++ b/src/QF4Y.yaml @@ -0,0 +1,27 @@ +--- +- name: Spec Example 7.19. Single Pair Flow Mappings + from: http://www.yaml.org/spec/1.2/spec.html#id2792291 + tags: spec flow mapping + yaml: | + [ + foo: bar + ] + tree: | + +STR + +DOC + +SEQ [] + +MAP {} + =VAL :foo + =VAL :bar + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "foo": "bar" + } + ] + dump: | + - foo: bar diff --git a/src/QLJ7.yaml b/src/QLJ7.yaml new file mode 100644 index 0000000..7f7c54d --- /dev/null +++ b/src/QLJ7.yaml @@ -0,0 +1,22 @@ +--- +- name: Tag shorthand used in documents but only defined in the first + from: IRC + tags: error directive tag + fail: true + yaml: | + %TAG !prefix! tag:example.com,2011: + --- !prefix!A + a: b + --- !prefix!B + c: d + --- !prefix!C + e: f + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL :b + -MAP + -DOC + +DOC --- diff --git a/src/QT73.yaml b/src/QT73.yaml new file mode 100644 index 0000000..79d925a --- /dev/null +++ b/src/QT73.yaml @@ -0,0 +1,12 @@ +--- +- name: Comment and document-end marker + from: '@perlpunk' + tags: comment footer + yaml: | + # comment + ... + tree: | + +STR + -STR + json: '' + dump: '' diff --git a/src/R4YG.yaml b/src/R4YG.yaml new file mode 100644 index 0000000..4e45cdb --- /dev/null +++ b/src/R4YG.yaml @@ -0,0 +1,44 @@ +--- +- name: Spec Example 8.2. Block Indentation Indicator + from: http://www.yaml.org/spec/1.2/spec.html#id2794311 + tags: spec literal folded scalar whitespace libyaml-err upto-1.2 + yaml: | + - | + detected + - > + ␣ + ␣␣ + # detected + - |1 + explicit + - > + ——» + detected + tree: | + +STR + +DOC + +SEQ + =VAL |detected\n + =VAL >\n\n# detected\n + =VAL | explicit\n + =VAL >\t\ndetected\n + -SEQ + -DOC + -STR + json: | + [ + "detected\n", + "\n\n# detected\n", + " explicit\n", + "\t\ndetected\n" + ] + dump: | + - | + detected + - >2 + + + # detected + - |2 + explicit + - "\t\ndetected\n" diff --git a/src/R52L.yaml b/src/R52L.yaml new file mode 100644 index 0000000..e0f5edd --- /dev/null +++ b/src/R52L.yaml @@ -0,0 +1,43 @@ +--- +- name: Nested flow mapping sequence and mappings + from: '@perlpunk' + tags: flow mapping sequence + yaml: | + --- + { top1: [item1, {key2: value2}, item3], top2: value2 } + tree: | + +STR + +DOC --- + +MAP {} + =VAL :top1 + +SEQ [] + =VAL :item1 + +MAP {} + =VAL :key2 + =VAL :value2 + -MAP + =VAL :item3 + -SEQ + =VAL :top2 + =VAL :value2 + -MAP + -DOC + -STR + json: | + { + "top1": [ + "item1", + { + "key2": "value2" + }, + "item3" + ], + "top2": "value2" + } + dump: | + --- + top1: + - item1 + - key2: value2 + - item3 + top2: value2 diff --git a/src/RHX7.yaml b/src/RHX7.yaml new file mode 100644 index 0000000..f80cd86 --- /dev/null +++ b/src/RHX7.yaml @@ -0,0 +1,16 @@ +--- +- name: YAML directive without document end marker + from: '@perlpunk' + tags: directive error + fail: true + yaml: | + --- + key: value + %YAML 1.2 + --- + tree: | + +STR + +DOC --- + +MAP + =VAL :key + =VAL :value diff --git a/src/RLU9.yaml b/src/RLU9.yaml new file mode 100644 index 0000000..579bb1d --- /dev/null +++ b/src/RLU9.yaml @@ -0,0 +1,38 @@ +--- +- name: Sequence Indent + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/indent.tml + tags: sequence indent + yaml: | + foo: + - 42 + bar: + - 44 + tree: | + +STR + +DOC + +MAP + =VAL :foo + +SEQ + =VAL :42 + -SEQ + =VAL :bar + +SEQ + =VAL :44 + -SEQ + -MAP + -DOC + -STR + json: | + { + "foo": [ + 42 + ], + "bar": [ + 44 + ] + } + dump: | + foo: + - 42 + bar: + - 44 diff --git a/src/RR7F.yaml b/src/RR7F.yaml new file mode 100644 index 0000000..c6690f8 --- /dev/null +++ b/src/RR7F.yaml @@ -0,0 +1,27 @@ +--- +- name: Mixed Block Mapping (implicit to explicit) + from: NimYAML tests + tags: explicit-key mapping + yaml: | + a: 4.2 + ? d + : 23 + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL :4.2 + =VAL :d + =VAL :23 + -MAP + -DOC + -STR + json: | + { + "d": 23, + "a": 4.2 + } + dump: | + a: 4.2 + d: 23 diff --git a/src/RTP8.yaml b/src/RTP8.yaml new file mode 100644 index 0000000..a2ebf2f --- /dev/null +++ b/src/RTP8.yaml @@ -0,0 +1,20 @@ +--- +- name: Spec Example 9.2. Document Markers + from: http://www.yaml.org/spec/1.2/spec.html#id2800866 + tags: spec header footer + yaml: | + %YAML 1.2 + --- + Document + ... # Suffix + tree: | + +STR + +DOC --- + =VAL :Document + -DOC ... + -STR + json: | + "Document" + dump: | + --- Document + ... diff --git a/src/RXY3.yaml b/src/RXY3.yaml new file mode 100644 index 0000000..e8ea24b --- /dev/null +++ b/src/RXY3.yaml @@ -0,0 +1,13 @@ +--- +- name: Invalid document-end marker in single quoted string + from: '@perlpunk' + tags: footer single error + fail: true + yaml: | + --- + ' + ... + ' + tree: | + +STR + +DOC --- diff --git a/src/RZP5.yaml b/src/RZP5.yaml new file mode 100644 index 0000000..e01e7e8 --- /dev/null +++ b/src/RZP5.yaml @@ -0,0 +1,58 @@ +--- +- name: Various Trailing Comments [1.3] + from: XW4D, modified for YAML 1.3 + tags: anchor comment folded mapping 1.3-mod + yaml: | + a: "double + quotes" # lala + b: plain + value # lala + c : #lala + d + ? # lala + - seq1 + : # lala + - #lala + seq2 + e: &node # lala + - x: y + block: > # lala + abcde + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL "double quotes + =VAL :b + =VAL :plain value + =VAL :c + =VAL :d + +SEQ + =VAL :seq1 + -SEQ + +SEQ + =VAL :seq2 + -SEQ + =VAL :e + +SEQ &node + +MAP + =VAL :x + =VAL :y + -MAP + -SEQ + =VAL :block + =VAL >abcde\n + -MAP + -DOC + -STR + dump: | + a: "double quotes" + b: plain value + c: d + ? - seq1 + : - seq2 + e: &node + - x: y + block: > + abcde diff --git a/src/RZT7.yaml b/src/RZT7.yaml new file mode 100644 index 0000000..9c84722 --- /dev/null +++ b/src/RZT7.yaml @@ -0,0 +1,133 @@ +--- +- name: Spec Example 2.28. Log File + from: http://www.yaml.org/spec/1.2/spec.html#id2761866 + tags: spec header literal mapping sequence + yaml: | + --- + Time: 2001-11-23 15:01:42 -5 + User: ed + Warning: + This is an error message + for the log file + --- + Time: 2001-11-23 15:02:31 -5 + User: ed + Warning: + A slightly different error + message. + --- + Date: 2001-11-23 15:03:17 -5 + User: ed + Fatal: + Unknown variable "bar" + Stack: + - file: TopClass.py + line: 23 + code: | + x = MoreObject("345\n") + - file: MoreClass.py + line: 58 + code: |- + foo = bar + tree: | + +STR + +DOC --- + +MAP + =VAL :Time + =VAL :2001-11-23 15:01:42 -5 + =VAL :User + =VAL :ed + =VAL :Warning + =VAL :This is an error message for the log file + -MAP + -DOC + +DOC --- + +MAP + =VAL :Time + =VAL :2001-11-23 15:02:31 -5 + =VAL :User + =VAL :ed + =VAL :Warning + =VAL :A slightly different error message. + -MAP + -DOC + +DOC --- + +MAP + =VAL :Date + =VAL :2001-11-23 15:03:17 -5 + =VAL :User + =VAL :ed + =VAL :Fatal + =VAL :Unknown variable "bar" + =VAL :Stack + +SEQ + +MAP + =VAL :file + =VAL :TopClass.py + =VAL :line + =VAL :23 + =VAL :code + =VAL |x = MoreObject("345\\n")\n + -MAP + +MAP + =VAL :file + =VAL :MoreClass.py + =VAL :line + =VAL :58 + =VAL :code + =VAL |foo = bar + -MAP + -SEQ + -MAP + -DOC + -STR + json: | + { + "Time": "2001-11-23 15:01:42 -5", + "User": "ed", + "Warning": "This is an error message for the log file" + } + { + "Time": "2001-11-23 15:02:31 -5", + "User": "ed", + "Warning": "A slightly different error message." + } + { + "Date": "2001-11-23 15:03:17 -5", + "User": "ed", + "Fatal": "Unknown variable \"bar\"", + "Stack": [ + { + "file": "TopClass.py", + "line": 23, + "code": "x = MoreObject(\"345\\n\")\n" + }, + { + "file": "MoreClass.py", + "line": 58, + "code": "foo = bar" + } + ] + } + dump: | + --- + Time: 2001-11-23 15:01:42 -5 + User: ed + Warning: This is an error message for the log file + --- + Time: 2001-11-23 15:02:31 -5 + User: ed + Warning: A slightly different error message. + --- + Date: 2001-11-23 15:03:17 -5 + User: ed + Fatal: Unknown variable "bar" + Stack: + - file: TopClass.py + line: 23 + code: | + x = MoreObject("345\n") + - file: MoreClass.py + line: 58 + code: |- + foo = bar diff --git a/src/S3PD.yaml b/src/S3PD.yaml new file mode 100644 index 0000000..a1c2da5 --- /dev/null +++ b/src/S3PD.yaml @@ -0,0 +1,29 @@ +--- +- name: Spec Example 8.18. Implicit Block Mapping Entries + from: http://www.yaml.org/spec/1.2/spec.html#id2798896 + tags: empty-key spec mapping + yaml: | + plain key: in-line value + : # Both empty + "quoted key": + - entry + tree: | + +STR + +DOC + +MAP + =VAL :plain key + =VAL :in-line value + =VAL : + =VAL : + =VAL "quoted key + +SEQ + =VAL :entry + -SEQ + -MAP + -DOC + -STR + emit: | + plain key: in-line value + : + "quoted key": + - entry diff --git a/src/S4GJ.yaml b/src/S4GJ.yaml new file mode 100644 index 0000000..beb8bff --- /dev/null +++ b/src/S4GJ.yaml @@ -0,0 +1,14 @@ +--- +- name: Invalid text after block scalar indicator + from: '@perlpunk' + tags: error folded + fail: true + yaml: | + --- + folded: > first line + second line + tree: | + +STR + +DOC --- + +MAP + =VAL :folded diff --git a/src/S4JQ.yaml b/src/S4JQ.yaml new file mode 100644 index 0000000..4160abd --- /dev/null +++ b/src/S4JQ.yaml @@ -0,0 +1,29 @@ +--- +- name: Spec Example 6.28. Non-Specific Tags + from: http://www.yaml.org/spec/1.2/spec.html#id2785512 + tags: spec tag + yaml: | + # Assuming conventional resolution: + - "12" + - 12 + - ! 12 + tree: | + +STR + +DOC + +SEQ + =VAL "12 + =VAL :12 + =VAL :12 + -SEQ + -DOC + -STR + json: | + [ + "12", + 12, + "12" + ] + dump: | + - "12" + - 12 + - ! 12 diff --git a/src/S4T7.yaml b/src/S4T7.yaml new file mode 100644 index 0000000..e09e55c --- /dev/null +++ b/src/S4T7.yaml @@ -0,0 +1,20 @@ +--- +- name: Document with footer + from: https://github.com/ingydotnet/yaml-pegex-pm/blob/master/test/footer.tml + tags: mapping footer + yaml: | + aaa: bbb + ... + tree: | + +STR + +DOC + +MAP + =VAL :aaa + =VAL :bbb + -MAP + -DOC ... + -STR + json: | + { + "aaa": "bbb" + } diff --git a/src/S7BG.yaml b/src/S7BG.yaml new file mode 100644 index 0000000..3b35338 --- /dev/null +++ b/src/S7BG.yaml @@ -0,0 +1,22 @@ +--- +- name: Colon followed by comma + from: '@perlpunk' + tags: scalar + yaml: | + --- + - :, + tree: | + +STR + +DOC --- + +SEQ + =VAL ::, + -SEQ + -DOC + -STR + json: | + [ + ":," + ] + dump: | + --- + - :, diff --git a/src/S98Z.yaml b/src/S98Z.yaml new file mode 100644 index 0000000..5ecb3bd --- /dev/null +++ b/src/S98Z.yaml @@ -0,0 +1,16 @@ +--- +- name: Block scalar with more spaces than first content line + from: '@perlpunk' + tags: error folded comment scalar whitespace + fail: true + yaml: | + empty block scalar: > + ␣ + ␣␣ + ␣␣␣ + # comment + tree: | + +STR + +DOC + +MAP + =VAL :empty block scalar diff --git a/src/S9E8.yaml b/src/S9E8.yaml new file mode 100644 index 0000000..57e59a9 --- /dev/null +++ b/src/S9E8.yaml @@ -0,0 +1,49 @@ +--- +- name: Spec Example 5.3. Block Structure Indicators + from: http://www.yaml.org/spec/1.2/spec.html#id2772312 + tags: explicit-key spec mapping sequence + yaml: | + sequence: + - one + - two + mapping: + ? sky + : blue + sea : green + tree: | + +STR + +DOC + +MAP + =VAL :sequence + +SEQ + =VAL :one + =VAL :two + -SEQ + =VAL :mapping + +MAP + =VAL :sky + =VAL :blue + =VAL :sea + =VAL :green + -MAP + -MAP + -DOC + -STR + json: | + { + "sequence": [ + "one", + "two" + ], + "mapping": { + "sky": "blue", + "sea": "green" + } + } + dump: | + sequence: + - one + - two + mapping: + sky: blue + sea: green diff --git a/src/SBG9.yaml b/src/SBG9.yaml new file mode 100644 index 0000000..4d0d595 --- /dev/null +++ b/src/SBG9.yaml @@ -0,0 +1,30 @@ +--- +- name: Flow Sequence in Flow Mapping + from: NimYAML tests + tags: complex-key sequence mapping flow + yaml: | + {a: [b, c], [d, e]: f} + tree: | + +STR + +DOC + +MAP {} + =VAL :a + +SEQ [] + =VAL :b + =VAL :c + -SEQ + +SEQ [] + =VAL :d + =VAL :e + -SEQ + =VAL :f + -MAP + -DOC + -STR + dump: | + a: + - b + - c + ? - d + - e + : f diff --git a/src/SF5V.yaml b/src/SF5V.yaml new file mode 100644 index 0000000..0dd71d6 --- /dev/null +++ b/src/SF5V.yaml @@ -0,0 +1,11 @@ +--- +- name: Duplicate YAML directive + from: '@perlpunk' + tags: directive error + fail: true + yaml: | + %YAML 1.2 + %YAML 1.2 + --- + tree: | + +STR diff --git a/src/SKE5.yaml b/src/SKE5.yaml new file mode 100644 index 0000000..f5014a5 --- /dev/null +++ b/src/SKE5.yaml @@ -0,0 +1,34 @@ +--- +- name: Anchor before zero indented sequence + from: '@perlpunk' + tags: anchor indent sequence + yaml: | + --- + seq: + &anchor + - a + - b + tree: | + +STR + +DOC --- + +MAP + =VAL :seq + +SEQ &anchor + =VAL :a + =VAL :b + -SEQ + -MAP + -DOC + -STR + json: | + { + "seq": [ + "a", + "b" + ] + } + dump: | + --- + seq: &anchor + - a + - b diff --git a/src/SM9W.yaml b/src/SM9W.yaml new file mode 100644 index 0000000..238712f --- /dev/null +++ b/src/SM9W.yaml @@ -0,0 +1,34 @@ +--- +- name: Single character streams + from: '@ingydotnet' + tags: sequence + yaml: | + -∎ + tree: | + +STR + +DOC + +SEQ + =VAL : + -SEQ + -DOC + -STR + json: | + [null] + dump: | + - + +- tags: mapping + yaml: | + :∎ + tree: | + +STR + +DOC + +MAP + =VAL : + =VAL : + -MAP + -DOC + -STR + json: null + dump: | + : diff --git a/src/SR86.yaml b/src/SR86.yaml new file mode 100644 index 0000000..a28bb3c --- /dev/null +++ b/src/SR86.yaml @@ -0,0 +1,15 @@ +--- +- name: Anchor plus Alias + from: '@perlpunk' + tags: alias error + fail: true + yaml: | + key1: &a value + key2: &b *a + tree: | + +STR + +DOC + +MAP + =VAL :key1 + =VAL &a :value + =VAL :key2 diff --git a/src/SSW6.yaml b/src/SSW6.yaml new file mode 100644 index 0000000..aaf31b0 --- /dev/null +++ b/src/SSW6.yaml @@ -0,0 +1,17 @@ +--- +- name: Spec Example 7.7. Single Quoted Characters [1.3] + from: 4GC6, modified for YAML 1.3 + tags: spec scalar single 1.3-mod + yaml: | + --- + 'here''s to "quotes"' + tree: | + +STR + +DOC --- + =VAL 'here's to "quotes" + -DOC + -STR + json: | + "here's to \"quotes\"" + dump: | + --- 'here''s to "quotes"' diff --git a/src/SU5Z.yaml b/src/SU5Z.yaml new file mode 100644 index 0000000..4b9c56d --- /dev/null +++ b/src/SU5Z.yaml @@ -0,0 +1,13 @@ +--- +- name: Comment without whitespace after doublequoted scalar + from: '@perlpunk' + tags: comment error double whitespace + fail: true + yaml: | + key: "value"# invalid comment + tree: | + +STR + +DOC + +MAP + =VAL :key + =VAL "value diff --git a/src/SU74.yaml b/src/SU74.yaml new file mode 100644 index 0000000..e402f1c --- /dev/null +++ b/src/SU74.yaml @@ -0,0 +1,14 @@ +--- +- name: Anchor and alias as mapping key + from: '@perlpunk' + tags: error anchor alias mapping + fail: true + yaml: | + key1: &alias value1 + &b *alias : value2 + tree: | + +STR + +DOC + +MAP + =VAL :key1 + =VAL &alias :value1 diff --git a/src/SY6V.yaml b/src/SY6V.yaml new file mode 100644 index 0000000..82986e5 --- /dev/null +++ b/src/SY6V.yaml @@ -0,0 +1,9 @@ +--- +- name: Anchor before sequence entry on same line + from: '@perlpunk' + tags: anchor error sequence + fail: true + yaml: | + &anchor - sequence entry + tree: | + +STR diff --git a/src/SYW4.yaml b/src/SYW4.yaml new file mode 100644 index 0000000..a5a61b1 --- /dev/null +++ b/src/SYW4.yaml @@ -0,0 +1,31 @@ +--- +- name: Spec Example 2.2. Mapping Scalars to Scalars + from: http://www.yaml.org/spec/1.2/spec.html#id2759963 + tags: spec scalar comment + yaml: | + hr: 65 # Home runs + avg: 0.278 # Batting average + rbi: 147 # Runs Batted In + tree: | + +STR + +DOC + +MAP + =VAL :hr + =VAL :65 + =VAL :avg + =VAL :0.278 + =VAL :rbi + =VAL :147 + -MAP + -DOC + -STR + json: | + { + "hr": 65, + "avg": 0.278, + "rbi": 147 + } + dump: | + hr: 65 + avg: 0.278 + rbi: 147 diff --git a/src/T26H.yaml b/src/T26H.yaml new file mode 100644 index 0000000..843b3be --- /dev/null +++ b/src/T26H.yaml @@ -0,0 +1,32 @@ +--- +- name: Spec Example 8.8. Literal Content [1.3] + from: DWX9, modified for YAML 1.3 + tags: spec literal scalar comment whitespace 1.3-mod + yaml: | + --- | + ␣ + ␣␣ + literal + ␣␣␣ + ␣␣ + text + + # Comment + tree: | + +STR + +DOC --- + =VAL |\n\nliteral\n \n\ntext\n + -DOC + -STR + json: | + "\n\nliteral\n \n\ntext\n" + dump: | + "\n\nliteral\n \n\ntext\n" + emit: | + --- | + + + literal + ␣␣␣ + + text diff --git a/src/T4YY.yaml b/src/T4YY.yaml new file mode 100644 index 0000000..bf230f6 --- /dev/null +++ b/src/T4YY.yaml @@ -0,0 +1,26 @@ +--- +- name: Spec Example 7.9. Single Quoted Lines [1.3] + from: PRH3, modified for YAML 1.3 + tags: single spec scalar whitespace 1.3-mod + yaml: | + --- + ' 1st non-empty + + 2nd non-empty␣ + 3rd non-empty ' + tree: | + +STR + +DOC --- + =VAL ' 1st non-empty\n2nd non-empty 3rd non-empty␣ + -DOC + -STR + json: | + " 1st non-empty\n2nd non-empty 3rd non-empty " + dump: | + ' 1st non-empty + + 2nd non-empty 3rd non-empty ' + emit: | + --- ' 1st non-empty + + 2nd non-empty 3rd non-empty ' diff --git a/src/T5N4.yaml b/src/T5N4.yaml new file mode 100644 index 0000000..c7b5059 --- /dev/null +++ b/src/T5N4.yaml @@ -0,0 +1,24 @@ +--- +- name: Spec Example 8.7. Literal Scalar [1.3] + from: M9B4, modified for YAML 1.3 + tags: spec literal scalar whitespace 1.3-mod + yaml: | + --- | + literal + ——»text + ↵ + ↵ + tree: | + +STR + +DOC --- + =VAL |literal\n\ttext\n + -DOC + -STR + json: | + "literal\n\ttext\n" + dump: | + "literal\n\ttext\n" + emit: | + --- | + literal + —»text diff --git a/src/T833.yaml b/src/T833.yaml new file mode 100644 index 0000000..5d6638b --- /dev/null +++ b/src/T833.yaml @@ -0,0 +1,15 @@ +--- +- name: Flow mapping missing a separating comma + from: '@perlpunk' + tags: error flow mapping + fail: true + yaml: | + --- + { + foo: 1 + bar: 2 } + tree: | + +STR + +DOC --- + +MAP + =VAL :foo diff --git a/src/TD5N.yaml b/src/TD5N.yaml new file mode 100644 index 0000000..2391b17 --- /dev/null +++ b/src/TD5N.yaml @@ -0,0 +1,15 @@ +--- +- name: Invalid scalar after sequence + from: '@perlpunk' + tags: error sequence scalar + fail: true + yaml: | + - item1 + - item2 + invalid + tree: | + +STR + +DOC + +SEQ + =VAL :item1 + =VAL :item2 diff --git a/src/TE2A.yaml b/src/TE2A.yaml new file mode 100644 index 0000000..34968f3 --- /dev/null +++ b/src/TE2A.yaml @@ -0,0 +1,28 @@ +--- +- name: Spec Example 8.16. Block Mappings + from: http://www.yaml.org/spec/1.2/spec.html#id2798147 + tags: spec mapping + yaml: | + block mapping: + key: value + tree: | + +STR + +DOC + +MAP + =VAL :block mapping + +MAP + =VAL :key + =VAL :value + -MAP + -MAP + -DOC + -STR + json: | + { + "block mapping": { + "key": "value" + } + } + dump: | + block mapping: + key: value diff --git a/src/TL85.yaml b/src/TL85.yaml new file mode 100644 index 0000000..a091d1d --- /dev/null +++ b/src/TL85.yaml @@ -0,0 +1,22 @@ +--- +- name: Spec Example 6.8. Flow Folding + from: http://www.yaml.org/spec/1.2/spec.html#id2779950 + tags: double spec whitespace scalar upto-1.2 + yaml: | + " + foo␣ + ␣ + —» bar + + baz + " + tree: | + +STR + +DOC + =VAL " foo\nbar\nbaz␣ + -DOC + -STR + json: | + " foo\nbar\nbaz " + dump: | + " foo\nbar\nbaz " diff --git a/src/TS54.yaml b/src/TS54.yaml new file mode 100644 index 0000000..d1e9928 --- /dev/null +++ b/src/TS54.yaml @@ -0,0 +1,29 @@ +--- +- name: Folded Block Scalar + from: NimYAML tests + tags: folded scalar 1.3-err + yaml: | + > + ab + cd + ␣ + ef + + + gh + tree: | + +STR + +DOC + =VAL >ab cd\nef\n\ngh\n + -DOC + -STR + json: | + "ab cd\nef\n\ngh\n" + dump: | + > + ab cd + + ef + + + gh diff --git a/src/U3C3.yaml b/src/U3C3.yaml new file mode 100644 index 0000000..16988bf --- /dev/null +++ b/src/U3C3.yaml @@ -0,0 +1,18 @@ +--- +- name: Spec Example 6.16. “TAG” directive + from: http://www.yaml.org/spec/1.2/spec.html#id2782252 + tags: spec header tag + yaml: | + %TAG !yaml! tag:yaml.org,2002: + --- + !yaml!str "foo" + tree: | + +STR + +DOC --- + =VAL "foo + -DOC + -STR + json: | + "foo" + dump: | + --- !!str "foo" diff --git a/src/U3XV.yaml b/src/U3XV.yaml new file mode 100644 index 0000000..761e8b4 --- /dev/null +++ b/src/U3XV.yaml @@ -0,0 +1,92 @@ +--- +- name: Node and Mapping Key Anchors + from: '@perlpunk' + tags: anchor comment 1.3-err + yaml: | + --- + top1: &node1 + &k1 key1: one + top2: &node2 # comment + key2: two + top3: + &k3 key3: three + top4: + &node4 + &k4 key4: four + top5: + &node5 + key5: five + top6: &val6 + six + top7: + &val7 seven + tree: | + +STR + +DOC --- + +MAP + =VAL :top1 + +MAP &node1 + =VAL &k1 :key1 + =VAL :one + -MAP + =VAL :top2 + +MAP &node2 + =VAL :key2 + =VAL :two + -MAP + =VAL :top3 + +MAP + =VAL &k3 :key3 + =VAL :three + -MAP + =VAL :top4 + +MAP &node4 + =VAL &k4 :key4 + =VAL :four + -MAP + =VAL :top5 + +MAP &node5 + =VAL :key5 + =VAL :five + -MAP + =VAL :top6 + =VAL &val6 :six + =VAL :top7 + =VAL &val7 :seven + -MAP + -DOC + -STR + json: | + { + "top1": { + "key1": "one" + }, + "top2": { + "key2": "two" + }, + "top3": { + "key3": "three" + }, + "top4": { + "key4": "four" + }, + "top5": { + "key5": "five" + }, + "top6": "six", + "top7": "seven" + } + dump: | + --- + top1: &node1 + &k1 key1: one + top2: &node2 + key2: two + top3: + &k3 key3: three + top4: &node4 + &k4 key4: four + top5: &node5 + key5: five + top6: &val6 six + top7: &val7 seven diff --git a/src/U44R.yaml b/src/U44R.yaml new file mode 100644 index 0000000..0347d3b --- /dev/null +++ b/src/U44R.yaml @@ -0,0 +1,17 @@ +--- +- name: Bad indentation in mapping (2) + from: '@perlpunk' + tags: error mapping indent double + fail: true + yaml: | + map: + key1: "quoted1" + key2: "bad indentation" + tree: | + +STR + +DOC + +MAP + =VAL :map + +MAP + =VAL :key1 + =VAL "quoted1 diff --git a/src/U99R.yaml b/src/U99R.yaml new file mode 100644 index 0000000..2de0c92 --- /dev/null +++ b/src/U99R.yaml @@ -0,0 +1,11 @@ +--- +- name: Invalid comma in tag + from: '@perlpunk' + tags: error tag + fail: true + yaml: | + - !!str, xxx + tree: | + +STR + +DOC + +SEQ diff --git a/src/U9NS.yaml b/src/U9NS.yaml new file mode 100644 index 0000000..c8ed11a --- /dev/null +++ b/src/U9NS.yaml @@ -0,0 +1,49 @@ +--- +- name: Spec Example 2.8. Play by Play Feed from a Game + from: http://www.yaml.org/spec/1.2/spec.html#id2760519 + tags: spec header + yaml: | + --- + time: 20:03:20 + player: Sammy Sosa + action: strike (miss) + ... + --- + time: 20:03:47 + player: Sammy Sosa + action: grand slam + ... + tree: | + +STR + +DOC --- + +MAP + =VAL :time + =VAL :20:03:20 + =VAL :player + =VAL :Sammy Sosa + =VAL :action + =VAL :strike (miss) + -MAP + -DOC ... + +DOC --- + +MAP + =VAL :time + =VAL :20:03:47 + =VAL :player + =VAL :Sammy Sosa + =VAL :action + =VAL :grand slam + -MAP + -DOC ... + -STR + json: | + { + "time": "20:03:20", + "player": "Sammy Sosa", + "action": "strike (miss)" + } + { + "time": "20:03:47", + "player": "Sammy Sosa", + "action": "grand slam" + } diff --git a/src/UDM2.yaml b/src/UDM2.yaml new file mode 100644 index 0000000..a07694a --- /dev/null +++ b/src/UDM2.yaml @@ -0,0 +1,25 @@ +--- +- name: Plain URL in flow mapping + from: https://github.com/yaml/libyaml/pull/28 + tags: flow scalar + yaml: | + - { url: http://example.org } + tree: | + +STR + +DOC + +SEQ + +MAP {} + =VAL :url + =VAL :http://example.org + -MAP + -SEQ + -DOC + -STR + json: | + [ + { + "url": "http://example.org" + } + ] + dump: | + - url: http://example.org diff --git a/src/UDR7.yaml b/src/UDR7.yaml new file mode 100644 index 0000000..e070842 --- /dev/null +++ b/src/UDR7.yaml @@ -0,0 +1,44 @@ +--- +- name: Spec Example 5.4. Flow Collection Indicators + from: http://www.yaml.org/spec/1.2/spec.html#id2772813 + tags: spec flow sequence mapping + yaml: | + sequence: [ one, two, ] + mapping: { sky: blue, sea: green } + tree: | + +STR + +DOC + +MAP + =VAL :sequence + +SEQ [] + =VAL :one + =VAL :two + -SEQ + =VAL :mapping + +MAP {} + =VAL :sky + =VAL :blue + =VAL :sea + =VAL :green + -MAP + -MAP + -DOC + -STR + json: | + { + "sequence": [ + "one", + "two" + ], + "mapping": { + "sky": "blue", + "sea": "green" + } + } + dump: | + sequence: + - one + - two + mapping: + sky: blue + sea: green diff --git a/src/UGM3.yaml b/src/UGM3.yaml new file mode 100644 index 0000000..cf46bf2 --- /dev/null +++ b/src/UGM3.yaml @@ -0,0 +1,163 @@ +--- +- name: Spec Example 2.27. Invoice + from: http://www.yaml.org/spec/1.2/spec.html#id2761823 + tags: spec tag literal mapping sequence alias unknown-tag + yaml: | + --- ! + invoice: 34843 + date : 2001-01-23 + bill-to: &id001 + given : Chris + family : Dumars + address: + lines: | + 458 Walkman Dr. + Suite #292 + city : Royal Oak + state : MI + postal : 48046 + ship-to: *id001 + product: + - sku : BL394D + quantity : 4 + description : Basketball + price : 450.00 + - sku : BL4438H + quantity : 1 + description : Super Hoop + price : 2392.00 + tax : 251.42 + total: 4443.52 + comments: + Late afternoon is best. + Backup contact is Nancy + Billsmer @ 338-4338. + tree: | + +STR + +DOC --- + +MAP + =VAL :invoice + =VAL :34843 + =VAL :date + =VAL :2001-01-23 + =VAL :bill-to + +MAP &id001 + =VAL :given + =VAL :Chris + =VAL :family + =VAL :Dumars + =VAL :address + +MAP + =VAL :lines + =VAL |458 Walkman Dr.\nSuite #292\n + =VAL :city + =VAL :Royal Oak + =VAL :state + =VAL :MI + =VAL :postal + =VAL :48046 + -MAP + -MAP + =VAL :ship-to + =ALI *id001 + =VAL :product + +SEQ + +MAP + =VAL :sku + =VAL :BL394D + =VAL :quantity + =VAL :4 + =VAL :description + =VAL :Basketball + =VAL :price + =VAL :450.00 + -MAP + +MAP + =VAL :sku + =VAL :BL4438H + =VAL :quantity + =VAL :1 + =VAL :description + =VAL :Super Hoop + =VAL :price + =VAL :2392.00 + -MAP + -SEQ + =VAL :tax + =VAL :251.42 + =VAL :total + =VAL :4443.52 + =VAL :comments + =VAL :Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338. + -MAP + -DOC + -STR + json: | + { + "invoice": 34843, + "date": "2001-01-23", + "bill-to": { + "given": "Chris", + "family": "Dumars", + "address": { + "lines": "458 Walkman Dr.\nSuite #292\n", + "city": "Royal Oak", + "state": "MI", + "postal": 48046 + } + }, + "ship-to": { + "given": "Chris", + "family": "Dumars", + "address": { + "lines": "458 Walkman Dr.\nSuite #292\n", + "city": "Royal Oak", + "state": "MI", + "postal": 48046 + } + }, + "product": [ + { + "sku": "BL394D", + "quantity": 4, + "description": "Basketball", + "price": 450 + }, + { + "sku": "BL4438H", + "quantity": 1, + "description": "Super Hoop", + "price": 2392 + } + ], + "tax": 251.42, + "total": 4443.52, + "comments": "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338." + } + dump: | + --- ! + invoice: 34843 + date: 2001-01-23 + bill-to: &id001 + given: Chris + family: Dumars + address: + lines: | + 458 Walkman Dr. + Suite #292 + city: Royal Oak + state: MI + postal: 48046 + ship-to: *id001 + product: + - sku: BL394D + quantity: 4 + description: Basketball + price: 450.00 + - sku: BL4438H + quantity: 1 + description: Super Hoop + price: 2392.00 + tax: 251.42 + total: 4443.52 + comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338. diff --git a/src/UKK6.yaml b/src/UKK6.yaml new file mode 100644 index 0000000..2648ef1 --- /dev/null +++ b/src/UKK6.yaml @@ -0,0 +1,43 @@ +--- +- name: Syntax character edge cases + from: '@ingydotnet' + tags: edge empty-key + yaml: | + - : + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL : + =VAL : + -MAP + -SEQ + -DOC + -STR + +- yaml: | + :: + tree: | + +STR + +DOC + +MAP + =VAL :: + =VAL : + -MAP + -DOC + -STR + json: | + { + ":": null + } + +- yaml: | + ! + tree: | + +STR + +DOC + =VAL : + -DOC + -STR + json: null diff --git a/src/UT92.yaml b/src/UT92.yaml new file mode 100644 index 0000000..4652fb0 --- /dev/null +++ b/src/UT92.yaml @@ -0,0 +1,35 @@ +--- +- name: Spec Example 9.4. Explicit Documents + from: http://www.yaml.org/spec/1.2/spec.html#id2801448 + tags: flow spec header footer comment + yaml: | + --- + { matches + % : 20 } + ... + --- + # Empty + ... + tree: | + +STR + +DOC --- + +MAP {} + =VAL :matches % + =VAL :20 + -MAP + -DOC ... + +DOC --- + =VAL : + -DOC ... + -STR + json: | + { + "matches %": 20 + } + null + dump: | + --- + matches %: 20 + ... + --- + ... diff --git a/src/UV7Q.yaml b/src/UV7Q.yaml new file mode 100644 index 0000000..0caf960 --- /dev/null +++ b/src/UV7Q.yaml @@ -0,0 +1,28 @@ +--- +- name: Legal tab after indentation + from: '@ingydotnet' + tags: indent whitespace + yaml: | + x: + - x + ——»x + tree: | + +STR + +DOC + +MAP + =VAL :x + +SEQ + =VAL :x x + -SEQ + -MAP + -DOC + -STR + json: | + { + "x": [ + "x x" + ] + } + dump: | + x: + - x x diff --git a/src/V55R.yaml b/src/V55R.yaml new file mode 100644 index 0000000..1335d60 --- /dev/null +++ b/src/V55R.yaml @@ -0,0 +1,27 @@ +--- +- name: Aliases in Block Sequence + from: NimYAML tests + tags: alias sequence + yaml: | + - &a a + - &b b + - *a + - *b + tree: | + +STR + +DOC + +SEQ + =VAL &a :a + =VAL &b :b + =ALI *a + =ALI *b + -SEQ + -DOC + -STR + json: | + [ + "a", + "b", + "a", + "b" + ] diff --git a/src/V9D5.yaml b/src/V9D5.yaml new file mode 100644 index 0000000..a06fdc4 --- /dev/null +++ b/src/V9D5.yaml @@ -0,0 +1,29 @@ +--- +- name: Spec Example 8.19. Compact Block Mappings + from: http://www.yaml.org/spec/1.2/spec.html#id2799091 + tags: complex-key explicit-key spec mapping + yaml: | + - sun: yellow + - ? earth: blue + : moon: white + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL :sun + =VAL :yellow + -MAP + +MAP + +MAP + =VAL :earth + =VAL :blue + -MAP + +MAP + =VAL :moon + =VAL :white + -MAP + -MAP + -SEQ + -DOC + -STR diff --git a/src/VJP3.yaml b/src/VJP3.yaml new file mode 100644 index 0000000..76a5c68 --- /dev/null +++ b/src/VJP3.yaml @@ -0,0 +1,49 @@ +--- +- name: Flow collections over many lines + from: '@ingydotnet' + tags: flow indent + fail: true + yaml: | + k: { + k + : + v + } + tree: | + +STR + +DOC + +MAP + =VAL :k + +MAP {} + +- yaml: | + k: { + k + : + v + } + tree: | + +STR + +DOC + +MAP + =VAL :k + +MAP {} + =VAL :k + =VAL :v + -MAP + -MAP + -DOC + -STR + json: | + { + "k" : { + "k" : "v" + } + } + dump: | + --- + k: + k: v + emit: | + k: + k: v diff --git a/src/W42U.yaml b/src/W42U.yaml new file mode 100644 index 0000000..2c52f96 --- /dev/null +++ b/src/W42U.yaml @@ -0,0 +1,47 @@ +--- +- name: Spec Example 8.15. Block Sequence Entry Types + from: http://www.yaml.org/spec/1.2/spec.html#id2797944 + tags: comment spec literal sequence + yaml: | + - # Empty + - | + block node + - - one # Compact + - two # sequence + - one: two # Compact mapping + tree: | + +STR + +DOC + +SEQ + =VAL : + =VAL |block node\n + +SEQ + =VAL :one + =VAL :two + -SEQ + +MAP + =VAL :one + =VAL :two + -MAP + -SEQ + -DOC + -STR + json: | + [ + null, + "block node\n", + [ + "one", + "two" + ], + { + "one": "two" + } + ] + dump: | + - + - | + block node + - - one + - two + - one: two diff --git a/src/W4TN.yaml b/src/W4TN.yaml new file mode 100644 index 0000000..ca41ac7 --- /dev/null +++ b/src/W4TN.yaml @@ -0,0 +1,31 @@ +--- +- name: Spec Example 9.5. Directives Documents + from: http://www.yaml.org/spec/1.2/spec.html#id2801606 + tags: spec header footer 1.3-err + yaml: | + %YAML 1.2 + --- | + %!PS-Adobe-2.0 + ... + %YAML 1.2 + --- + # Empty + ... + tree: | + +STR + +DOC --- + =VAL |%!PS-Adobe-2.0\n + -DOC ... + +DOC --- + =VAL : + -DOC ... + -STR + json: | + "%!PS-Adobe-2.0\n" + null + dump: | + --- | + %!PS-Adobe-2.0 + ... + --- + ... diff --git a/src/W5VH.yaml b/src/W5VH.yaml new file mode 100644 index 0000000..bcf069e --- /dev/null +++ b/src/W5VH.yaml @@ -0,0 +1,23 @@ +--- +- name: Allowed characters in alias + from: '@perlpunk' + tags: alias 1.3-err + yaml: | + a: &:@*!$": scalar a + b: *:@*!$": + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL &:@*!$": :scalar a + =VAL :b + =ALI *:@*!$": + -MAP + -DOC + -STR + json: | + { + "a": "scalar a", + "b": "scalar a" + } diff --git a/src/W9L4.yaml b/src/W9L4.yaml new file mode 100644 index 0000000..016f15b --- /dev/null +++ b/src/W9L4.yaml @@ -0,0 +1,16 @@ +--- +- name: Literal block scalar with more spaces in first line + from: '@perlpunk' + tags: error literal whitespace + fail: true + yaml: | + --- + block scalar: | + ␣␣␣␣␣ + more spaces at the beginning + are invalid + tree: | + +STR + +DOC --- + +MAP + =VAL :block scalar diff --git a/src/WZ62.yaml b/src/WZ62.yaml new file mode 100644 index 0000000..0af62ad --- /dev/null +++ b/src/WZ62.yaml @@ -0,0 +1,28 @@ +--- +- name: Spec Example 7.2. Empty Content + from: http://www.yaml.org/spec/1.2/spec.html#id2786720 + tags: spec flow scalar tag + yaml: | + { + foo : !!str, + !!str : bar, + } + tree: | + +STR + +DOC + +MAP {} + =VAL :foo + =VAL : + =VAL : + =VAL :bar + -MAP + -DOC + -STR + json: | + { + "foo": "", + "": "bar" + } + dump: | + foo: !!str + !!str : bar diff --git a/src/X38W.yaml b/src/X38W.yaml new file mode 100644 index 0000000..c5b1910 --- /dev/null +++ b/src/X38W.yaml @@ -0,0 +1,33 @@ +--- +- name: Aliases in Flow Objects + from: NimYAML tests + tags: alias complex-key flow + yaml: | + { &a [a, &b b]: *b, *a : [c, *b, d]} + tree: | + +STR + +DOC + +MAP {} + +SEQ [] &a + =VAL :a + =VAL &b :b + -SEQ + =ALI *b + =ALI *a + +SEQ [] + =VAL :c + =ALI *b + =VAL :d + -SEQ + -MAP + -DOC + -STR + dump: | + ? &a + - a + - &b b + : *b + *a : + - c + - *b + - d diff --git a/src/X4QW.yaml b/src/X4QW.yaml new file mode 100644 index 0000000..69651b8 --- /dev/null +++ b/src/X4QW.yaml @@ -0,0 +1,13 @@ +--- +- name: Comment without whitespace after block scalar indicator + from: '@perlpunk' + tags: folded comment error whitespace + fail: true + yaml: | + block: ># comment + scalar + tree: | + +STR + +DOC + +MAP + =VAL :block diff --git a/src/X8DW.yaml b/src/X8DW.yaml new file mode 100644 index 0000000..56f36d0 --- /dev/null +++ b/src/X8DW.yaml @@ -0,0 +1,25 @@ +--- +- name: Explicit key and value seperated by comment + from: '@perlpunk' + tags: comment explicit-key mapping + yaml: | + --- + ? key + # comment + : value + tree: | + +STR + +DOC --- + +MAP + =VAL :key + =VAL :value + -MAP + -DOC + -STR + json: | + { + "key": "value" + } + dump: | + --- + key: value diff --git a/src/XLQ9.yaml b/src/XLQ9.yaml new file mode 100644 index 0000000..d894fe8 --- /dev/null +++ b/src/XLQ9.yaml @@ -0,0 +1,19 @@ +--- +- name: Multiline scalar that looks like a YAML directive + from: '@perlpunk' + tags: directive scalar + yaml: | + --- + scalar + %YAML 1.2 + tree: | + +STR + +DOC --- + =VAL :scalar %YAML 1.2 + -DOC + -STR + json: | + "scalar %YAML 1.2" + dump: | + --- scalar %YAML 1.2 + ... diff --git a/src/XV9V.yaml b/src/XV9V.yaml new file mode 100644 index 0000000..57b18fb --- /dev/null +++ b/src/XV9V.yaml @@ -0,0 +1,33 @@ +--- +- name: Spec Example 6.5. Empty Lines [1.3] + from: 5GBF, modified for YAML 1.3 + tags: literal spec scalar 1.3-mod + yaml: | + Folding: + "Empty line + + as a line feed" + Chomping: | + Clipped empty lines + ␣ + ↵ + tree: | + +STR + +DOC + +MAP + =VAL :Folding + =VAL "Empty line\nas a line feed + =VAL :Chomping + =VAL |Clipped empty lines\n + -MAP + -DOC + -STR + json: | + { + "Folding": "Empty line\nas a line feed", + "Chomping": "Clipped empty lines\n" + } + dump: | + Folding: "Empty line\nas a line feed" + Chomping: | + Clipped empty lines diff --git a/src/XW4D.yaml b/src/XW4D.yaml new file mode 100644 index 0000000..2acbdb0 --- /dev/null +++ b/src/XW4D.yaml @@ -0,0 +1,59 @@ +--- +- name: Various Trailing Comments + from: '@perlpunk' + tags: comment explicit-key folded 1.3-err + yaml: | + a: "double + quotes" # lala + b: plain + value # lala + c : #lala + d + ? # lala + - seq1 + : # lala + - #lala + seq2 + e: + &node # lala + - x: y + block: > # lala + abcde + tree: | + +STR + +DOC + +MAP + =VAL :a + =VAL "double quotes + =VAL :b + =VAL :plain value + =VAL :c + =VAL :d + +SEQ + =VAL :seq1 + -SEQ + +SEQ + =VAL :seq2 + -SEQ + =VAL :e + +SEQ &node + +MAP + =VAL :x + =VAL :y + -MAP + -SEQ + =VAL :block + =VAL >abcde\n + -MAP + -DOC + -STR + dump: | + a: "double quotes" + b: plain value + c: d + ? - seq1 + : - seq2 + e: &node + - x: y + block: > + abcde diff --git a/src/Y2GN.yaml b/src/Y2GN.yaml new file mode 100644 index 0000000..103d793 --- /dev/null +++ b/src/Y2GN.yaml @@ -0,0 +1,23 @@ +--- +- name: Anchor with colon in the middle + from: '@perlpunk' + tags: anchor + yaml: | + --- + key: &an:chor value + tree: | + +STR + +DOC --- + +MAP + =VAL :key + =VAL &an:chor :value + -MAP + -DOC + -STR + json: | + { + "key": "value" + } + dump: | + --- + key: &an:chor value diff --git a/src/Y79Y.yaml b/src/Y79Y.yaml new file mode 100644 index 0000000..7bd9a16 --- /dev/null +++ b/src/Y79Y.yaml @@ -0,0 +1,119 @@ +--- +- name: Tabs in various contexts + from: '@ingydotnet' + tags: whitespace + fail: true + yaml: | + foo: | + ————» + bar: 1 + tree: | + +STR + +DOC + +MAP + =VAL :foo + +- yaml: | + foo: | + ———» + bar: 1 + tree: | + +STR + +DOC + +MAP + =VAL :foo + =VAL |\t\n + =VAL :bar + =VAL :1 + -MAP + -DOC + -STR + json: | + { + "foo": "\t\n", + "bar": 1 + } + dump: | + foo: | + ———» + bar: 1 + +- yaml: | + - [ + ————» + foo + ] + tree: | + +STR + +DOC + +SEQ + +SEQ [] + =VAL :foo + -SEQ + -SEQ + -DOC + -STR + json: | + [ + [ + "foo" + ] + ] + dump: | + - - foo + +- fail: true + yaml: | + - [ + ————»foo, + foo + ] + tree: | + +STR + +DOC + +SEQ + +SEQ [] + json: null + +- fail: true + yaml: | + -———»- + +- fail: true + yaml: | + - ——»- + +- fail: true + yaml: | + ?———»- + +- fail: true + yaml: | + ? - + :———»- + +- fail: true + yaml: | + ?———»key: + +- fail: true + yaml: | + ? key: + :———»key: + +- yaml: | + -———»-1 + tree: | + +STR + +DOC + +SEQ + =VAL :-1 + -SEQ + -DOC + -STR + json: | + [ + -1 + ] + dump: | + - -1 diff --git a/src/YD5X.yaml b/src/YD5X.yaml new file mode 100644 index 0000000..5dee2f0 --- /dev/null +++ b/src/YD5X.yaml @@ -0,0 +1,58 @@ +--- +- name: Spec Example 2.5. Sequence of Sequences + from: http://www.yaml.org/spec/1.2/spec.html#id2760351 + tags: spec sequence + yaml: | + - [name , hr, avg ] + - [Mark McGwire, 65, 0.278] + - [Sammy Sosa , 63, 0.288] + tree: | + +STR + +DOC + +SEQ + +SEQ [] + =VAL :name + =VAL :hr + =VAL :avg + -SEQ + +SEQ [] + =VAL :Mark McGwire + =VAL :65 + =VAL :0.278 + -SEQ + +SEQ [] + =VAL :Sammy Sosa + =VAL :63 + =VAL :0.288 + -SEQ + -SEQ + -DOC + -STR + json: | + [ + [ + "name", + "hr", + "avg" + ], + [ + "Mark McGwire", + 65, + 0.278 + ], + [ + "Sammy Sosa", + 63, + 0.288 + ] + ] + dump: | + - - name + - hr + - avg + - - Mark McGwire + - 65 + - 0.278 + - - Sammy Sosa + - 63 + - 0.288 diff --git a/src/YJV2.yaml b/src/YJV2.yaml new file mode 100644 index 0000000..80a6c19 --- /dev/null +++ b/src/YJV2.yaml @@ -0,0 +1,11 @@ +--- +- name: Dash in flow sequence + from: '@ingydotnet' + tags: flow sequence + fail: true + yaml: | + [-] + tree: | + +STR + +DOC + +SEQ [] diff --git a/src/Z67P.yaml b/src/Z67P.yaml new file mode 100644 index 0000000..7816433 --- /dev/null +++ b/src/Z67P.yaml @@ -0,0 +1,30 @@ +--- +- name: Spec Example 8.21. Block Scalar Nodes [1.3] + from: M5C3, modified for YAML 1.3 + tags: indent spec literal folded tag local-tag 1.3-mod + yaml: | + literal: |2 + value + folded: !foo >1 + value + tree: | + +STR + +DOC + +MAP + =VAL :literal + =VAL |value\n + =VAL :folded + =VAL >value\n + -MAP + -DOC + -STR + json: | + { + "literal": "value\n", + "folded": "value\n" + } + dump: | + literal: | + value + folded: !foo > + value diff --git a/src/Z9M4.yaml b/src/Z9M4.yaml new file mode 100644 index 0000000..27d22d6 --- /dev/null +++ b/src/Z9M4.yaml @@ -0,0 +1,23 @@ +--- +- name: Spec Example 6.22. Global Tag Prefix + from: http://www.yaml.org/spec/1.2/spec.html#id2783726 + tags: spec header tag unknown-tag + yaml: | + %TAG !e! tag:example.com,2000:app/ + --- + - !e!foo "bar" + tree: | + +STR + +DOC --- + +SEQ + =VAL "bar + -SEQ + -DOC + -STR + json: | + [ + "bar" + ] + dump: | + --- + - ! "bar" diff --git a/src/ZCZ6.yaml b/src/ZCZ6.yaml new file mode 100644 index 0000000..582021a --- /dev/null +++ b/src/ZCZ6.yaml @@ -0,0 +1,12 @@ +--- +- name: Invalid mapping in plain single line value + from: https://gist.github.com/anonymous/0c8db51d151baf8113205ba3ce71d1b4 via @ingydotnet + tags: error mapping scalar + fail: true + yaml: | + a: b: c: d + tree: | + +STR + +DOC + +MAP + =VAL :a diff --git a/src/ZF4X.yaml b/src/ZF4X.yaml new file mode 100644 index 0000000..3eaaee2 --- /dev/null +++ b/src/ZF4X.yaml @@ -0,0 +1,49 @@ +--- +- name: Spec Example 2.6. Mapping of Mappings + from: http://www.yaml.org/spec/1.2/spec.html#id2760372 + tags: flow spec mapping + yaml: | + Mark McGwire: {hr: 65, avg: 0.278} + Sammy Sosa: { + hr: 63, + avg: 0.288 + } + tree: | + +STR + +DOC + +MAP + =VAL :Mark McGwire + +MAP {} + =VAL :hr + =VAL :65 + =VAL :avg + =VAL :0.278 + -MAP + =VAL :Sammy Sosa + +MAP {} + =VAL :hr + =VAL :63 + =VAL :avg + =VAL :0.288 + -MAP + -MAP + -DOC + -STR + json: | + { + "Mark McGwire": { + "hr": 65, + "avg": 0.278 + }, + "Sammy Sosa": { + "hr": 63, + "avg": 0.288 + } + } + dump: | + Mark McGwire: + hr: 65 + avg: 0.278 + Sammy Sosa: + hr: 63 + avg: 0.288 diff --git a/src/ZH7C.yaml b/src/ZH7C.yaml new file mode 100644 index 0000000..ae04318 --- /dev/null +++ b/src/ZH7C.yaml @@ -0,0 +1,23 @@ +--- +- name: Anchors in Mapping + from: NimYAML tests + tags: anchor mapping + yaml: | + &a a: b + c: &d d + tree: | + +STR + +DOC + +MAP + =VAL &a :a + =VAL :b + =VAL :c + =VAL &d :d + -MAP + -DOC + -STR + json: | + { + "a": "b", + "c": "d" + } diff --git a/src/ZK9H.yaml b/src/ZK9H.yaml new file mode 100644 index 0000000..4b6b8b5 --- /dev/null +++ b/src/ZK9H.yaml @@ -0,0 +1,37 @@ +--- +- name: Nested top level flow mapping + from: '@perlpunk' + tags: flow indent mapping sequence + yaml: | + { key: [[[ + value + ]]] + } + tree: | + +STR + +DOC + +MAP {} + =VAL :key + +SEQ [] + +SEQ [] + +SEQ [] + =VAL :value + -SEQ + -SEQ + -SEQ + -MAP + -DOC + -STR + json: | + { + "key": [ + [ + [ + "value" + ] + ] + ] + } + dump: | + key: + - - - value diff --git a/src/ZL4Z.yaml b/src/ZL4Z.yaml new file mode 100644 index 0000000..9dc05a0 --- /dev/null +++ b/src/ZL4Z.yaml @@ -0,0 +1,14 @@ +--- +- name: Invalid nested mapping + from: '@perlpunk' + tags: error mapping + fail: true + yaml: | + --- + a: 'b': c + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL 'b diff --git a/src/ZVH3.yaml b/src/ZVH3.yaml new file mode 100644 index 0000000..c64c026 --- /dev/null +++ b/src/ZVH3.yaml @@ -0,0 +1,16 @@ +--- +- name: Wrong indented sequence item + from: '@perlpunk' + tags: error sequence indent + fail: true + yaml: | + - key: value + - item1 + tree: | + +STR + +DOC + +SEQ + +MAP + =VAL :key + =VAL :value + -MAP diff --git a/src/ZWK4.yaml b/src/ZWK4.yaml new file mode 100644 index 0000000..39abebf --- /dev/null +++ b/src/ZWK4.yaml @@ -0,0 +1,33 @@ +--- +- name: Key with anchor after missing explicit mapping value + from: '@perlpunk' + tags: anchor explicit-key mapping + yaml: | + --- + a: 1 + ? b + &anchor c: 3 + tree: | + +STR + +DOC --- + +MAP + =VAL :a + =VAL :1 + =VAL :b + =VAL : + =VAL &anchor :c + =VAL :3 + -MAP + -DOC + -STR + json: | + { + "a": 1, + "b": null, + "c": 3 + } + dump: | + --- + a: 1 + b: + &anchor c: 3 diff --git a/src/ZXT5.yaml b/src/ZXT5.yaml new file mode 100644 index 0000000..34e6ec9 --- /dev/null +++ b/src/ZXT5.yaml @@ -0,0 +1,13 @@ +--- +- name: Implicit key followed by newline and adjacent value + from: '@perlpunk' + tags: error flow mapping sequence + fail: true + yaml: | + [ "key" + :value ] + tree: | + +STR + +DOC + +SEQ [] + =VAL "key diff --git a/src/ZYU8.yaml b/src/ZYU8.yaml new file mode 100644 index 0000000..646da1b --- /dev/null +++ b/src/ZYU8.yaml @@ -0,0 +1,32 @@ +--- +- skip: true + note: The following cases are valid YAML according to the 1.2 productions but + not at all usefully valid. We don't want to encourage parsers to support + them when we'll likely make them invalid later. + also: MU58 + name: Directive variants + from: '@ingydotnet' + tags: directive + yaml: | + %YAML1.1 + --- + tree: | + +STR + +DOC --- + =VAL : + -DOC + -STR + json: | + null + +- yaml: | + %*** + --- + +- yaml: | + %YAML 1.1 1.2 + --- + +- yaml: | + %YAML 1.12345 + ---