Add yaml-test-suite
as subtree.
This commit is contained in:
commit
3f9b8c22a3
369 changed files with 12584 additions and 0 deletions
351
parser/tests/yaml-test-suite/.bpan/run-or-docker.bash
Normal file
351
parser/tests/yaml-test-suite/.bpan/run-or-docker.bash
Normal file
|
@ -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; }
|
15
parser/tests/yaml-test-suite/.github/workflows/test.yaml
vendored
Normal file
15
parser/tests/yaml-test-suite/.github/workflows/test.yaml
vendored
Normal file
|
@ -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
|
8
parser/tests/yaml-test-suite/.gitignore
vendored
Normal file
8
parser/tests/yaml-test-suite/.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/data/
|
||||
/gh-pages/
|
||||
/export.tsv
|
||||
/import.tsv
|
||||
/matrix/
|
||||
/new/
|
||||
/node_modules/
|
||||
/testml/
|
21
parser/tests/yaml-test-suite/License
Normal file
21
parser/tests/yaml-test-suite/License
Normal file
|
@ -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.
|
124
parser/tests/yaml-test-suite/Makefile
Normal file
124
parser/tests/yaml-test-suite/Makefile
Normal file
|
@ -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 $</*
|
||||
suite-to-data src/*.yaml
|
||||
|
||||
data-status: data
|
||||
@git -C $< add -Af . && \
|
||||
git -C $< status --short
|
||||
|
||||
data-diff: data
|
||||
git -C $< add -Af . && \
|
||||
git -C $< diff --cached
|
||||
|
||||
data-push: data data-update
|
||||
[[ $$(git -C $< status --short) ]] && \
|
||||
( \
|
||||
git -C $< add -Af . && \
|
||||
COMMIT=$$(git rev-parse --short HEAD) && \
|
||||
git -C $< commit -m "Regenerated data from main $$COMMIT" && \
|
||||
git -C $< push origin data \
|
||||
)
|
||||
|
||||
common:
|
||||
cp $(COMMON)/bpan/run-or-docker.bash $(BPAN)/
|
||||
|
||||
clean:
|
||||
rm -f export.tsv
|
||||
rm -fr data gh-pages new testml
|
||||
git worktree prune
|
||||
|
||||
docker-push: docker-build
|
||||
RUN_OR_DOCKER_PUSH=true suite-to-data
|
||||
|
||||
clean-docker:
|
||||
-docker images | \
|
||||
grep -E '(suite-to-data|new-test-file)' | \
|
||||
awk '{print $3}' | \
|
||||
xargs docker rmi 2>/dev/null
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
gh-pages:
|
||||
git branch --track $@ origin/$@ 2>/dev/null || true
|
||||
git worktree add $@ $@
|
173
parser/tests/yaml-test-suite/ReadMe.md
Normal file
173
parser/tests/yaml-test-suite/ReadMe.md
Normal file
|
@ -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
|
||||
<https://github.com/perlpunk/yaml-test-matrix>.
|
||||
|
||||
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:
|
||||
|
||||
* `<SPC>` for a space character
|
||||
* `<TAB>` 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.
|
129
parser/tests/yaml-test-suite/bin/YAMLTestSuite.pm
Normal file
129
parser/tests/yaml-test-suite/bin/YAMLTestSuite.pm
Normal file
|
@ -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;
|
82
parser/tests/yaml-test-suite/bin/new-test-file
Executable file
82
parser/tests/yaml-test-suite/bin/new-test-file
Executable 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: <test title>
|
||||
|
||||
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 "$@"
|
19
parser/tests/yaml-test-suite/bin/new-test-id
Executable file
19
parser/tests/yaml-test-suite/bin/new-test-id
Executable file
|
@ -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"
|
||||
)
|
||||
|
157
parser/tests/yaml-test-suite/bin/run-all-parsers
Executable file
157
parser/tests/yaml-test-suite/bin/run-all-parsers
Executable file
|
@ -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/<Tag\("!!",\ "(.*?)"\)>/<tag:yaml.org,2002:$1>/g;
|
||||
s/<Tag\("!",\ "(.*?)"\)>/<!$1>/g;
|
||||
s/<Tag\("",\ "!"\)>/<!>/g;
|
||||
s/<Tag\("",\ "(tag:.*?)"\)>/<$1>/g;
|
||||
s/<Tag\("",\ "(!.*?)"\)>/<$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 "$@"
|
27
parser/tests/yaml-test-suite/bin/suite-to-data
Executable file
27
parser/tests/yaml-test-suite/bin/suite-to-data
Executable file
|
@ -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 "$@"
|
92
parser/tests/yaml-test-suite/bin/suite-to-data.pl
Normal file
92
parser/tests/yaml-test-suite/bin/suite-to-data.pl
Normal file
|
@ -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<id ID num data multi slug>};
|
||||
|
||||
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";
|
||||
}
|
64
parser/tests/yaml-test-suite/bin/suite-to-testml
Executable file
64
parser/tests/yaml-test-suite/bin/suite-to-testml
Executable file
|
@ -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<id ID num data>};
|
||||
|
||||
my ($name, $yaml, $tree, $fail) =
|
||||
@$data{qw<name yaml tree fail>};
|
||||
|
||||
$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";
|
||||
}
|
204
parser/tests/yaml-test-suite/bin/suite-to-tsv
Executable file
204
parser/tests/yaml-test-suite/bin/suite-to-tsv
Executable file
|
@ -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";
|
||||
}
|
39
parser/tests/yaml-test-suite/bin/tsv-to-json
Executable file
39
parser/tests/yaml-test-suite/bin/tsv-to-json
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict; use warnings;
|
||||
use JSON::PP;
|
||||
|
||||
$_ = do { local $/; <STDIN> };
|
||||
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);
|
99
parser/tests/yaml-test-suite/bin/tsv-to-new
Executable file
99
parser/tests/yaml-test-suite/bin/tsv-to-new
Executable file
|
@ -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
|
148
parser/tests/yaml-test-suite/bin/yaml-to-test
Executable file
148
parser/tests/yaml-test-suite/bin/yaml-to-test
Executable file
|
@ -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<MORE SKIP NAME FROM TAGS TREE>};
|
||||
|
||||
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;
|
||||
}
|
60
parser/tests/yaml-test-suite/doc/tag-usage.md
Normal file
60
parser/tests/yaml-test-suite/doc/tag-usage.md
Normal file
|
@ -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
|
||||
```
|
56
parser/tests/yaml-test-suite/src/229Q.yaml
Normal file
56
parser/tests/yaml-test-suite/src/229Q.yaml
Normal file
|
@ -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
|
15
parser/tests/yaml-test-suite/src/236B.yaml
Normal file
15
parser/tests/yaml-test-suite/src/236B.yaml
Normal file
|
@ -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
|
82
parser/tests/yaml-test-suite/src/26DV.yaml
Normal file
82
parser/tests/yaml-test-suite/src/26DV.yaml
Normal file
|
@ -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
|
17
parser/tests/yaml-test-suite/src/27NA.yaml
Normal file
17
parser/tests/yaml-test-suite/src/27NA.yaml
Normal file
|
@ -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
|
32
parser/tests/yaml-test-suite/src/2AUY.yaml
Normal file
32
parser/tests/yaml-test-suite/src/2AUY.yaml
Normal file
|
@ -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 <tag:yaml.org,2002:str> :a
|
||||
=VAL :b
|
||||
=VAL <tag:yaml.org,2002:int> :42
|
||||
=VAL :d
|
||||
-SEQ
|
||||
-DOC
|
||||
-STR
|
||||
json: |
|
||||
[
|
||||
"a",
|
||||
"b",
|
||||
42,
|
||||
"d"
|
||||
]
|
||||
dump: |
|
||||
- !!str a
|
||||
- b
|
||||
- !!int 42
|
||||
- d
|
12
parser/tests/yaml-test-suite/src/2CMS.yaml
Normal file
12
parser/tests/yaml-test-suite/src/2CMS.yaml
Normal file
|
@ -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
|
41
parser/tests/yaml-test-suite/src/2EBW.yaml
Normal file
41
parser/tests/yaml-test-suite/src/2EBW.yaml
Normal file
|
@ -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
|
38
parser/tests/yaml-test-suite/src/2G84.yaml
Normal file
38
parser/tests/yaml-test-suite/src/2G84.yaml
Normal file
|
@ -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: |
|
||||
--- ""
|
18
parser/tests/yaml-test-suite/src/2JQS.yaml
Normal file
18
parser/tests/yaml-test-suite/src/2JQS.yaml
Normal file
|
@ -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
|
22
parser/tests/yaml-test-suite/src/2LFX.yaml
Normal file
22
parser/tests/yaml-test-suite/src/2LFX.yaml
Normal file
|
@ -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"
|
27
parser/tests/yaml-test-suite/src/2SXE.yaml
Normal file
27
parser/tests/yaml-test-suite/src/2SXE.yaml
Normal file
|
@ -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:
|
36
parser/tests/yaml-test-suite/src/2XXW.yaml
Normal file
36
parser/tests/yaml-test-suite/src/2XXW.yaml
Normal file
|
@ -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 <tag:yaml.org,2002:set>
|
||||
=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:
|
30
parser/tests/yaml-test-suite/src/33X3.yaml
Normal file
30
parser/tests/yaml-test-suite/src/33X3.yaml
Normal file
|
@ -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 <tag:yaml.org,2002:int> :1
|
||||
=VAL <tag:yaml.org,2002:int> :-2
|
||||
=VAL <tag:yaml.org,2002:int> :33
|
||||
-SEQ
|
||||
-DOC
|
||||
-STR
|
||||
json: |
|
||||
[
|
||||
1,
|
||||
-2,
|
||||
33
|
||||
]
|
||||
dump: |
|
||||
---
|
||||
- !!int 1
|
||||
- !!int -2
|
||||
- !!int 33
|
44
parser/tests/yaml-test-suite/src/35KP.yaml
Normal file
44
parser/tests/yaml-test-suite/src/35KP.yaml
Normal file
|
@ -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 <tag:yaml.org,2002:map>
|
||||
=VAL :a
|
||||
=VAL :b
|
||||
-MAP
|
||||
-DOC
|
||||
+DOC ---
|
||||
+SEQ <tag:yaml.org,2002:seq>
|
||||
=VAL <tag:yaml.org,2002:str> :c
|
||||
-SEQ
|
||||
-DOC
|
||||
+DOC ---
|
||||
=VAL <tag:yaml.org,2002:str> :d e
|
||||
-DOC
|
||||
-STR
|
||||
json: |
|
||||
{
|
||||
"a": "b"
|
||||
}
|
||||
[
|
||||
"c"
|
||||
]
|
||||
"d e"
|
||||
dump: |
|
||||
--- !!map
|
||||
a: b
|
||||
--- !!seq
|
||||
- !!str c
|
||||
--- !!str d e
|
28
parser/tests/yaml-test-suite/src/36F6.yaml
Normal file
28
parser/tests/yaml-test-suite/src/36F6.yaml
Normal file
|
@ -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'
|
28
parser/tests/yaml-test-suite/src/3ALJ.yaml
Normal file
28
parser/tests/yaml-test-suite/src/3ALJ.yaml
Normal file
|
@ -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"
|
||||
]
|
31
parser/tests/yaml-test-suite/src/3GZX.yaml
Normal file
31
parser/tests/yaml-test-suite/src/3GZX.yaml
Normal file
|
@ -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"
|
||||
}
|
17
parser/tests/yaml-test-suite/src/3HFZ.yaml
Normal file
17
parser/tests/yaml-test-suite/src/3HFZ.yaml
Normal file
|
@ -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 ...
|
18
parser/tests/yaml-test-suite/src/3MYT.yaml
Normal file
18
parser/tests/yaml-test-suite/src/3MYT.yaml
Normal file
|
@ -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
|
22
parser/tests/yaml-test-suite/src/3R3P.yaml
Normal file
22
parser/tests/yaml-test-suite/src/3R3P.yaml
Normal file
|
@ -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
|
87
parser/tests/yaml-test-suite/src/3RLN.yaml
Normal file
87
parser/tests/yaml-test-suite/src/3RLN.yaml
Normal file
|
@ -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"
|
21
parser/tests/yaml-test-suite/src/3UYS.yaml
Normal file
21
parser/tests/yaml-test-suite/src/3UYS.yaml
Normal file
|
@ -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"
|
27
parser/tests/yaml-test-suite/src/4ABK.yaml
Normal file
27
parser/tests/yaml-test-suite/src/4ABK.yaml
Normal file
|
@ -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
|
30
parser/tests/yaml-test-suite/src/4CQQ.yaml
Normal file
30
parser/tests/yaml-test-suite/src/4CQQ.yaml
Normal file
|
@ -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"
|
15
parser/tests/yaml-test-suite/src/4EJS.yaml
Normal file
15
parser/tests/yaml-test-suite/src/4EJS.yaml
Normal file
|
@ -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
|
42
parser/tests/yaml-test-suite/src/4FJ6.yaml
Normal file
42
parser/tests/yaml-test-suite/src/4FJ6.yaml
Normal file
|
@ -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
|
14
parser/tests/yaml-test-suite/src/4GC6.yaml
Normal file
14
parser/tests/yaml-test-suite/src/4GC6.yaml
Normal file
|
@ -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\""
|
17
parser/tests/yaml-test-suite/src/4H7K.yaml
Normal file
17
parser/tests/yaml-test-suite/src/4H7K.yaml
Normal file
|
@ -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
|
19
parser/tests/yaml-test-suite/src/4HVU.yaml
Normal file
19
parser/tests/yaml-test-suite/src/4HVU.yaml
Normal file
|
@ -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
|
20
parser/tests/yaml-test-suite/src/4JVG.yaml
Normal file
20
parser/tests/yaml-test-suite/src/4JVG.yaml
Normal file
|
@ -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
|
56
parser/tests/yaml-test-suite/src/4MUZ.yaml
Normal file
56
parser/tests/yaml-test-suite/src/4MUZ.yaml
Normal file
|
@ -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
|
29
parser/tests/yaml-test-suite/src/4Q9F.yaml
Normal file
29
parser/tests/yaml-test-suite/src/4Q9F.yaml
Normal file
|
@ -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
|
44
parser/tests/yaml-test-suite/src/4QFQ.yaml
Normal file
44
parser/tests/yaml-test-suite/src/4QFQ.yaml
Normal file
|
@ -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
|
27
parser/tests/yaml-test-suite/src/4RWC.yaml
Normal file
27
parser/tests/yaml-test-suite/src/4RWC.yaml
Normal file
|
@ -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
|
14
parser/tests/yaml-test-suite/src/4UYU.yaml
Normal file
14
parser/tests/yaml-test-suite/src/4UYU.yaml
Normal file
|
@ -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"
|
17
parser/tests/yaml-test-suite/src/4V8U.yaml
Normal file
17
parser/tests/yaml-test-suite/src/4V8U.yaml
Normal file
|
@ -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
|
40
parser/tests/yaml-test-suite/src/4WA9.yaml
Normal file
40
parser/tests/yaml-test-suite/src/4WA9.yaml
Normal file
|
@ -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
|
41
parser/tests/yaml-test-suite/src/4ZYM.yaml
Normal file
41
parser/tests/yaml-test-suite/src/4ZYM.yaml
Normal file
|
@ -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
|
17
parser/tests/yaml-test-suite/src/52DL.yaml
Normal file
17
parser/tests/yaml-test-suite/src/52DL.yaml
Normal file
|
@ -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
|
25
parser/tests/yaml-test-suite/src/54T7.yaml
Normal file
25
parser/tests/yaml-test-suite/src/54T7.yaml
Normal file
|
@ -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
|
11
parser/tests/yaml-test-suite/src/55WF.yaml
Normal file
11
parser/tests/yaml-test-suite/src/55WF.yaml
Normal file
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
- name: Invalid escape in double quoted string
|
||||
from: '@perlpunk'
|
||||
tags: error double
|
||||
fail: true
|
||||
yaml: |
|
||||
---
|
||||
"\."
|
||||
tree: |
|
||||
+STR
|
||||
+DOC ---
|
36
parser/tests/yaml-test-suite/src/565N.yaml
Normal file
36
parser/tests/yaml-test-suite/src/565N.yaml
Normal file
|
@ -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 <tag:yaml.org,2002:binary> "R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLCAgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
|
||||
=VAL :generic
|
||||
=VAL <tag:yaml.org,2002:binary> |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."
|
||||
}
|
49
parser/tests/yaml-test-suite/src/57H4.yaml
Normal file
49
parser/tests/yaml-test-suite/src/57H4.yaml
Normal file
|
@ -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 <tag:yaml.org,2002:seq>
|
||||
=VAL :entry
|
||||
+SEQ <tag:yaml.org,2002:seq>
|
||||
=VAL :nested
|
||||
-SEQ
|
||||
-SEQ
|
||||
=VAL :mapping
|
||||
+MAP <tag:yaml.org,2002: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
|
21
parser/tests/yaml-test-suite/src/58MP.yaml
Normal file
21
parser/tests/yaml-test-suite/src/58MP.yaml
Normal file
|
@ -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
|
33
parser/tests/yaml-test-suite/src/5BVJ.yaml
Normal file
33
parser/tests/yaml-test-suite/src/5BVJ.yaml
Normal file
|
@ -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
|
42
parser/tests/yaml-test-suite/src/5C5M.yaml
Normal file
42
parser/tests/yaml-test-suite/src/5C5M.yaml
Normal file
|
@ -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
|
33
parser/tests/yaml-test-suite/src/5GBF.yaml
Normal file
33
parser/tests/yaml-test-suite/src/5GBF.yaml
Normal file
|
@ -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
|
38
parser/tests/yaml-test-suite/src/5KJE.yaml
Normal file
38
parser/tests/yaml-test-suite/src/5KJE.yaml
Normal file
|
@ -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
|
16
parser/tests/yaml-test-suite/src/5LLU.yaml
Normal file
16
parser/tests/yaml-test-suite/src/5LLU.yaml
Normal file
|
@ -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
|
24
parser/tests/yaml-test-suite/src/5MUD.yaml
Normal file
24
parser/tests/yaml-test-suite/src/5MUD.yaml
Normal file
|
@ -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
|
22
parser/tests/yaml-test-suite/src/5NYZ.yaml
Normal file
22
parser/tests/yaml-test-suite/src/5NYZ.yaml
Normal file
|
@ -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
|
37
parser/tests/yaml-test-suite/src/5T43.yaml
Normal file
37
parser/tests/yaml-test-suite/src/5T43.yaml
Normal file
|
@ -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
|
13
parser/tests/yaml-test-suite/src/5TRB.yaml
Normal file
13
parser/tests/yaml-test-suite/src/5TRB.yaml
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
- name: Invalid document-start marker in doublequoted tring
|
||||
from: '@perlpunk'
|
||||
tags: header double error
|
||||
fail: true
|
||||
yaml: |
|
||||
---
|
||||
"
|
||||
---
|
||||
"
|
||||
tree: |
|
||||
+STR
|
||||
+DOC ---
|
24
parser/tests/yaml-test-suite/src/5TYM.yaml
Normal file
24
parser/tests/yaml-test-suite/src/5TYM.yaml
Normal file
|
@ -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 <!my-light> :fluorescent
|
||||
-DOC ...
|
||||
+DOC ---
|
||||
=VAL <!my-light> :green
|
||||
-DOC
|
||||
-STR
|
||||
json: |
|
||||
"fluorescent"
|
||||
"green"
|
13
parser/tests/yaml-test-suite/src/5U3A.yaml
Normal file
13
parser/tests/yaml-test-suite/src/5U3A.yaml
Normal file
|
@ -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
|
38
parser/tests/yaml-test-suite/src/5WE3.yaml
Normal file
38
parser/tests/yaml-test-suite/src/5WE3.yaml
Normal file
|
@ -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
|
17
parser/tests/yaml-test-suite/src/62EZ.yaml
Normal file
17
parser/tests/yaml-test-suite/src/62EZ.yaml
Normal file
|
@ -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
|
31
parser/tests/yaml-test-suite/src/652Z.yaml
Normal file
31
parser/tests/yaml-test-suite/src/652Z.yaml
Normal file
|
@ -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
|
18
parser/tests/yaml-test-suite/src/65WH.yaml
Normal file
18
parser/tests/yaml-test-suite/src/65WH.yaml
Normal file
|
@ -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"
|
||||
]
|
37
parser/tests/yaml-test-suite/src/6BCT.yaml
Normal file
37
parser/tests/yaml-test-suite/src/6BCT.yaml
Normal file
|
@ -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
|
28
parser/tests/yaml-test-suite/src/6BFJ.yaml
Normal file
28
parser/tests/yaml-test-suite/src/6BFJ.yaml
Normal file
|
@ -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
|
18
parser/tests/yaml-test-suite/src/6CA3.yaml
Normal file
18
parser/tests/yaml-test-suite/src/6CA3.yaml
Normal file
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
- name: Tab indented top flow
|
||||
from: '@ingydotnet'
|
||||
tags: indent whitespace
|
||||
yaml: |
|
||||
————»[
|
||||
————»]
|
||||
tree: |
|
||||
+STR
|
||||
+DOC
|
||||
+SEQ []
|
||||
-SEQ
|
||||
-DOC
|
||||
-STR
|
||||
json: |
|
||||
[]
|
||||
emit: |
|
||||
--- []
|
26
parser/tests/yaml-test-suite/src/6CK3.yaml
Normal file
26
parser/tests/yaml-test-suite/src/6CK3.yaml
Normal file
|
@ -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 <!local> :foo
|
||||
=VAL <tag:yaml.org,2002:str> :bar
|
||||
=VAL <tag:example.com,2000:app/tag!> :baz
|
||||
-SEQ
|
||||
-DOC
|
||||
-STR
|
||||
json: |
|
||||
[
|
||||
"foo",
|
||||
"bar",
|
||||
"baz"
|
||||
]
|
27
parser/tests/yaml-test-suite/src/6FWR.yaml
Normal file
27
parser/tests/yaml-test-suite/src/6FWR.yaml
Normal file
|
@ -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
|
||||
|
||||
␣␣␣
|
||||
...
|
21
parser/tests/yaml-test-suite/src/6H3V.yaml
Normal file
21
parser/tests/yaml-test-suite/src/6H3V.yaml
Normal file
|
@ -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'
|
55
parser/tests/yaml-test-suite/src/6HB6.yaml
Normal file
55
parser/tests/yaml-test-suite/src/6HB6.yaml
Normal file
|
@ -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
|
21
parser/tests/yaml-test-suite/src/6JQW.yaml
Normal file
21
parser/tests/yaml-test-suite/src/6JQW.yaml
Normal file
|
@ -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: |
|
||||
--- |
|
||||
\//||\/||
|
||||
// || ||__
|
17
parser/tests/yaml-test-suite/src/6JTT.yaml
Normal file
17
parser/tests/yaml-test-suite/src/6JTT.yaml
Normal file
|
@ -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
|
38
parser/tests/yaml-test-suite/src/6JWB.yaml
Normal file
38
parser/tests/yaml-test-suite/src/6JWB.yaml
Normal file
|
@ -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 <tag:yaml.org,2002:seq>
|
||||
=VAL <tag:yaml.org,2002:str> :a
|
||||
+MAP <tag:yaml.org,2002:map>
|
||||
=VAL :key
|
||||
=VAL <tag:yaml.org,2002:str> :value
|
||||
-MAP
|
||||
-SEQ
|
||||
-MAP
|
||||
-DOC
|
||||
-STR
|
||||
json: |
|
||||
{
|
||||
"foo": [
|
||||
"a",
|
||||
{
|
||||
"key": "value"
|
||||
}
|
||||
]
|
||||
}
|
||||
dump: |
|
||||
foo: !!seq
|
||||
- !!str a
|
||||
- !!map
|
||||
key: !!str value
|
28
parser/tests/yaml-test-suite/src/6KGN.yaml
Normal file
28
parser/tests/yaml-test-suite/src/6KGN.yaml
Normal file
|
@ -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
|
18
parser/tests/yaml-test-suite/src/6LVF.yaml
Normal file
18
parser/tests/yaml-test-suite/src/6LVF.yaml
Normal file
|
@ -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"
|
22
parser/tests/yaml-test-suite/src/6M2F.yaml
Normal file
22
parser/tests/yaml-test-suite/src/6M2F.yaml
Normal file
|
@ -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
|
33
parser/tests/yaml-test-suite/src/6PBE.yaml
Normal file
33
parser/tests/yaml-test-suite/src/6PBE.yaml
Normal file
|
@ -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
|
18
parser/tests/yaml-test-suite/src/6S55.yaml
Normal file
18
parser/tests/yaml-test-suite/src/6S55.yaml
Normal file
|
@ -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
|
27
parser/tests/yaml-test-suite/src/6SLA.yaml
Normal file
27
parser/tests/yaml-test-suite/src/6SLA.yaml
Normal file
|
@ -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
|
29
parser/tests/yaml-test-suite/src/6VJK.yaml
Normal file
29
parser/tests/yaml-test-suite/src/6VJK.yaml
Normal file
|
@ -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!
|
35
parser/tests/yaml-test-suite/src/6WLZ.yaml
Normal file
35
parser/tests/yaml-test-suite/src/6WLZ.yaml
Normal file
|
@ -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 <!foo> "bar
|
||||
-DOC ...
|
||||
+DOC ---
|
||||
=VAL <tag:example.com,2000:app/foo> "bar
|
||||
-DOC
|
||||
-STR
|
||||
json: |
|
||||
"bar"
|
||||
"bar"
|
||||
dump: |
|
||||
---
|
||||
!foo "bar"
|
||||
...
|
||||
--- !<tag:example.com,2000:app/foo>
|
||||
"bar"
|
||||
emit: |
|
||||
--- !foo "bar"
|
||||
...
|
||||
--- !<tag:example.com,2000:app/foo> "bar"
|
25
parser/tests/yaml-test-suite/src/6WPF.yaml
Normal file
25
parser/tests/yaml-test-suite/src/6WPF.yaml
Normal file
|
@ -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 "
|
22
parser/tests/yaml-test-suite/src/6XDY.yaml
Normal file
22
parser/tests/yaml-test-suite/src/6XDY.yaml
Normal file
|
@ -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: |
|
||||
---
|
||||
---
|
40
parser/tests/yaml-test-suite/src/6ZKB.yaml
Normal file
40
parser/tests/yaml-test-suite/src/6ZKB.yaml
Normal file
|
@ -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
|
38
parser/tests/yaml-test-suite/src/735Y.yaml
Normal file
38
parser/tests/yaml-test-suite/src/735Y.yaml
Normal file
|
@ -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 <tag:yaml.org,2002: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
|
41
parser/tests/yaml-test-suite/src/74H7.yaml
Normal file
41
parser/tests/yaml-test-suite/src/74H7.yaml
Normal file
|
@ -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 <tag:yaml.org,2002:str> :a
|
||||
=VAL :b
|
||||
=VAL :c
|
||||
=VAL <tag:yaml.org,2002:int> :42
|
||||
=VAL :e
|
||||
=VAL <tag:yaml.org,2002:str> :f
|
||||
=VAL :g
|
||||
=VAL :h
|
||||
=VAL <tag:yaml.org,2002:str> :23
|
||||
=VAL <tag:yaml.org,2002:bool> :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
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue