├── .editorconfig ├── .eslintrc.yml ├── .github ├── FUNDING.yml └── workflows │ └── ci.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── benchmark ├── add-by-tag.sh ├── benchmark.js ├── implementations │ └── current │ │ └── index.js ├── profile.js └── samples │ ├── document_application2.yaml │ ├── document_huge.yaml │ ├── document_nodeca_application.yaml │ ├── document_nodeca_database.yaml │ ├── document_nodeca_logger.yaml │ ├── scalar_block_folded.yaml │ ├── scalar_block_literal.yaml │ ├── scalar_double_quoted_binary_01.yaml │ ├── scalar_double_quoted_binary_02.yaml │ ├── scalar_double_quoted_escaped_01.yaml │ ├── scalar_double_quoted_escaped_02.yaml │ ├── scalar_double_quoted_simple_01.yaml │ ├── scalar_double_quoted_simple_02.yaml │ └── scalar_double_quoted_simple_multiline.yaml ├── bin └── js-yaml.js ├── dist ├── js-yaml.js ├── js-yaml.min.js └── js-yaml.mjs ├── examples ├── .eslintrc.yml ├── custom_types.js ├── custom_types.yml ├── dumper.js ├── dumper.json ├── handle_unknown_types.js ├── int_type_override.js ├── sample_document.js └── sample_document.yml ├── index.js ├── lib ├── common.js ├── dumper.js ├── exception.js ├── loader.js ├── schema.js ├── schema │ ├── core.js │ ├── default.js │ ├── failsafe.js │ └── json.js ├── snippet.js ├── type.js └── type │ ├── binary.js │ ├── bool.js │ ├── float.js │ ├── int.js │ ├── map.js │ ├── merge.js │ ├── null.js │ ├── omap.js │ ├── pairs.js │ ├── seq.js │ ├── set.js │ ├── str.js │ └── timestamp.js ├── migrate_v3_to_v4.md ├── package.json ├── support ├── build_demo.js ├── demo_template │ ├── base64.js │ ├── demo.css │ ├── demo.js │ ├── index.html │ └── rollup.config.js └── rollup.config.js └── test ├── .eslintrc.yml ├── 00-units.js ├── 10-loader.js ├── 11-load-errors.js ├── 20-dumper.js ├── 25-dumper-fuzzy.js ├── 30-issues.js ├── issues ├── 0008.js ├── 0017.js ├── 0019.js ├── 0026.js ├── 0027.js ├── 0033.js ├── 0046.js ├── 0054.js ├── 0063.js ├── 0064.js ├── 0064.yml ├── 0068.js ├── 0080.js ├── 0085.js ├── 0092.js ├── 0093.js ├── 0095.js ├── 0108.js ├── 0110.js ├── 0112.js ├── 0117.js ├── 0144.js ├── 0154.js ├── 0155.js ├── 0156.js ├── 0160.js ├── 0164.js ├── 0194.js ├── 0203.js ├── 0205.js ├── 0220.js ├── 0221.js ├── 0235.js ├── 0243-basic.yml ├── 0243-nested.yml ├── 0243.js ├── 0248-listener.js ├── 0258.js ├── 0266.js ├── 0301.js ├── 0303.js ├── 0321.js ├── 0332.js ├── 0333.js ├── 0335.js ├── 0342.js ├── 0346.js ├── 0350.js ├── 0351.js ├── 0385.js ├── 0399.js ├── 0403.js ├── 0418.js ├── 0432.js ├── 0468.js ├── 0470.js ├── 0475-case1.yml ├── 0475-case2.yml ├── 0475.js ├── 0519.js ├── 0521.js ├── 0525-1.js ├── 0525-2.js ├── 0529.js ├── 0570.js ├── 0571.js ├── 0576.js ├── 0586.js ├── 0587.js └── 0614.js ├── samples-common ├── construct-binary.js ├── construct-binary.yml ├── construct-bool.js ├── construct-bool.yml ├── construct-custom.js ├── construct-custom.yml ├── construct-float.js ├── construct-float.yml ├── construct-int.js ├── construct-int.yml ├── construct-map.js ├── construct-map.yml ├── construct-merge.js ├── construct-merge.yml ├── construct-null.js ├── construct-null.yml ├── construct-omap.js ├── construct-omap.yml ├── construct-pairs.js ├── construct-pairs.yml ├── construct-seq.js ├── construct-seq.yml ├── construct-set.js ├── construct-set.yml ├── construct-str-ascii.js ├── construct-str-ascii.yml ├── construct-str-utf8.js ├── construct-str-utf8.yml ├── construct-str.js ├── construct-str.yml ├── construct-string-types.js ├── construct-string-types.yml ├── construct-timestamp.js ├── construct-timestamp.yml ├── construct-value.js ├── construct-value.yml ├── dump-empty-collections.js ├── dump-empty-collections.yml ├── duplicate-mapping-key.js ├── duplicate-mapping-key.yml ├── duplicate-merge-key.js ├── duplicate-merge-key.yml ├── emitting-unacceptable-unicode-character-bug.js ├── emitting-unacceptable-unicode-character-bug.yml ├── invalid-single-quote-bug.js ├── invalid-single-quote-bug.yml ├── more-floats.js ├── more-floats.yml ├── negative-float-bug.js ├── negative-float-bug.yml ├── single-dot-is-not-float-bug.js ├── single-dot-is-not-float-bug.yml ├── timestamp-bugs.js ├── timestamp-bugs.yml ├── utf8-implicit.js └── utf8-implicit.yml ├── samples-load-errors ├── a-nasty-libyaml-bug.yml ├── document-separator-in-quoted-scalar.yml ├── duplicate-key.js ├── duplicate-key.yml ├── duplicate-tag-directive.yml ├── duplicate-value-key.js ├── duplicate-value-key.yml ├── duplicate-yaml-directive.yml ├── expected-mapping.yml ├── expected-scalar.yml ├── expected-sequence.yml ├── fetch-complex-value-bug.yml ├── forbidden-entry.yml ├── forbidden-key.yml ├── forbidden-value.yml ├── invalid-anchor-2.yml ├── invalid-base64-data-2.yml ├── invalid-base64-data.yml ├── invalid-block-scalar-indicator.yml ├── invalid-character.yml ├── invalid-directive-line.yml ├── invalid-directive-name-1.yml ├── invalid-directive-name-2.yml ├── invalid-escape-character.yml ├── invalid-escape-numbers.yml ├── invalid-indentation-indicator-1.yml ├── invalid-indentation-indicator-2.yml ├── invalid-item-without-trailing-break.yml ├── invalid-merge-1.yml ├── invalid-merge-2.yml ├── invalid-omap-1.yml ├── invalid-omap-2.yml ├── invalid-omap-3.yml ├── invalid-pairs-1.yml ├── invalid-pairs-2.yml ├── invalid-pairs-3.yml ├── invalid-simple-key.yml ├── invalid-starting-character.yml ├── invalid-tag-2.yml ├── invalid-tag-directive-handle.yml ├── invalid-tag-handle-1.yml ├── invalid-tag-handle-2.yml ├── invalid-uri-escapes-1.yml ├── invalid-uri.yml ├── invalid-yaml-directive-version-1.yml ├── invalid-yaml-directive-version-2.yml ├── invalid-yaml-directive-version-3.yml ├── invalid-yaml-directive-version-4.yml ├── invalid-yaml-directive-version-5.yml ├── invalid-yaml-directive-version-6.yml ├── invalid-yaml-version.yml ├── no-block-collection-end.yml ├── no-block-mapping-end-2.yml ├── no-block-mapping-end.yml ├── no-document-start.yml ├── no-flow-mapping-end.yml ├── no-flow-sequence-end.yml ├── no-node-1.yml ├── no-node-2.yml ├── remove-possible-simple-key-bug.yml ├── unclosed-bracket.yml ├── unclosed-quoted-scalar.yml ├── undefined-anchor.yml └── undefined-tag-handle.yml ├── support └── schema.js ├── units ├── alias-nodes.js ├── bom-strip.js ├── character-set.js ├── dump-scalar-styles.js ├── empty-node-resolving.js ├── is-negative-zero.js ├── loader-parameters.js ├── replacer.js ├── single-document-error.js ├── skip-invalid.js ├── snippet.js ├── snippet.txt ├── sort-keys.js └── tagmultikind.js ├── unported ├── aliases-cdumper-bug.code ├── aliases.events ├── documents.events ├── emit-block-scalar-in-simple-key-context-bug.canonical ├── emit-block-scalar-in-simple-key-context-bug.data ├── emitting-unacceptable-unicode-character-bug.skip-ext ├── empty-anchor.emitter-error ├── empty-document-bug.canonical ├── empty-document-bug.data ├── empty-document-bug.empty ├── empty-tag-handle.emitter-error ├── empty-tag-prefix.emitter-error ├── empty-tag.emitter-error ├── expected-document-end.emitter-error ├── expected-document-start.emitter-error ├── expected-node-1.emitter-error ├── expected-node-2.emitter-error ├── expected-nothing.emitter-error ├── expected-stream-start.emitter-error ├── invalid-anchor.emitter-error ├── invalid-tag-handle-1.emitter-error ├── invalid-tag-handle-2.emitter-error ├── invalid-utf8-byte.loader-error ├── invalid-utf8-byte.stream-error ├── latin.unicode ├── mappings.events ├── no-alias-anchor.emitter-error ├── no-alias-anchor.skip-ext ├── no-tag.emitter-error ├── recursive-anchor.former-loader-error ├── recursive-dict.recursive ├── recursive-list.recursive ├── recursive-set.recursive ├── recursive-state.recursive ├── recursive-tuple.recursive ├── recursive.former-dumper-error ├── resolver.data ├── run-parser-crash-bug.data ├── scalars.events ├── scan-document-end-bug.canonical ├── scan-document-end-bug.data ├── scan-line-break-bug.canonical ├── scan-line-break-bug.data ├── sequences.events ├── serializer-is-already-opened.dumper-error ├── serializer-is-closed-1.dumper-error ├── serializer-is-closed-2.dumper-error ├── serializer-is-not-opened-1.dumper-error ├── serializer-is-not-opened-2.dumper-error ├── sloppy-indentation.canonical ├── sloppy-indentation.data ├── spec-02-01.data ├── spec-02-02.data ├── spec-02-03.data ├── spec-02-04.data ├── spec-02-05.data ├── spec-02-06.data ├── spec-02-07.data ├── spec-02-08.data ├── spec-02-09.data ├── spec-02-10.data ├── spec-02-11.data ├── spec-02-12.data ├── spec-02-13.data ├── spec-02-14.data ├── spec-02-15.data ├── spec-02-16.data ├── spec-02-17.data ├── spec-02-18.data ├── spec-02-19.data ├── spec-02-20.data ├── spec-02-21.data ├── spec-02-22.data ├── spec-02-23.data ├── spec-02-24.data ├── spec-02-25.data ├── spec-02-26.data ├── spec-02-27.data ├── spec-02-28.data ├── spec-05-01-utf8.data ├── spec-05-01-utf8.empty ├── spec-05-02-utf8.data ├── spec-05-02-utf8.error ├── spec-05-03.canonical ├── spec-05-03.data ├── spec-05-04.canonical ├── spec-05-04.data ├── spec-05-05.data ├── spec-05-05.empty ├── spec-05-06.canonical ├── spec-05-06.data ├── spec-05-07.canonical ├── spec-05-07.data ├── spec-05-08.canonical ├── spec-05-08.data ├── spec-05-09.canonical ├── spec-05-09.data ├── spec-05-10.data ├── spec-05-10.error ├── spec-05-11.canonical ├── spec-05-11.data ├── spec-05-12.data ├── spec-05-12.error ├── spec-05-13.canonical ├── spec-05-13.data ├── spec-05-14.canonical ├── spec-05-14.data ├── spec-05-15.data ├── spec-05-15.error ├── spec-06-01.canonical ├── spec-06-01.data ├── spec-06-02.data ├── spec-06-02.empty ├── spec-06-03.canonical ├── spec-06-03.data ├── spec-06-04.canonical ├── spec-06-04.data ├── spec-06-05.canonical ├── spec-06-05.data ├── spec-06-06.canonical ├── spec-06-06.data ├── spec-06-07.canonical ├── spec-06-07.data ├── spec-06-08.canonical ├── spec-06-08.data ├── spec-07-01.canonical ├── spec-07-01.data ├── spec-07-01.skip-ext ├── spec-07-02.canonical ├── spec-07-02.data ├── spec-07-02.skip-ext ├── spec-07-03.data ├── spec-07-03.error ├── spec-07-04.canonical ├── spec-07-04.data ├── spec-07-05.data ├── spec-07-05.error ├── spec-07-06.canonical ├── spec-07-06.data ├── spec-07-07a.canonical ├── spec-07-07a.data ├── spec-07-07b.canonical ├── spec-07-07b.data ├── spec-07-08.canonical ├── spec-07-08.data ├── spec-07-09.canonical ├── spec-07-09.data ├── spec-07-10.canonical ├── spec-07-10.data ├── spec-07-11.data ├── spec-07-11.empty ├── spec-07-12a.canonical ├── spec-07-12a.data ├── spec-07-12b.canonical ├── spec-07-12b.data ├── spec-07-13.canonical ├── spec-07-13.data ├── spec-08-01.canonical ├── spec-08-01.data ├── spec-08-02.canonical ├── spec-08-02.data ├── spec-08-03.canonical ├── spec-08-03.data ├── spec-08-04.data ├── spec-08-04.error ├── spec-08-05.canonical ├── spec-08-05.data ├── spec-08-06.data ├── spec-08-06.error ├── spec-08-07.canonical ├── spec-08-07.data ├── spec-08-08.canonical ├── spec-08-08.data ├── spec-08-09.canonical ├── spec-08-09.data ├── spec-08-10.canonical ├── spec-08-10.data ├── spec-08-11.canonical ├── spec-08-11.data ├── spec-08-12.canonical ├── spec-08-12.data ├── spec-08-13.canonical ├── spec-08-13.data ├── spec-08-13.skip-ext ├── spec-08-14.canonical ├── spec-08-14.data ├── spec-08-15.canonical ├── spec-08-15.data ├── spec-09-01.canonical ├── spec-09-01.data ├── spec-09-02.canonical ├── spec-09-02.data ├── spec-09-03.canonical ├── spec-09-03.data ├── spec-09-04.canonical ├── spec-09-04.data ├── spec-09-05.canonical ├── spec-09-05.data ├── spec-09-06.canonical ├── spec-09-06.data ├── spec-09-07.canonical ├── spec-09-07.data ├── spec-09-08.canonical ├── spec-09-08.data ├── spec-09-09.canonical ├── spec-09-09.data ├── spec-09-10.canonical ├── spec-09-10.data ├── spec-09-11.canonical ├── spec-09-11.data ├── spec-09-12.canonical ├── spec-09-12.data ├── spec-09-13.canonical ├── spec-09-13.data ├── spec-09-14.data ├── spec-09-14.error ├── spec-09-15.canonical ├── spec-09-15.data ├── spec-09-16.canonical ├── spec-09-16.data ├── spec-09-17.canonical ├── spec-09-17.data ├── spec-09-18.canonical ├── spec-09-18.data ├── spec-09-19.canonical ├── spec-09-19.data ├── spec-09-20.canonical ├── spec-09-20.data ├── spec-09-20.skip-ext ├── spec-09-21.data ├── spec-09-21.error ├── spec-09-22.canonical ├── spec-09-22.data ├── spec-09-23.canonical ├── spec-09-23.data ├── spec-09-24.canonical ├── spec-09-24.data ├── spec-09-25.canonical ├── spec-09-25.data ├── spec-09-26.canonical ├── spec-09-26.data ├── spec-09-27.canonical ├── spec-09-27.data ├── spec-09-28.canonical ├── spec-09-28.data ├── spec-09-29.canonical ├── spec-09-29.data ├── spec-09-30.canonical ├── spec-09-30.data ├── spec-09-31.canonical ├── spec-09-31.data ├── spec-09-32.canonical ├── spec-09-32.data ├── spec-09-33.canonical ├── spec-09-33.data ├── spec-10-01.canonical ├── spec-10-01.data ├── spec-10-02.canonical ├── spec-10-02.data ├── spec-10-03.canonical ├── spec-10-03.data ├── spec-10-04.canonical ├── spec-10-04.data ├── spec-10-05.canonical ├── spec-10-05.data ├── spec-10-06.canonical ├── spec-10-06.data ├── spec-10-07.canonical ├── spec-10-07.data ├── spec-10-08.data ├── spec-10-08.error ├── spec-10-09.canonical ├── spec-10-09.data ├── spec-10-10.canonical ├── spec-10-10.data ├── spec-10-11.canonical ├── spec-10-11.data ├── spec-10-12.canonical ├── spec-10-12.data ├── spec-10-13.canonical ├── spec-10-13.data ├── spec-10-14.canonical ├── spec-10-14.data ├── spec-10-15.canonical ├── spec-10-15.data ├── tags.events ├── unknown.dumper-error └── unsupported-version.emitter-error └── unsupported ├── bool.detect ├── colon-in-flow-context.loader-error ├── construct-python-bool.code ├── construct-python-bool.data ├── construct-python-bytes-py3.code ├── construct-python-bytes-py3.data ├── construct-python-complex.code ├── construct-python-complex.data ├── construct-python-float.code ├── construct-python-float.data ├── construct-python-int.code ├── construct-python-int.data ├── construct-python-long-short-py2.code ├── construct-python-long-short-py2.data ├── construct-python-long-short-py3.code ├── construct-python-long-short-py3.data ├── construct-python-name-module.code ├── construct-python-name-module.data ├── construct-python-none.code ├── construct-python-none.data ├── construct-python-object.code ├── construct-python-object.data ├── construct-python-str-ascii.code ├── construct-python-str-ascii.data ├── construct-python-str-utf8-py2.code ├── construct-python-str-utf8-py2.data ├── construct-python-str-utf8-py3.code ├── construct-python-str-utf8-py3.data ├── construct-python-tuple-list-dict.code ├── construct-python-tuple-list-dict.data ├── construct-python-unicode-ascii-py2.code ├── construct-python-unicode-ascii-py2.data ├── construct-python-unicode-ascii-py3.code ├── construct-python-unicode-ascii-py3.data ├── construct-python-unicode-utf8-py2.code ├── construct-python-unicode-utf8-py2.data ├── construct-python-unicode-utf8-py3.code ├── construct-python-unicode-utf8-py3.data ├── duplicate-anchor-1.loader-error ├── duplicate-anchor-2.loader-error ├── duplicate-mapping-key.data ├── empty-python-module.loader-error ├── empty-python-name.loader-error ├── float-representer-2.3-bug.code ├── float-representer-2.3-bug.data ├── float.detect ├── function.detect ├── int.detect ├── invalid-anchor-1.loader-error ├── invalid-python-bytes-2-py3.loader-error ├── invalid-python-bytes-py3.loader-error ├── invalid-python-module-kind.loader-error ├── invalid-python-module-value.loader-error ├── invalid-python-module.loader-error ├── invalid-python-name-kind.loader-error ├── invalid-python-name-module-2.loader-error ├── invalid-python-name-module.loader-error ├── invalid-python-name-object.loader-error ├── invalid-python-name-value.loader-error ├── invalid-tag-1.loader-error ├── invalid-tag-directive-prefix.loader-error ├── invalid-uri-escapes-2.loader-error ├── invalid-uri-escapes-3.loader-error ├── merge.detect ├── null.detect ├── odd-utf16.stream-error ├── spec-02-01.structure ├── spec-02-01.tokens ├── spec-02-02.structure ├── spec-02-02.tokens ├── spec-02-03.structure ├── spec-02-03.tokens ├── spec-02-04.structure ├── spec-02-04.tokens ├── spec-02-05.structure ├── spec-02-05.tokens ├── spec-02-06.structure ├── spec-02-06.tokens ├── spec-02-07.structure ├── spec-02-07.tokens ├── spec-02-08.structure ├── spec-02-08.tokens ├── spec-02-09.structure ├── spec-02-09.tokens ├── spec-02-10.structure ├── spec-02-10.tokens ├── spec-02-11.structure ├── spec-02-11.tokens ├── spec-02-12.structure ├── spec-02-12.tokens ├── spec-02-13.structure ├── spec-02-13.tokens ├── spec-02-14.structure ├── spec-02-14.tokens ├── spec-02-15.structure ├── spec-02-15.tokens ├── spec-02-16.structure ├── spec-02-16.tokens ├── spec-02-17.structure ├── spec-02-17.tokens ├── spec-02-18.structure ├── spec-02-18.tokens ├── spec-02-19.structure ├── spec-02-19.tokens ├── spec-02-20.structure ├── spec-02-20.tokens ├── spec-02-21.structure ├── spec-02-21.tokens ├── spec-02-22.structure ├── spec-02-22.tokens ├── spec-02-23.structure ├── spec-02-23.tokens ├── spec-02-24.structure ├── spec-02-24.tokens ├── spec-02-25.structure ├── spec-02-25.tokens ├── spec-02-26.structure ├── spec-02-26.tokens ├── spec-02-27.structure ├── spec-02-27.tokens ├── spec-02-28.structure ├── spec-02-28.tokens ├── spec-05-01-utf16be.data ├── spec-05-01-utf16be.empty ├── spec-05-01-utf16le.data ├── spec-05-01-utf16le.empty ├── spec-05-02-utf16be.data ├── spec-05-02-utf16be.error ├── spec-05-02-utf16le.data ├── spec-05-02-utf16le.error ├── str.detect ├── timestamp.detect ├── undefined-constructor.loader-error ├── utf16be.code ├── utf16be.data ├── utf16le.code ├── utf16le.data ├── value.data ├── value.detect ├── yaml.data └── yaml.detect /.editorconfig: -------------------------------------------------------------------------------- 1 | # Cross-editor coding style settings. 2 | # See http://editorconfig.org/ for details. 3 | 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | indent_style = space 9 | indent_size = 2 10 | end_of_line = lf 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | open_collective: puzrin 2 | patreon: puzrin 3 | tidelift: "npm/js-yaml" 4 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | schedule: 7 | - cron: '0 0 * * 3' 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | strategy: 15 | matrix: 16 | node-version: [ '12', '14' ] 17 | 18 | steps: 19 | - uses: actions/checkout@v2 20 | 21 | - name: Use Node.js ${{ matrix.node-version }} 22 | uses: actions/setup-node@v1 23 | with: 24 | node-version: ${{ matrix.node-version }} 25 | 26 | - run: npm install 27 | 28 | - run: npm test 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .nyc_output 2 | coverage 3 | demo 4 | node_modules 5 | doc 6 | benchmark/implementations/* 7 | !/benchmark/implementations/current/ 8 | -------------------------------------------------------------------------------- /benchmark/add-by-tag.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if test $# -eq 0; then 4 | echo "No branch/tag names provided" 5 | exit 1 6 | fi 7 | 8 | root_dir="$(dirname $0)" 9 | 10 | for branch in $@; do 11 | impl_dir="$root_dir/implementations/js-yaml-$branch" 12 | 13 | if test -e "$impl_dir"; then 14 | echo "$impl_dir already exists; skipping" 15 | else 16 | git clone --branch "$branch" --depth 1 https://github.com/nodeca/js-yaml.git "$impl_dir" 17 | fi 18 | done 19 | -------------------------------------------------------------------------------- /benchmark/implementations/current/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = require('../../../'); 4 | -------------------------------------------------------------------------------- /benchmark/profile.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | 4 | 'use strict'; 5 | 6 | var fs = require('fs'); 7 | var path = require('path'); 8 | var yaml = require('../'); 9 | 10 | var data = fs.readFileSync(path.join(__dirname, '/samples/document_nodeca_application.yaml'), 'utf8'); 11 | 12 | for (var i = 0; i < 10000; i++) { 13 | yaml.load(data); 14 | } 15 | -------------------------------------------------------------------------------- /benchmark/samples/document_application2.yaml: -------------------------------------------------------------------------------- 1 | configured: true 2 | applications: 3 | - nodeca.core 4 | - nodeca.users 5 | - nodeca.forum 6 | - nodeca.blogs 7 | locales: 8 | default: en-US 9 | options: 10 | recaptcha: 11 | private_key: 6LdSINcSAAAAABs6duZAvnuN2-PwceqKqZMMFEt2 12 | public_key: 6LdSINcSAAAAAPUJnsQreWd-lT-ILxnoIWwLAepO 13 | bind: 14 | default: 15 | listen: 0.0.0.0:3000 16 | forum: 17 | mount: /forum 18 | 19 | forum.index: 20 | mount: / 21 | 22 | -------------------------------------------------------------------------------- /benchmark/samples/document_nodeca_database.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Database 3 | # 4 | 5 | # we wil have redis and mongo connections, but the keys will be different. 6 | # right now it's just a stub, key names would be someting like 7 | # "documents_backend" (by the nature of DB usage) 8 | 9 | database: 10 | redis: 11 | host: localhost 12 | port: 6379 13 | #index: 1 14 | 15 | mongo: 16 | host: localhost 17 | port: 27017 18 | database: nodeca-dev 19 | #user: mongouser 20 | #password: m0NGoP4$$WORd 21 | -------------------------------------------------------------------------------- /benchmark/samples/document_nodeca_logger.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Logger configuration 3 | # 4 | 5 | logger: 6 | 7 | options: 8 | 9 | # 10 | # Global minimal error level 11 | # 12 | 13 | level: debug 14 | 15 | # 16 | # Appenders options 17 | # 18 | 19 | file: 20 | logSize: 10 # Max MB per log file 21 | backups: 5 # Amount of "old" log files 22 | 23 | # 24 | # Logger categories 25 | # 26 | 27 | system: 28 | - level: debug 29 | file: log/system.log 30 | - level: error 31 | file: log/system-error.log 32 | 33 | bin@: 34 | - level: debug 35 | file: log/static.log 36 | - level: error 37 | file: log/static-error.log 38 | 39 | http@: 40 | - level: debug 41 | file: log/server.log 42 | - level: error 43 | file: log/server-error.log 44 | 45 | rpc@: 46 | - level: debug 47 | file: log/rpc.log 48 | - level: error 49 | file: log/rpc-error.log 50 | 51 | -------------------------------------------------------------------------------- /benchmark/samples/scalar_double_quoted_binary_01.yaml: -------------------------------------------------------------------------------- 1 | "\x28\x72\x5A\xD2\x26\x72\xCD\xBB\x3D\x9B\xB6\x88\x1F\x33\x25\x0C\x19\x7A\x87\xD7\x95\x2D\x22\xB3\x9A\x05\x9A\x26\x49\x37\x71\xF5\x5F\xF4\x80\x9E\xB8\xE9\x81\xDB\xC8\xBE\x87\x23\x22\x99\x82\x2A\xF3\x9A\xBE\x5E\x86\x5E\x63\x6A\xC0\x7E\xF4\xB6\xA3\x0F\xD2\xE3\xCD\x22\xB9\x51\xF7\x43\x3F\x9A\x79\xFD\x5A\x16\xC3\x52\xD9\x58\xE3\x45\xE8\xAD\x04\x52\x8E\xA2\xEB\xF2\x30\x7D\x7A\x1A\x0E\xC0\x30\xBB\xC3\xAC\xA5\x42\xC7\xBA\x0F\x17\xEF\x21\xC1\x1F\xE9\x55\xA9\x3C\xC3\x84\xD0\xCA\x63\x19\xDD\x22\x0E\x3B\x90\x19\xE3\x4D\x48\x80\x5F\x6E\x7F\xA4\xD9\xF9\x4B\xCD\x05\x04\xDE\xC0\x73\xE2\x05\x3F\x0F\xA3\xAA\x86\xA1\x90\x54\xCE\x4D\xB2\xA3\xCC\x12\x4A\xD7\x31\x4C\x59\x48\x2A\x34\x18\xED\xDF\x5D\x7E\xD8\xF5\x37\xBF\xB6\x0E\x8E\xC9\x52\x46\x0A\xC7\x10\xB6\xAE\xA0\x74\xF3\x5B\x77\x9B\x8E\x4C\x2B\xBE\x93\x99\xD6\xB5" 2 | -------------------------------------------------------------------------------- /benchmark/samples/scalar_double_quoted_escaped_01.yaml: -------------------------------------------------------------------------------- 1 | "Lorem nipsum\tdolor sit amet,\nconsectetur adipiscing elit.\u2028Donec a diam lectus. \"Sed sit amet ipsum\" mauris." 2 | -------------------------------------------------------------------------------- /benchmark/samples/scalar_double_quoted_simple_01.yaml: -------------------------------------------------------------------------------- 1 | "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris." 2 | -------------------------------------------------------------------------------- /examples/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | es6: true 3 | 4 | parserOptions: 5 | ecmaVersion: 2020 6 | -------------------------------------------------------------------------------- /examples/custom_types.yml: -------------------------------------------------------------------------------- 1 | subject: Custom types in JS-YAML 2 | spaces: 3 | - !space 4 | height: 1000 5 | width: 1000 6 | points: 7 | - !point [ 10, 43, 23 ] 8 | - !point [ 165, 0, 50 ] 9 | - !point [ 100, 100, 100 ] 10 | 11 | - !space 12 | height: 64 13 | width: 128 14 | points: 15 | - !point [ 12, 43, 0 ] 16 | - !point [ 1, 4, 90 ] 17 | 18 | - !space # An empty space 19 | -------------------------------------------------------------------------------- /examples/dumper.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /*eslint-disable no-console*/ 4 | 5 | var yaml = require('../'); 6 | var object = require('./dumper.json'); 7 | 8 | 9 | console.log(yaml.dump(object, { 10 | flowLevel: 3, 11 | styles: { 12 | '!!int' : 'hexadecimal', 13 | '!!null' : 'camelcase' 14 | } 15 | })); 16 | 17 | 18 | // Output: 19 | //============================================================================== 20 | // name: Wizzard 21 | // level: 0x11 22 | // sanity: Null 23 | // inventory: 24 | // - name: Hat 25 | // features: [magic, pointed] 26 | // traits: {} 27 | // - name: Staff 28 | // features: [] 29 | // traits: {damage: 0xA} 30 | // - name: Cloak 31 | // features: [old] 32 | // traits: {defence: 0x0, comfort: 0x3} 33 | -------------------------------------------------------------------------------- /examples/dumper.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Wizzard", 3 | "level" : 17, 4 | "sanity" : null, 5 | "inventory" : [ 6 | { 7 | "name" : "Hat", 8 | "features" : [ "magic", "pointed" ], 9 | "traits" : {} 10 | }, 11 | { 12 | "name" : "Staff", 13 | "features" : [], 14 | "traits" : { "damage" : 10 } 15 | }, 16 | { 17 | "name" : "Cloak", 18 | "features" : [ "old" ], 19 | "traits" : { "defence" : 0, "comfort" : 3 } 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /examples/sample_document.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /*eslint-disable no-console*/ 4 | 5 | var fs = require('fs'); 6 | var path = require('path'); 7 | var util = require('util'); 8 | var yaml = require('../'); 9 | 10 | 11 | try { 12 | var filename = path.join(__dirname, 'sample_document.yml'), 13 | contents = fs.readFileSync(filename, 'utf8'), 14 | data = yaml.load(contents); 15 | 16 | console.log(util.inspect(data, false, 10, true)); 17 | } catch (err) { 18 | console.log(err.stack || String(err)); 19 | } 20 | -------------------------------------------------------------------------------- /lib/schema/core.js: -------------------------------------------------------------------------------- 1 | // Standard YAML's Core schema. 2 | // http://www.yaml.org/spec/1.2/spec.html#id2804923 3 | // 4 | // NOTE: JS-YAML does not support schema-specific tag resolution restrictions. 5 | // So, Core schema has no distinctions from JSON schema is JS-YAML. 6 | 7 | 8 | 'use strict'; 9 | 10 | 11 | module.exports = require('./json'); 12 | -------------------------------------------------------------------------------- /lib/schema/default.js: -------------------------------------------------------------------------------- 1 | // JS-YAML's default schema for `safeLoad` function. 2 | // It is not described in the YAML specification. 3 | // 4 | // This schema is based on standard YAML's Core schema and includes most of 5 | // extra types described at YAML tag repository. (http://yaml.org/type/) 6 | 7 | 8 | 'use strict'; 9 | 10 | 11 | module.exports = require('./core').extend({ 12 | implicit: [ 13 | require('../type/timestamp'), 14 | require('../type/merge') 15 | ], 16 | explicit: [ 17 | require('../type/binary'), 18 | require('../type/omap'), 19 | require('../type/pairs'), 20 | require('../type/set') 21 | ] 22 | }); 23 | -------------------------------------------------------------------------------- /lib/schema/failsafe.js: -------------------------------------------------------------------------------- 1 | // Standard YAML's Failsafe schema. 2 | // http://www.yaml.org/spec/1.2/spec.html#id2802346 3 | 4 | 5 | 'use strict'; 6 | 7 | 8 | var Schema = require('../schema'); 9 | 10 | 11 | module.exports = new Schema({ 12 | explicit: [ 13 | require('../type/str'), 14 | require('../type/seq'), 15 | require('../type/map') 16 | ] 17 | }); 18 | -------------------------------------------------------------------------------- /lib/schema/json.js: -------------------------------------------------------------------------------- 1 | // Standard YAML's JSON schema. 2 | // http://www.yaml.org/spec/1.2/spec.html#id2803231 3 | // 4 | // NOTE: JS-YAML does not support schema-specific tag resolution restrictions. 5 | // So, this schema is not such strict as defined in the YAML specification. 6 | // It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc. 7 | 8 | 9 | 'use strict'; 10 | 11 | 12 | module.exports = require('./failsafe').extend({ 13 | implicit: [ 14 | require('../type/null'), 15 | require('../type/bool'), 16 | require('../type/int'), 17 | require('../type/float') 18 | ] 19 | }); 20 | -------------------------------------------------------------------------------- /lib/type/bool.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Type = require('../type'); 4 | 5 | function resolveYamlBoolean(data) { 6 | if (data === null) return false; 7 | 8 | var max = data.length; 9 | 10 | return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || 11 | (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); 12 | } 13 | 14 | function constructYamlBoolean(data) { 15 | return data === 'true' || 16 | data === 'True' || 17 | data === 'TRUE'; 18 | } 19 | 20 | function isBoolean(object) { 21 | return Object.prototype.toString.call(object) === '[object Boolean]'; 22 | } 23 | 24 | module.exports = new Type('tag:yaml.org,2002:bool', { 25 | kind: 'scalar', 26 | resolve: resolveYamlBoolean, 27 | construct: constructYamlBoolean, 28 | predicate: isBoolean, 29 | represent: { 30 | lowercase: function (object) { return object ? 'true' : 'false'; }, 31 | uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, 32 | camelcase: function (object) { return object ? 'True' : 'False'; } 33 | }, 34 | defaultStyle: 'lowercase' 35 | }); 36 | -------------------------------------------------------------------------------- /lib/type/map.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Type = require('../type'); 4 | 5 | module.exports = new Type('tag:yaml.org,2002:map', { 6 | kind: 'mapping', 7 | construct: function (data) { return data !== null ? data : {}; } 8 | }); 9 | -------------------------------------------------------------------------------- /lib/type/merge.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Type = require('../type'); 4 | 5 | function resolveYamlMerge(data) { 6 | return data === '<<' || data === null; 7 | } 8 | 9 | module.exports = new Type('tag:yaml.org,2002:merge', { 10 | kind: 'scalar', 11 | resolve: resolveYamlMerge 12 | }); 13 | -------------------------------------------------------------------------------- /lib/type/null.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Type = require('../type'); 4 | 5 | function resolveYamlNull(data) { 6 | if (data === null) return true; 7 | 8 | var max = data.length; 9 | 10 | return (max === 1 && data === '~') || 11 | (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); 12 | } 13 | 14 | function constructYamlNull() { 15 | return null; 16 | } 17 | 18 | function isNull(object) { 19 | return object === null; 20 | } 21 | 22 | module.exports = new Type('tag:yaml.org,2002:null', { 23 | kind: 'scalar', 24 | resolve: resolveYamlNull, 25 | construct: constructYamlNull, 26 | predicate: isNull, 27 | represent: { 28 | canonical: function () { return '~'; }, 29 | lowercase: function () { return 'null'; }, 30 | uppercase: function () { return 'NULL'; }, 31 | camelcase: function () { return 'Null'; }, 32 | empty: function () { return ''; } 33 | }, 34 | defaultStyle: 'lowercase' 35 | }); 36 | -------------------------------------------------------------------------------- /lib/type/seq.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Type = require('../type'); 4 | 5 | module.exports = new Type('tag:yaml.org,2002:seq', { 6 | kind: 'sequence', 7 | construct: function (data) { return data !== null ? data : []; } 8 | }); 9 | -------------------------------------------------------------------------------- /lib/type/set.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Type = require('../type'); 4 | 5 | var _hasOwnProperty = Object.prototype.hasOwnProperty; 6 | 7 | function resolveYamlSet(data) { 8 | if (data === null) return true; 9 | 10 | var key, object = data; 11 | 12 | for (key in object) { 13 | if (_hasOwnProperty.call(object, key)) { 14 | if (object[key] !== null) return false; 15 | } 16 | } 17 | 18 | return true; 19 | } 20 | 21 | function constructYamlSet(data) { 22 | return data !== null ? data : {}; 23 | } 24 | 25 | module.exports = new Type('tag:yaml.org,2002:set', { 26 | kind: 'mapping', 27 | resolve: resolveYamlSet, 28 | construct: constructYamlSet 29 | }); 30 | -------------------------------------------------------------------------------- /lib/type/str.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Type = require('../type'); 4 | 5 | module.exports = new Type('tag:yaml.org,2002:str', { 6 | kind: 'scalar', 7 | construct: function (data) { return data !== null ? data : ''; } 8 | }); 9 | -------------------------------------------------------------------------------- /support/build_demo.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | 'use strict'; 4 | 5 | /* eslint-env es6 */ 6 | 7 | const shell = require('shelljs'); 8 | 9 | shell.rm('-rf', 'demo'); 10 | shell.mkdir('demo'); 11 | 12 | shell.exec('node_modules/.bin/rollup -c support/demo_template/rollup.config.js'); 13 | 14 | shell.cp('support/demo_template/index.html', 'demo/'); 15 | shell.cp('support/demo_template/demo.css', 'demo/'); 16 | shell.cp('node_modules/codemirror/lib/codemirror.css', 'demo/'); 17 | -------------------------------------------------------------------------------- /support/demo_template/rollup.config.js: -------------------------------------------------------------------------------- 1 | import nodeResolve from '@rollup/plugin-node-resolve'; 2 | import commonjs from '@rollup/plugin-commonjs'; 3 | import nodePolyfills from 'rollup-plugin-node-polyfills'; 4 | 5 | export default [ 6 | { 7 | input: 'support/demo_template/demo.js', 8 | output: { file: 'demo/demo.js', format: 'iife', name: 'demo' }, 9 | plugins: [ 10 | nodePolyfills(), 11 | nodeResolve(), 12 | commonjs() 13 | ] 14 | } 15 | ]; 16 | -------------------------------------------------------------------------------- /support/rollup.config.js: -------------------------------------------------------------------------------- 1 | import nodeResolve from '@rollup/plugin-node-resolve'; 2 | import commonjs from '@rollup/plugin-commonjs'; 3 | import pkg from '../package.json'; 4 | import { terser } from 'rollup-plugin-terser'; 5 | 6 | const banner = { 7 | banner() { 8 | return `/*! ${pkg.name} ${pkg.version} https://github.com/${pkg.repository} @license ${pkg.license} */`; 9 | } 10 | } 11 | 12 | const plugins = [ nodeResolve(), commonjs(), banner ]; 13 | 14 | const umd_out_base = { format: 'umd', name: 'jsyaml', exports: 'named' }; 15 | 16 | export default [ 17 | // es5 18 | { 19 | input: 'index.js', 20 | output: [ 21 | { ...umd_out_base, file: 'dist/js-yaml.js' }, 22 | { ...umd_out_base, file: 'dist/js-yaml.min.js', plugins: [ terser() ] } 23 | ], 24 | plugins 25 | }, 26 | // esm 27 | { 28 | input: 'index.js', 29 | output: [ 30 | { format: 'esm', file: 'dist/js-yaml.mjs' }, 31 | ], 32 | plugins 33 | } 34 | ]; 35 | -------------------------------------------------------------------------------- /test/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | node: true 3 | mocha: true 4 | es6: true 5 | 6 | parserOptions: 7 | ecmaVersion: 2020 8 | 9 | rules: 10 | no-undefined: 0 11 | -------------------------------------------------------------------------------- /test/00-units.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var path = require('path'); 5 | var fs = require('fs'); 6 | 7 | 8 | describe('Units', function () { 9 | var directory = path.resolve(__dirname, 'units'); 10 | 11 | fs.readdirSync(directory).forEach(function (file) { 12 | if (path.extname(file) === '.js') { 13 | require(path.resolve(directory, file)); 14 | } 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /test/11-load-errors.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var path = require('path'); 6 | var fs = require('fs'); 7 | var yaml = require('../'); 8 | 9 | var TEST_SCHEMA = require('./support/schema').TEST_SCHEMA; 10 | 11 | 12 | describe('Load errors', function () { 13 | var samplesDir = path.resolve(__dirname, 'samples-load-errors'); 14 | 15 | fs.readdirSync(samplesDir).forEach(function (sampleName) { 16 | var yamlFile = path.resolve(samplesDir, sampleName); 17 | 18 | it(path.basename(sampleName, '.yml'), function () { 19 | var yamlSource = fs.readFileSync(yamlFile, { encoding: 'utf8' }); 20 | 21 | assert.throws(function () { 22 | yaml.loadAll( 23 | yamlSource, 24 | function () {}, 25 | { 26 | filename: yamlFile, 27 | schema: TEST_SCHEMA, 28 | onWarning: function (e) { throw e; } 29 | } 30 | ); 31 | }, yaml.YAMLException, yamlFile); 32 | }); 33 | }); 34 | }); 35 | -------------------------------------------------------------------------------- /test/20-dumper.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var path = require('path'); 6 | var fs = require('fs'); 7 | var yaml = require('../'); 8 | 9 | var TEST_SCHEMA = require('./support/schema').TEST_SCHEMA; 10 | 11 | 12 | describe('Dumper', function () { 13 | var samplesDir = path.resolve(__dirname, 'samples-common'); 14 | 15 | fs.readdirSync(samplesDir).forEach(function (jsFile) { 16 | if (path.extname(jsFile) !== '.js') return; // continue 17 | 18 | it(path.basename(jsFile, '.js'), function () { 19 | var sample = require(path.resolve(samplesDir, jsFile)); 20 | var data = typeof sample === 'function' ? sample.expected : sample, 21 | serialized = yaml.dump(data, { schema: TEST_SCHEMA }), 22 | deserialized = yaml.load(serialized, { schema: TEST_SCHEMA }); 23 | 24 | if (typeof sample === 'function') { 25 | sample.call(this, deserialized); 26 | } else { 27 | assert.deepStrictEqual(deserialized, sample); 28 | } 29 | }); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /test/30-issues.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var path = require('path'); 5 | var fs = require('fs'); 6 | 7 | 8 | describe('Issues', function () { 9 | var issues = path.resolve(__dirname, 'issues'); 10 | 11 | fs.readdirSync(issues).forEach(function (file) { 12 | if (path.extname(file) === '.js') { 13 | require(path.resolve(issues, file)); 14 | } 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /test/issues/0008.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Parse failed when no document start present', function () { 9 | assert.doesNotThrow(function () { 10 | yaml.load(` 11 | foo: !!str bar 12 | `); 13 | }, TypeError); 14 | }); 15 | -------------------------------------------------------------------------------- /test/issues/0017.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Non-specific "!" tags should resolve to !!str', function () { 9 | var data = yaml.load(` 10 | ! 12 11 | `); 12 | 13 | assert.strictEqual(typeof data, 'string'); 14 | }); 15 | -------------------------------------------------------------------------------- /test/issues/0019.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Timestamp parsing is one month off', function () { 9 | var data = yaml.load(` 10 | --- 11 | xmas: 2011-12-24 12 | ... 13 | `); 14 | 15 | // JS month starts with 0 (0 => Jan, 1 => Feb, ...) 16 | assert.strictEqual(data.xmas.getTime(), Date.UTC(2011, 11, 24)); 17 | }); 18 | -------------------------------------------------------------------------------- /test/issues/0026.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('should convert new line into white space', function () { 9 | var data = yaml.load(` 10 | test: > 11 | a 12 | b 13 | c 14 | `); 15 | 16 | assert.strictEqual(data.test, 'a b c\n'); 17 | }); 18 | -------------------------------------------------------------------------------- /test/issues/0033.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('refactor compact variant of MarkedYAMLError.toString', function () { 9 | var source = ` 10 | foo: {bar} baz 11 | `; 12 | 13 | assert.throws(function () { 14 | yaml.load(source); 15 | }, "require('issue-33.yml') should throw, but it does not"); 16 | }); 17 | -------------------------------------------------------------------------------- /test/issues/0063.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Invalid errors/warnings of invalid indentation on flow scalars', function () { 9 | var sources = [ 10 | 'text:\n hello\n world', // plain style 11 | "text:\n 'hello\n world'", // single-quoted style 12 | 'text:\n "hello\n world"' // double-quoted style 13 | ]; 14 | var expected = { text: 'hello world' }; 15 | 16 | assert.doesNotThrow(function () { yaml.load(sources[0]); }, 'Throws on plain style'); 17 | assert.doesNotThrow(function () { yaml.load(sources[1]); }, 'Throws on single-quoted style'); 18 | assert.doesNotThrow(function () { yaml.load(sources[2]); }, 'Throws on double-quoted style'); 19 | 20 | assert.deepStrictEqual(yaml.load(sources[0]), expected); 21 | assert.deepStrictEqual(yaml.load(sources[1]), expected); 22 | assert.deepStrictEqual(yaml.load(sources[2]), expected); 23 | }); 24 | -------------------------------------------------------------------------------- /test/issues/0064.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | var readFileSync = require('fs').readFileSync; 7 | 8 | 9 | it('Wrong error message when yaml file contains tabs', function () { 10 | assert.doesNotThrow( 11 | function () { yaml.load(readFileSync(require('path').join(__dirname, '/0064.yml'), 'utf8')); }, 12 | yaml.YAMLException); 13 | }); 14 | -------------------------------------------------------------------------------- /test/issues/0064.yml: -------------------------------------------------------------------------------- 1 | mapping: contains tab 2 | -------------------------------------------------------------------------------- /test/issues/0068.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Prevent adding unnecessary space character to end of a line within block collections', function () { 9 | assert.strictEqual(yaml.dump({ data: [ 'foo', 'bar', 'baz' ] }), 'data:\n - foo\n - bar\n - baz\n'); 10 | assert.strictEqual(yaml.dump({ foo: { bar: [ 'baz' ] } }), 'foo:\n bar:\n - baz\n'); 11 | }); 12 | -------------------------------------------------------------------------------- /test/issues/0085.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | var DEPRECATED_BOOLEANS_SYNTAX = [ 9 | 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', 10 | 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' 11 | ]; 12 | 13 | 14 | it('Dumper should take into account booleans syntax from YAML 1.0/1.1', function () { 15 | DEPRECATED_BOOLEANS_SYNTAX.forEach(function (string) { 16 | var dump = yaml.dump(string).trim(); 17 | 18 | assert( 19 | ((dump === "'" + string + "'") || (dump === '"' + string + '"')), 20 | ('"' + string + '" string is dumped without quoting; actual dump: ' + dump) 21 | ); 22 | }); 23 | }); 24 | 25 | -------------------------------------------------------------------------------- /test/issues/0092.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Invalid parse error on whitespace between quoted scalar keys and ":" symbol in mappings', function () { 9 | assert.doesNotThrow(function () { 10 | yaml.load('{ "field1" : "v1", "field2": "v2" }'); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /test/issues/0093.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Unwanted line breaks in folded scalars', function () { 9 | var data = yaml.load(` 10 | first: > 11 | a 12 | b 13 | c 14 | d 15 | e 16 | f 17 | 18 | second: > 19 | a 20 | b 21 | c 22 | 23 | d 24 | e 25 | f 26 | 27 | third: > 28 | a 29 | b 30 | 31 | c 32 | d 33 | e 34 | f 35 | `); 36 | 37 | assert.strictEqual(data.first, 'a b\n c\n d\ne f\n'); 38 | assert.strictEqual(data.second, 'a b\n c\n\n d\ne f\n'); 39 | assert.strictEqual(data.third, 'a b\n\n c\n d\ne f\n'); 40 | }); 41 | -------------------------------------------------------------------------------- /test/issues/0095.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Empty block scalars loaded wrong', function () { 9 | assert.deepStrictEqual(yaml.load('a: |\nb: .'), { a: '', b: '.' }); 10 | assert.deepStrictEqual(yaml.load('a: |+\nb: .'), { a: '', b: '.' }); 11 | assert.deepStrictEqual(yaml.load('a: |-\nb: .'), { a: '', b: '.' }); 12 | 13 | assert.deepStrictEqual(yaml.load('a: >\nb: .'), { a: '', b: '.' }); 14 | assert.deepStrictEqual(yaml.load('a: >+\nb: .'), { a: '', b: '.' }); 15 | assert.deepStrictEqual(yaml.load('a: >-\nb: .'), { a: '', b: '.' }); 16 | 17 | assert.deepStrictEqual(yaml.load('a: |\n\nb: .'), { a: '', b: '.' }); 18 | assert.deepStrictEqual(yaml.load('a: |+\n\nb: .'), { a: '\n', b: '.' }); 19 | assert.deepStrictEqual(yaml.load('a: |-\n\nb: .'), { a: '', b: '.' }); 20 | 21 | assert.deepStrictEqual(yaml.load('a: >\n\nb: .'), { a: '', b: '.' }); 22 | assert.deepStrictEqual(yaml.load('a: >+\n\nb: .'), { a: '\n', b: '.' }); 23 | assert.deepStrictEqual(yaml.load('a: >-\n\nb: .'), { a: '', b: '.' }); 24 | }); 25 | -------------------------------------------------------------------------------- /test/issues/0108.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Literal scalars have an unwanted leading line break', function () { 9 | assert.strictEqual(yaml.load('|\n foobar\n'), 'foobar\n'); 10 | assert.strictEqual(yaml.load('|\n hello\n world\n'), 'hello\nworld\n'); 11 | assert.strictEqual(yaml.load('|\n war never changes\n'), 'war never changes\n'); 12 | }); 13 | -------------------------------------------------------------------------------- /test/issues/0110.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Circular and cross references', function () { 9 | var source = { 10 | a: { a: 1 }, 11 | b: [ 1, 2 ], 12 | c: {}, 13 | d: [] 14 | }; 15 | source.crossObject = source.a; 16 | source.crossArray = source.b; 17 | source.c.circularObject = source; 18 | source.d.push(source.d); 19 | source.d.push(source); 20 | 21 | var obtained = yaml.load(yaml.dump(source)); 22 | 23 | assert.strictEqual(obtained.crossObject, obtained.a); 24 | assert.strictEqual(obtained.crossArray, obtained.b); 25 | assert.strictEqual(obtained.c.circularObject, obtained); 26 | assert.strictEqual(obtained.d[0], obtained.d); 27 | assert.strictEqual(obtained.d[1], obtained); 28 | }); 29 | -------------------------------------------------------------------------------- /test/issues/0112.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Plain scalar "constructor" parsed as `null`', function () { 9 | assert.strictEqual(yaml.load('constructor'), 'constructor'); 10 | assert.deepStrictEqual(yaml.load('constructor: value'), { constructor: 'value' }); 11 | assert.deepStrictEqual(yaml.load('key: constructor'), { key: 'constructor' }); 12 | assert.deepStrictEqual(yaml.load('{ constructor: value }'), { constructor: 'value' }); 13 | assert.deepStrictEqual(yaml.load('{ key: constructor }'), { key: 'constructor' }); 14 | }); 15 | -------------------------------------------------------------------------------- /test/issues/0117.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Negative zero loses the sign after dump', function () { 9 | assert.strictEqual(yaml.dump(-0), '-0.0\n'); 10 | }); 11 | -------------------------------------------------------------------------------- /test/issues/0144.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Infinite loop when attempting to parse multi-line scalar document that is not indented', function () { 9 | assert.strictEqual(yaml.load('--- |\nfoo\n'), 'foo\n'); 10 | }); 11 | -------------------------------------------------------------------------------- /test/issues/0154.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Indentation warning on empty lines within quoted scalars and flow collections', function () { 9 | assert.doesNotThrow(function () { yaml.load("- 'hello\n\n world'"); }); 10 | assert.doesNotThrow(function () { yaml.load('- "hello\n\n world"'); }); 11 | assert.doesNotThrow(function () { yaml.load('- [hello,\n\n world]'); }); 12 | assert.doesNotThrow(function () { yaml.load('- {hello: world,\n\n foo: bar}'); }); 13 | }); 14 | -------------------------------------------------------------------------------- /test/issues/0155.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Named null', function () { 9 | assert.deepStrictEqual(yaml.load('---\ntest: !!null \nfoo: bar'), { test: null, foo: 'bar' }); 10 | }); 11 | -------------------------------------------------------------------------------- /test/issues/0156.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | function SuccessSignal() {} 9 | 10 | var TestClassYaml = new yaml.Type('!test', { 11 | kind: 'scalar', 12 | resolve: function () { throw new SuccessSignal(); } 13 | }); 14 | 15 | var TEST_SCHEMA = yaml.DEFAULT_SCHEMA.extend([ TestClassYaml ]); 16 | 17 | 18 | it('Resolving of empty nodes are skipped in some cases', function () { 19 | assert.throws(function () { yaml.load('- foo: !test\n- bar: baz', { schema: TEST_SCHEMA }); }, SuccessSignal); 20 | }); 21 | -------------------------------------------------------------------------------- /test/issues/0160.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Correct encoding of UTF-16 surrogate pairs', function () { 9 | assert.strictEqual(yaml.load('"\\U0001F431"'), '🐱'); 10 | }); 11 | -------------------------------------------------------------------------------- /test/issues/0164.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | const assert = require('assert'); 5 | const yaml = require('../../'); 6 | 7 | 8 | it('should define __proto__ as a value (not invoke setter)', function () { 9 | let object = yaml.load('{ __proto__: {foo: bar} }'); 10 | 11 | assert.strictEqual(({}).hasOwnProperty.call(yaml.load('{}'), '__proto__'), false); 12 | assert.strictEqual(({}).hasOwnProperty.call(object, '__proto__'), true); 13 | assert(!object.foo); 14 | }); 15 | -------------------------------------------------------------------------------- /test/issues/0194.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Don\'t throw on warning', function () { 9 | var src = ` 10 | foo: { 11 | bar: true 12 | } 13 | `; 14 | var warnings = [], 15 | data; 16 | 17 | data = yaml.load(src); 18 | 19 | assert.deepStrictEqual(data, { foo: { bar: true } }); 20 | 21 | yaml.load(src, { onWarning: function (e) { warnings.push(e); } }); 22 | 23 | assert.strictEqual(warnings.length, 1); 24 | }); 25 | -------------------------------------------------------------------------------- /test/issues/0203.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Don\'t throw on warning', function () { 9 | var src = ` 10 | test: |- 11 | 12 | 13 | Hello 14 | world 15 | `; 16 | 17 | assert.deepStrictEqual(yaml.load(src), { test: '\n\nHello\nworld' }); 18 | }); 19 | -------------------------------------------------------------------------------- /test/issues/0205.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Duplicated objects within array', function () { 9 | var obj = { test: 'canary' }; 10 | var arrayWithRefs = [ obj, obj ]; 11 | 12 | var obtained = yaml.load(yaml.dump(arrayWithRefs)); 13 | 14 | assert.strictEqual(obtained[0].test, 'canary'); 15 | assert.strictEqual(obtained[0], obtained[1]); 16 | }); 17 | 18 | it('Duplicated arrays within array', function () { 19 | var array = [ 0, 1 ]; 20 | var arrayWithRefs = [ array, array ]; 21 | 22 | var obtained = yaml.load(yaml.dump(arrayWithRefs)); 23 | 24 | assert.strictEqual(obtained[0][0], 0); 25 | assert.strictEqual(obtained[0][1], 1); 26 | assert.strictEqual(obtained[0], obtained[1]); 27 | }); 28 | -------------------------------------------------------------------------------- /test/issues/0220.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Float type dumper should not miss dot', function () { 9 | assert.strictEqual(5e-100.toString(10), '5e-100'); 10 | assert.strictEqual(0.5e-100.toString(10), '5e-101'); 11 | 12 | assert.strictEqual(yaml.dump(0.5e-100), '5.e-101\n'); 13 | assert.strictEqual(yaml.load(yaml.dump(5e-100)), 5e-100); 14 | }); 15 | -------------------------------------------------------------------------------- /test/issues/0221.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it.skip('Block scalar chomping does not work on zero indent', function () { 9 | assert.throws(function () { yaml.load('|-\nfoo\nbar'); }, yaml.YAMLException); 10 | assert.deepStrictEqual(yaml.dump('foo\nbar'), '|-\n foo\nbar'); 11 | }); 12 | -------------------------------------------------------------------------------- /test/issues/0235.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var assert = require('assert'); 4 | var yaml = require('../../'); 5 | 6 | it('Flow style does not dump with block literals.', function () { 7 | assert.strictEqual(yaml.dump({ a: '\n' }, { flowLevel: 0 }), '{a: "\\n"}\n'); 8 | }); 9 | 10 | it('Ok to dump block-style literals when not yet flowing.', function () { 11 | // cf. example 8.6 from the YAML 1.2 spec 12 | assert.strictEqual(yaml.dump({ a: '\n' }, { flowLevel: 2 }), 'a: |+\n\n'); 13 | }); 14 | -------------------------------------------------------------------------------- /test/issues/0243-basic.yml: -------------------------------------------------------------------------------- 1 | a: 2 | b: 1 3 | c: 2 4 | d: 5 | e: 3 6 | f: 4 7 | duplicate: # 1 8 | id: 1234 9 | note: "this is the first one, so it won't raise an error" 10 | duplicate: # 2 11 | id: 5678 12 | note: "this is the second one, so it will raise an error, hopefully at the start of the key" 13 | g: 14 | h: 5 15 | i: 6 16 | -------------------------------------------------------------------------------- /test/issues/0243-nested.yml: -------------------------------------------------------------------------------- 1 | a: 2 | b: 1 3 | c: 2 4 | d: 5 | e: 3 6 | f: 4 7 | duplicate: # 1 8 | id: 1234 9 | note: "this is the first one, so it won't raise an error" 10 | duplicate: # 2 11 | id: 5678 12 | note: "this is the second one, so it will raise an error, hopefully at the start of the key" 13 | g: 14 | h: 5 15 | i: 6 16 | -------------------------------------------------------------------------------- /test/issues/0258.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | const assert = require('assert'); 5 | const yaml = require('../../'); 6 | 7 | 8 | it('should shorthand tags with !! whenever possible', function () { 9 | let regexp = new yaml.Type('tag:yaml.org,2002:js/regexp', { 10 | kind: 'scalar', 11 | resolve: () => true, 12 | construct: str => new RegExp(str), 13 | instanceOf: RegExp, 14 | represent: object => object.source 15 | }); 16 | 17 | let schema = yaml.DEFAULT_SCHEMA.extend(regexp); 18 | 19 | let source = 're: !!js/regexp .*\n'; 20 | 21 | let object = yaml.load(source, { schema }); 22 | assert(object.re instanceof RegExp); 23 | 24 | let str = yaml.dump(object, { schema }); 25 | assert.strictEqual(str, source); 26 | }); 27 | -------------------------------------------------------------------------------- /test/issues/0266.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | var DEPRECATED_BOOLEANS_SYNTAX = [ 9 | 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', 10 | 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' 11 | ]; 12 | 13 | 14 | it('Dumper should not take into account booleans syntax from YAML 1.0/1.1 in noCompatMode', function () { 15 | DEPRECATED_BOOLEANS_SYNTAX.forEach(function (string) { 16 | var dump = yaml.dump(string, { noCompatMode: true }).trim(); 17 | 18 | assert( 19 | (dump === string), 20 | ('"' + string + '" string is not dumped as-is; actual dump: ' + dump) 21 | ); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /test/issues/0301.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | const assert = require('assert'); 5 | const yaml = require('../../'); 6 | 7 | 8 | it('should assign anchor to an empty node', function () { 9 | assert.deepStrictEqual( 10 | yaml.load('foo: &a\nbar: *a\n'), 11 | { foo: null, bar: null } 12 | ); 13 | 14 | assert.deepStrictEqual( 15 | yaml.load('{ foo: &a, bar: *a }'), 16 | { foo: null, bar: null } 17 | ); 18 | 19 | assert.deepStrictEqual( 20 | yaml.load('- &a\n- *a\n'), 21 | [ null, null ] 22 | ); 23 | 24 | assert.deepStrictEqual( 25 | yaml.load('[ &a, *a ]'), 26 | [ null, null ] 27 | ); 28 | }); 29 | -------------------------------------------------------------------------------- /test/issues/0303.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var assert = require('assert'); 4 | var yaml = require('../../'); 5 | 6 | it('Loader should not strip quotes before newlines', function () { 7 | var with_space = yaml.load("'''foo'' '"); 8 | var with_newline = yaml.load("'''foo''\n'"); 9 | assert.strictEqual(with_space, "'foo' "); 10 | assert.strictEqual(with_newline, "'foo' "); 11 | }); 12 | -------------------------------------------------------------------------------- /test/issues/0321.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | const assert = require('assert'); 5 | const yaml = require('../../'); 6 | 7 | 8 | it('Should throw exception on extra comma in flow mappings', function () { 9 | assert.throws(function () { 10 | yaml.load('[foo, bar,, baz]'); 11 | }, /expected the node content, but found ','/); 12 | 13 | assert.throws(function () { 14 | yaml.load('{foo, bar,, baz}'); 15 | }, /expected the node content, but found ','/); 16 | 17 | // empty key is allowed here 18 | assert.deepStrictEqual(yaml.load('{foo,: bar}'), { foo: null, null: 'bar' }); 19 | }); 20 | -------------------------------------------------------------------------------- /test/issues/0332.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | const assert = require('assert'); 5 | const yaml = require('../../'); 6 | 7 | 8 | it('Should format errors', function () { 9 | try { 10 | yaml.load('"foo\u0001bar"'); 11 | } catch (err) { 12 | assert.strictEqual(err.toString(true), 'YAMLException: expected valid JSON character (1:9)'); 13 | assert.strictEqual(err.toString(false), `YAMLException: expected valid JSON character (1:9) 14 | 15 | 1 | "foo\u0001bar" 16 | -------------^`); 17 | } 18 | 19 | try { 20 | yaml.load('*'); 21 | } catch (err) { 22 | assert.strictEqual(err.toString(), `YAMLException: name of an alias node must contain at least one character (1:2) 23 | 24 | 1 | * 25 | ------^`); 26 | } 27 | 28 | try { 29 | yaml.load('foo:\n bar: 1\na'); 30 | } catch (err) { 31 | // eslint-disable-next-line max-len 32 | assert.strictEqual(err.toString(), `YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key (4:1) 33 | 34 | 1 | foo: 35 | 2 | bar: 1 36 | 3 | a 37 | 4 | 38 | -----^`); 39 | } 40 | }); 41 | -------------------------------------------------------------------------------- /test/issues/0333.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('should allow cast integers as !!float', function () { 9 | var data = yaml.load(` 10 | negative: !!float -1 11 | zero: !!float 0 12 | positive: !!float 2.3e4 13 | `); 14 | 15 | assert.deepStrictEqual(data, { 16 | negative: -1, 17 | zero: 0, 18 | positive: 23000 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /test/issues/0335.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Don\'t throw on warning', function () { 9 | var src = ` 10 | not_num_1: -_123 11 | not_num_2: _123 12 | not_num_3: 123_ 13 | not_num_4: 0b00_ 14 | not_num_5: 0x00_ 15 | not_num_6: 011_ 16 | `; 17 | 18 | assert.deepStrictEqual(yaml.load(src), { 19 | not_num_1: '-_123', 20 | not_num_2: '_123', 21 | not_num_3: '123_', 22 | not_num_4: '0b00_', 23 | not_num_5: '0x00_', 24 | not_num_6: '011_' 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /test/issues/0346.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var assert = require('assert'); 4 | var yaml = require('../../'); 5 | 6 | 7 | it('should not emit spaces in arrays in flow mode between entries using condenseFlow: true', function () { 8 | var array = [ 'a', 'b' ]; 9 | var dumpedArray = yaml.dump(array, { flowLevel: 0, indent: 0, condenseFlow: true }); 10 | assert.strictEqual( 11 | dumpedArray, 12 | '[a,b]\n' 13 | ); 14 | assert.deepStrictEqual(yaml.load(dumpedArray), array); 15 | }); 16 | 17 | it('should not emit spaces between key: value and quote keys using condenseFlow: true', function () { 18 | var object = { a: { b: 'c', d: 'e' } }; 19 | var objectDump = yaml.dump(object, { flowLevel: 0, indent: 0, condenseFlow: true }); 20 | assert.strictEqual( 21 | objectDump, 22 | '{"a":{"b":c, "d":e}}\n' 23 | ); 24 | assert.deepStrictEqual(yaml.load(objectDump), object); 25 | }); 26 | -------------------------------------------------------------------------------- /test/issues/0350.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('should return parse docs from loadAll', function () { 9 | var data = yaml.loadAll(` 10 | --- 11 | a: 1 12 | --- 13 | b: 2 14 | `); 15 | 16 | assert.deepStrictEqual(data, [ { a: 1 }, { b: 2 } ]); 17 | }); 18 | -------------------------------------------------------------------------------- /test/issues/0351.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../..'); 6 | 7 | 8 | it('should include the error message in the error stack', function () { 9 | try { 10 | yaml.load(` 11 | # intentionally invalid yaml 12 | 13 | foo: bar 14 | baz: qux 15 | `); 16 | } catch (err) { 17 | assert(err.stack.startsWith('YAMLException: end of the stream or a document separator is expected')); 18 | return; 19 | } 20 | assert.fail(null, null, 'Expected an error to be thrown'); 21 | }); 22 | -------------------------------------------------------------------------------- /test/issues/0399.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('should properly dump negative ints in different styles', function () { 9 | var dump, src = { integer: -100 }; 10 | 11 | dump = yaml.dump(src, { styles: { '!!int': 'binary' } }); 12 | assert.deepStrictEqual(yaml.load(dump), src); 13 | 14 | dump = yaml.dump(src, { styles: { '!!int': 'octal' } }); 15 | assert.deepStrictEqual(yaml.load(dump), src); 16 | 17 | dump = yaml.dump(src, { styles: { '!!int': 'hex' } }); 18 | assert.deepStrictEqual(yaml.load(dump), src); 19 | }); 20 | -------------------------------------------------------------------------------- /test/issues/0403.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('should properly dump leading newlines and spaces', function () { 9 | var dump, src; 10 | 11 | src = { str: '\n a\nb' }; 12 | dump = yaml.dump(src); 13 | assert.deepStrictEqual(yaml.load(dump), src); 14 | 15 | src = { str: '\n\n a\nb' }; 16 | dump = yaml.dump(src); 17 | assert.deepStrictEqual(yaml.load(dump), src); 18 | 19 | src = { str: '\n a\nb' }; 20 | dump = yaml.dump(src, { indent: 10 }); 21 | assert.deepStrictEqual(yaml.load(dump), src); 22 | }); 23 | -------------------------------------------------------------------------------- /test/issues/0418.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | const assert = require('assert'); 5 | const yaml = require('../../'); 6 | 7 | 8 | it('should error on invalid indentation in mappings', function () { 9 | assert.throws(() => yaml.load('foo: "1" bar: "2"'), /bad indentation of a mapping entry/); 10 | assert.throws(() => yaml.load('- "foo" - "bar"'), /bad indentation of a sequence entry/); 11 | }); 12 | -------------------------------------------------------------------------------- /test/issues/0432.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('should indent arrays an extra level by default', function () { 9 | var output = yaml.dump({ array: [ 'a', 'b' ] }); 10 | var expected = 'array:\n - a\n - b\n'; 11 | assert.strictEqual(output, expected); 12 | }); 13 | 14 | it('should not indent arrays an extra level when disabled', function () { 15 | var output = yaml.dump({ array: [ 'a', 'b' ] }, { noArrayIndent: true }); 16 | var expected = 'array:\n- a\n- b\n'; 17 | assert.strictEqual(output, expected); 18 | }); 19 | 20 | it('should always indent nested arrays', function () { 21 | var output = yaml.dump({ array: [ 'a', [ 'b', 'c' ], 'd' ] }, { noArrayIndent: true }); 22 | var expected = 'array:\n- a\n- - b\n - c\n- d\n'; 23 | assert.strictEqual(output, expected); 24 | }); 25 | -------------------------------------------------------------------------------- /test/issues/0468.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../..'); 6 | 7 | it('should not indent arrays an extra level when disabled', function () { 8 | /* eslint-disable max-len */ 9 | var output = yaml.dump( 10 | [ 11 | { 12 | a: 'a_val', 13 | b: 'b_val' 14 | }, 15 | { 16 | a: 'a2_val', 17 | items: [ 18 | { 19 | a: 'a_a_val', 20 | b: 'a_b_val' 21 | } 22 | ] 23 | } 24 | ], 25 | { noArrayIndent: true } 26 | ); 27 | var expected = '- a: a_val\n b: b_val\n- a: a2_val\n items:\n - a: a_a_val\n b: a_b_val\n'; 28 | assert.strictEqual(output, expected); 29 | }); 30 | -------------------------------------------------------------------------------- /test/issues/0470.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Don\'t quote strings with : without need', function () { 9 | var data = { 10 | // no quotes needed 11 | 'http://example.com': 'http://example.com', 12 | // quotes required 13 | 'foo: bar': 'foo: bar', 14 | 'foo:': 'foo:' 15 | }; 16 | 17 | var expected = ` 18 | http://example.com: http://example.com 19 | 'foo: bar': 'foo: bar' 20 | 'foo:': 'foo:' 21 | `.replace(/^\n/, ''); 22 | 23 | assert.strictEqual(yaml.dump(data), expected); 24 | assert.deepStrictEqual(yaml.load(expected), data); 25 | }); 26 | -------------------------------------------------------------------------------- /test/issues/0475.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | var readFileSync = require('fs').readFileSync; 7 | 8 | 9 | it('Should not allow nested arrays in map keys (explicit syntax)', function () { 10 | try { 11 | yaml.load(readFileSync(require('path').join(__dirname, '/0475-case1.yml'), 'utf8')); 12 | } catch (err) { 13 | assert(err.stack.startsWith('YAMLException: nested arrays are not supported inside keys')); 14 | return; 15 | } 16 | assert.fail(null, null, 'Expected an error to be thrown'); 17 | }); 18 | 19 | it('Should not allow nested arrays in map keys (implicit syntax)', function () { 20 | try { 21 | yaml.load(readFileSync(require('path').join(__dirname, '/0475-case2.yml'), 'utf8')); 22 | } catch (err) { 23 | assert(err.stack.startsWith('YAMLException: nested arrays are not supported inside keys')); 24 | return; 25 | } 26 | assert.fail(null, null, 'Expected an error to be thrown'); 27 | }); 28 | -------------------------------------------------------------------------------- /test/issues/0519.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var assert = require('assert'); 4 | var yaml = require('../../'); 5 | 6 | it('Dumper should add quotes around equals sign', function () { 7 | // pyyaml fails with unquoted `=` 8 | // https://yaml-online-parser.appspot.com/?yaml=%3D%0A&type=json 9 | assert.strictEqual(yaml.load(yaml.dump('=')), '='); 10 | assert.strictEqual(yaml.dump('='), "'='\n"); 11 | }); 12 | -------------------------------------------------------------------------------- /test/issues/0525-1.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Should throw if there is a null-byte in input', function () { 9 | try { 10 | yaml.load('foo\0bar'); 11 | } catch (err) { 12 | assert(err.stack.startsWith('YAMLException: null byte is not allowed in input')); 13 | return; 14 | } 15 | assert.fail(null, null, 'Expected an error to be thrown'); 16 | }); 17 | -------------------------------------------------------------------------------- /test/issues/0525-2.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Should check kind type when resolving ! tag', function () { 9 | try { 10 | yaml.load('! [0]'); 11 | } catch (err) { 12 | assert(err.stack.startsWith('YAMLException: unacceptable node kind for ! tag')); 13 | return; 14 | } 15 | assert.fail(null, null, 'Expected an error to be thrown'); 16 | }); 17 | -------------------------------------------------------------------------------- /test/issues/0570.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | const assert = require('assert'); 5 | const yaml = require('../../'); 6 | 7 | 8 | it('should dump null in different styles', function () { 9 | let dump, src = { foo: null, bar: 1 }; 10 | 11 | let tests = { 12 | lowercase: 'null', 13 | uppercase: 'NULL', 14 | camelcase: 'Null', 15 | canonical: '~', 16 | empty: '' 17 | }; 18 | 19 | for (let [ name, value ] of Object.entries(tests)) { 20 | dump = yaml.dump(src, { styles: { '!!null': name } }); 21 | assert.strictEqual(dump, 'foo: ' + value + '\nbar: 1\n'); 22 | assert.deepStrictEqual(yaml.load(dump), src); 23 | } 24 | }); 25 | -------------------------------------------------------------------------------- /test/issues/0587.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Should not encode astral characters', function () { 9 | assert.strictEqual(yaml.dump('😃😊'), '😃😊\n'); 10 | }); 11 | -------------------------------------------------------------------------------- /test/samples-common/construct-binary.yml: -------------------------------------------------------------------------------- 1 | canonical: !!binary "\ 2 | R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\ 3 | OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\ 4 | +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\ 5 | AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=" 6 | generic: !!binary | 7 | R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5 8 | OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+ 9 | +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC 10 | AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs= 11 | description: 12 | The binary value above is a tiny arrow encoded as a gif image. 13 | -------------------------------------------------------------------------------- /test/samples-common/construct-bool.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | valid_true: [ true, true, true ], 5 | valid_false: [ false, false, false ], 6 | deprecated_true: [ 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON' ], 7 | deprecated_false: [ 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' ] 8 | }; 9 | -------------------------------------------------------------------------------- /test/samples-common/construct-bool.yml: -------------------------------------------------------------------------------- 1 | # Valid notation. (YAML 1.2) 2 | # 3 | valid_true: 4 | - true 5 | - True 6 | - TRUE 7 | 8 | valid_false: 9 | - false 10 | - False 11 | - FALSE 12 | 13 | # Deprecated notation. (YAML 1.0/1.1) 14 | # 15 | deprecated_true: 16 | - y 17 | - Y 18 | - yes 19 | - Yes 20 | - YES 21 | - on 22 | - On 23 | - ON 24 | 25 | deprecated_false: 26 | - n 27 | - N 28 | - no 29 | - No 30 | - NO 31 | - off 32 | - Off 33 | - OFF -------------------------------------------------------------------------------- /test/samples-common/construct-custom.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - !tag1 3 | x: 1 4 | - !tag1 5 | x: 1 6 | 'y': 2 7 | z: 3 8 | - !tag2 9 | 10 10 | - !tag3 11 | x: 1 12 | - !tag3 13 | x: 1 14 | 'y': 2 15 | z: 3 16 | - !tag3 17 | =: 1 18 | 'y': 2 19 | z: 3 20 | - !foo 21 | my-parameter: foo 22 | my-another-parameter: [1,2,3] 23 | -------------------------------------------------------------------------------- /test/samples-common/construct-float.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var assert = require('assert'); 4 | 5 | var expected = { 6 | canonical: 685230.15, 7 | exponential: 685230.15, 8 | fixed: 685230.15, 9 | 'negative infinity': Number.NEGATIVE_INFINITY, 10 | 'not a number': NaN 11 | }; 12 | 13 | function testHandler(actual) { 14 | assert.strictEqual(Object.prototype.toString.call(actual), '[object Object]'); 15 | assert.strictEqual(Object.keys(actual).sort().join(','), Object.keys(expected).sort().join(',')); 16 | 17 | assert.strictEqual(actual['canonical'], expected['canonical']); 18 | assert.strictEqual(actual['exponential'], expected['exponential']); 19 | assert.strictEqual(actual['fixed'], expected['fixed']); 20 | assert.strictEqual(actual['negative infinity'], expected['negative infinity']); 21 | 22 | assert(Number.isNaN(actual['not a number'])); 23 | } 24 | 25 | testHandler.expected = expected; 26 | 27 | module.exports = testHandler; 28 | -------------------------------------------------------------------------------- /test/samples-common/construct-float.yml: -------------------------------------------------------------------------------- 1 | canonical: 6.8523015e+5 2 | exponential: 685.230_15e+03 3 | fixed: 685_230.15 4 | negative infinity: -.inf 5 | not a number: .NaN 6 | -------------------------------------------------------------------------------- /test/samples-common/construct-int.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | canonical: 685230, 5 | decimal: 685230, 6 | octal: 685230, 7 | hexadecimal: 685230, 8 | binary: 685230 9 | }; 10 | -------------------------------------------------------------------------------- /test/samples-common/construct-int.yml: -------------------------------------------------------------------------------- 1 | canonical: 685230 2 | decimal: +685_230 3 | octal: 0o2472256 4 | hexadecimal: 0x_0A_74_AE 5 | binary: 0b1010_0111_0100_1010_1110 6 | -------------------------------------------------------------------------------- /test/samples-common/construct-map.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | 'Block style': { 5 | Clark: 'Evans', 6 | Brian: 'Ingerson', 7 | Oren: 'Ben-Kiki' 8 | }, 9 | 'Flow style': { 10 | Clark: 'Evans', 11 | Brian: 'Ingerson', 12 | Oren: 'Ben-Kiki' 13 | }, 14 | 'foo,bar': 'baz' 15 | }; 16 | -------------------------------------------------------------------------------- /test/samples-common/construct-map.yml: -------------------------------------------------------------------------------- 1 | # Unordered set of key: value pairs. 2 | Block style: !!map 3 | Clark : Evans 4 | Brian : Ingerson 5 | Oren : Ben-Kiki 6 | Flow style: !!map { Clark: Evans, Brian: Ingerson, Oren: Ben-Kiki } 7 | 8 | # YAML has no restrictions on key type, so it can be an array 9 | ? - foo 10 | - bar 11 | : baz 12 | -------------------------------------------------------------------------------- /test/samples-common/construct-merge.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = [ 4 | { x: 1, y: 2 }, 5 | { x: 0, y: 2 }, 6 | { r: 10 }, 7 | { r: 1 }, 8 | { x: 1, y: 2, r: 10, label: 'center/big' }, 9 | { x: 1, y: 2, r: 10, label: 'center/big' }, 10 | { x: 1, y: 2, r: 10, label: 'center/big' }, 11 | { x: 1, y: 2, r: 10, label: 'center/big' } 12 | ]; 13 | -------------------------------------------------------------------------------- /test/samples-common/construct-merge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - &CENTER { x: 1, 'y': 2 } 3 | - &LEFT { x: 0, 'y': 2 } 4 | - &BIG { r: 10 } 5 | - &SMALL { r: 1 } 6 | 7 | # All the following maps are equal: 8 | 9 | - # Explicit keys 10 | x: 1 11 | 'y': 2 12 | r: 10 13 | label: center/big 14 | 15 | - # Merge one map 16 | << : *CENTER 17 | r: 10 18 | label: center/big 19 | 20 | - # Merge multiple maps 21 | << : [ *CENTER, *BIG ] 22 | label: center/big 23 | 24 | - # Override 25 | << : [ *BIG, *LEFT, *SMALL ] 26 | x: 1 27 | label: center/big 28 | -------------------------------------------------------------------------------- /test/samples-common/construct-null.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = [ 4 | null, 5 | { 6 | empty: null, 7 | canonical: null, 8 | english: null, 9 | null: 'null key' 10 | }, 11 | { 12 | sparse: [ 13 | null, 14 | '2nd entry', 15 | null, 16 | '4th entry', 17 | null 18 | ] 19 | } 20 | ]; 21 | -------------------------------------------------------------------------------- /test/samples-common/construct-null.yml: -------------------------------------------------------------------------------- 1 | # A document may be null. 2 | --- 3 | --- 4 | # This mapping has four keys, 5 | # one has a value. 6 | empty: 7 | canonical: ~ 8 | english: null 9 | ~: null key 10 | --- 11 | # This sequence has five 12 | # entries, two have values. 13 | sparse: 14 | - ~ 15 | - 2nd entry 16 | - 17 | - 4th entry 18 | - Null 19 | -------------------------------------------------------------------------------- /test/samples-common/construct-omap.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | Bestiary: [ 5 | { aardvark : 'African pig-like ant eater. Ugly.' }, 6 | { anteater : 'South-American ant eater. Two species.' }, 7 | { anaconda : 'South-American constrictor snake. Scaly.' } 8 | ], 9 | Numbers: [ 10 | { one : 1 }, 11 | { two : 2 }, 12 | { three : 3 } 13 | ] 14 | }; 15 | -------------------------------------------------------------------------------- /test/samples-common/construct-omap.yml: -------------------------------------------------------------------------------- 1 | # Explicitly typed ordered map (dictionary). 2 | Bestiary: !!omap 3 | - aardvark: African pig-like ant eater. Ugly. 4 | - anteater: South-American ant eater. Two species. 5 | - anaconda: South-American constrictor snake. Scaly. 6 | # Etc. 7 | # Flow style 8 | Numbers: !!omap [ one: 1, two: 2, three : 3 ] 9 | -------------------------------------------------------------------------------- /test/samples-common/construct-pairs.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | 'Block tasks': [ 5 | [ 'meeting', 'with team.' ], 6 | [ 'meeting', 'with boss.' ], 7 | [ 'break', 'lunch.' ], 8 | [ 'meeting', 'with client.' ] 9 | ], 10 | 'Flow tasks': [ 11 | [ 'meeting', 'with team' ], 12 | [ 'meeting', 'with boss' ] 13 | ] 14 | }; 15 | -------------------------------------------------------------------------------- /test/samples-common/construct-pairs.yml: -------------------------------------------------------------------------------- 1 | # Explicitly typed pairs. 2 | Block tasks: !!pairs 3 | - meeting: with team. 4 | - meeting: with boss. 5 | - break: lunch. 6 | - meeting: with client. 7 | Flow tasks: !!pairs [ meeting: with team, meeting: with boss ] 8 | -------------------------------------------------------------------------------- /test/samples-common/construct-seq.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | 'Block style': [ 5 | 'Mercury', 6 | 'Venus', 7 | 'Earth', 8 | 'Mars', 9 | 'Jupiter', 10 | 'Saturn', 11 | 'Uranus', 12 | 'Neptune', 13 | 'Pluto' 14 | ], 15 | 'Flow style': [ 16 | 'Mercury', 17 | 'Venus', 18 | 'Earth', 19 | 'Mars', 20 | 'Jupiter', 21 | 'Saturn', 22 | 'Uranus', 23 | 'Neptune', 24 | 'Pluto' 25 | ] 26 | }; 27 | -------------------------------------------------------------------------------- /test/samples-common/construct-seq.yml: -------------------------------------------------------------------------------- 1 | # Ordered sequence of nodes 2 | Block style: !!seq 3 | - Mercury # Rotates - no light/dark sides. 4 | - Venus # Deadliest. Aptly named. 5 | - Earth # Mostly dirt. 6 | - Mars # Seems empty. 7 | - Jupiter # The king. 8 | - Saturn # Pretty. 9 | - Uranus # Where the sun hardly shines. 10 | - Neptune # Boring. No rings. 11 | - Pluto # You call this a planet? 12 | Flow style: !!seq [ Mercury, Venus, Earth, Mars, # Rocks 13 | Jupiter, Saturn, Uranus, Neptune, # Gas 14 | Pluto ] # Overrated 15 | 16 | -------------------------------------------------------------------------------- /test/samples-common/construct-set.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | 'baseball players': { 5 | 'Mark McGwire': null, 6 | 'Sammy Sosa': null, 7 | 'Ken Griffey': null 8 | }, 9 | 'baseball teams': { 10 | 'Boston Red Sox': null, 11 | 'Detroit Tigers': null, 12 | 'New York Yankees': null 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /test/samples-common/construct-set.yml: -------------------------------------------------------------------------------- 1 | # Explicitly typed set. 2 | baseball players: !!set 3 | ? Mark McGwire 4 | ? Sammy Sosa 5 | ? Ken Griffey 6 | # Flow style 7 | baseball teams: !!set { Boston Red Sox, Detroit Tigers, New York Yankees } 8 | -------------------------------------------------------------------------------- /test/samples-common/construct-str-ascii.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = 'ascii string'; 4 | -------------------------------------------------------------------------------- /test/samples-common/construct-str-ascii.yml: -------------------------------------------------------------------------------- 1 | --- !!str "ascii string" 2 | -------------------------------------------------------------------------------- /test/samples-common/construct-str-utf8.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /*eslint-disable max-len*/ 4 | 5 | module.exports = '\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430'; 6 | -------------------------------------------------------------------------------- /test/samples-common/construct-str-utf8.yml: -------------------------------------------------------------------------------- 1 | --- !!str "Это уникодная строка" 2 | -------------------------------------------------------------------------------- /test/samples-common/construct-str.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | string: 'abcd' 5 | }; 6 | -------------------------------------------------------------------------------- /test/samples-common/construct-str.yml: -------------------------------------------------------------------------------- 1 | string: abcd 2 | -------------------------------------------------------------------------------- /test/samples-common/construct-timestamp.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | canonical: new Date(Date.UTC(2001, 11, 15, 2, 59, 43, 100)), 5 | 'valid iso8601': new Date(Date.UTC(2001, 11, 15, 2, 59, 43, 100)), 6 | 'space separated': new Date(Date.UTC(2001, 11, 15, 2, 59, 43, 100)), 7 | 'no time zone (Z)': new Date(Date.UTC(2001, 11, 15, 2, 59, 43, 100)), 8 | 'date (00:00:00Z)': new Date(Date.UTC(2002, 11, 14)), 9 | 'not a date': '2002-1-1' 10 | }; 11 | -------------------------------------------------------------------------------- /test/samples-common/construct-timestamp.yml: -------------------------------------------------------------------------------- 1 | canonical: 2001-12-15T02:59:43.1Z 2 | valid iso8601: 2001-12-14t21:59:43.10-05:00 3 | space separated: 2001-12-14 21:59:43.10 -5 4 | no time zone (Z): 2001-12-15 2:59:43.10 5 | date (00:00:00Z): 2002-12-14 6 | not a date: 2002-1-1 7 | -------------------------------------------------------------------------------- /test/samples-common/construct-value.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = [ 4 | { 5 | 'link with': [ 6 | 'library1.dll', 7 | 'library2.dll' 8 | ] 9 | }, 10 | { 11 | 'link with': [ 12 | { '=': 'library1.dll', version: 1.2 }, 13 | { '=': 'library2.dll', version: 2.3 } 14 | ] 15 | } 16 | ]; 17 | -------------------------------------------------------------------------------- /test/samples-common/construct-value.yml: -------------------------------------------------------------------------------- 1 | --- # Old schema 2 | link with: 3 | - library1.dll 4 | - library2.dll 5 | --- # New schema 6 | link with: 7 | - = : library1.dll 8 | version: 1.2 9 | - = : library2.dll 10 | version: 2.3 11 | -------------------------------------------------------------------------------- /test/samples-common/dump-empty-collections.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | module.exports = { 5 | emptyArray: [], 6 | emptyObject: {} 7 | }; 8 | -------------------------------------------------------------------------------- /test/samples-common/dump-empty-collections.yml: -------------------------------------------------------------------------------- 1 | emptyArray: [] 2 | emptyObject: {} 3 | -------------------------------------------------------------------------------- /test/samples-common/duplicate-mapping-key.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | foo: { 5 | baz: 'bat', 6 | foo: 'duplicate key' 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /test/samples-common/duplicate-mapping-key.yml: -------------------------------------------------------------------------------- 1 | foo: 2 | baz: bat 3 | foo: duplicate key 4 | -------------------------------------------------------------------------------- /test/samples-common/duplicate-merge-key.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | x: 1, 5 | y: 2, 6 | foo: 'bar', 7 | z: 3, 8 | t: 4 9 | }; 10 | -------------------------------------------------------------------------------- /test/samples-common/duplicate-merge-key.yml: -------------------------------------------------------------------------------- 1 | --- 2 | <<: {x: 1, y: 2} 3 | foo: bar 4 | <<: {z: 3, t: 4} 5 | -------------------------------------------------------------------------------- /test/samples-common/emitting-unacceptable-unicode-character-bug.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = '\udd00'; 4 | -------------------------------------------------------------------------------- /test/samples-common/emitting-unacceptable-unicode-character-bug.yml: -------------------------------------------------------------------------------- 1 | "\udd00" 2 | -------------------------------------------------------------------------------- /test/samples-common/invalid-single-quote-bug.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = [ 4 | "foo 'bar'", 5 | "foo\n'bar'" 6 | ]; 7 | -------------------------------------------------------------------------------- /test/samples-common/invalid-single-quote-bug.yml: -------------------------------------------------------------------------------- 1 | - "foo 'bar'" 2 | - "foo\n'bar'" 3 | -------------------------------------------------------------------------------- /test/samples-common/more-floats.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var assert = require('assert'); 4 | 5 | var expected = [ 6 | 0.0, 7 | 1.0, 8 | -1.0, 9 | Number.POSITIVE_INFINITY, 10 | Number.NEGATIVE_INFINITY, 11 | NaN, 12 | NaN 13 | ]; 14 | 15 | function testHandler(actual) { 16 | assert.strictEqual(Object.prototype.toString.call(actual), '[object Array]'); 17 | assert.strictEqual(actual.length, 7); 18 | assert.strictEqual(actual[0], expected[0]); 19 | assert.strictEqual(actual[1], expected[1]); 20 | assert.strictEqual(actual[2], expected[2]); 21 | assert.strictEqual(actual[3], expected[3]); 22 | assert.strictEqual(actual[4], expected[4]); 23 | assert(Number.isNaN(actual[5])); 24 | assert(Number.isNaN(actual[6])); 25 | } 26 | 27 | testHandler.expected = expected; 28 | 29 | module.exports = testHandler; 30 | -------------------------------------------------------------------------------- /test/samples-common/more-floats.yml: -------------------------------------------------------------------------------- 1 | [0.0, +1.0, -1.0, +.inf, -.inf, .nan, .nan] 2 | -------------------------------------------------------------------------------- /test/samples-common/negative-float-bug.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = -1.0; 4 | -------------------------------------------------------------------------------- /test/samples-common/negative-float-bug.yml: -------------------------------------------------------------------------------- 1 | -1.0 2 | -------------------------------------------------------------------------------- /test/samples-common/single-dot-is-not-float-bug.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = '.'; 4 | -------------------------------------------------------------------------------- /test/samples-common/single-dot-is-not-float-bug.yml: -------------------------------------------------------------------------------- 1 | . 2 | -------------------------------------------------------------------------------- /test/samples-common/timestamp-bugs.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = [ 4 | new Date(Date.UTC(2001, 11, 15, 3, 29, 43, 100)), 5 | new Date(Date.UTC(2001, 11, 14, 16, 29, 43, 100)), 6 | new Date(Date.UTC(2001, 11, 14, 21, 59, 43, 1)), 7 | new Date(Date.UTC(2001, 11, 14, (21 - 1), 59, 43, 0)), 8 | new Date(Date.UTC(2001, 11, 14, (21 + 1), (59 + 30), 43, 0)), 9 | new Date(Date.UTC(2005, 6, 8, 17, 35, 4, 517)) 10 | ]; 11 | -------------------------------------------------------------------------------- /test/samples-common/timestamp-bugs.yml: -------------------------------------------------------------------------------- 1 | - 2001-12-14 21:59:43.10 -5:30 2 | - 2001-12-14 21:59:43.10 +5:30 3 | - 2001-12-14 21:59:43.00101 4 | - 2001-12-14 21:59:43+1 5 | - 2001-12-14 21:59:43-1:30 6 | - 2005-07-08 17:35:04.517600 7 | -------------------------------------------------------------------------------- /test/samples-common/utf8-implicit.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = 'implicit UTF-8'; 4 | -------------------------------------------------------------------------------- /test/samples-common/utf8-implicit.yml: -------------------------------------------------------------------------------- 1 | --- implicit UTF-8 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/a-nasty-libyaml-bug.yml: -------------------------------------------------------------------------------- 1 | [ [ -------------------------------------------------------------------------------- /test/samples-load-errors/document-separator-in-quoted-scalar.yml: -------------------------------------------------------------------------------- 1 | --- 2 | "this --- is correct" 3 | --- 4 | "this 5 | ...is also 6 | correct" 7 | --- 8 | "a quoted scalar 9 | cannot contain 10 | --- 11 | document separators" 12 | -------------------------------------------------------------------------------- /test/samples-load-errors/duplicate-key.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { foo: 'baz' }; 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/duplicate-key.yml: -------------------------------------------------------------------------------- 1 | --- 2 | foo: bar 3 | foo: baz 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/duplicate-tag-directive.yml: -------------------------------------------------------------------------------- 1 | %TAG !foo! bar 2 | %TAG !foo! baz 3 | --- foo 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/duplicate-value-key.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { foo: 'bar', '=': 2 }; 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/duplicate-value-key.yml: -------------------------------------------------------------------------------- 1 | --- 2 | =: 1 3 | foo: bar 4 | =: 2 5 | -------------------------------------------------------------------------------- /test/samples-load-errors/duplicate-yaml-directive.yml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %YAML 1.1 3 | --- foo 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/expected-mapping.yml: -------------------------------------------------------------------------------- 1 | --- !!map [not, a, map] 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/expected-scalar.yml: -------------------------------------------------------------------------------- 1 | --- !!str [not a scalar] 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/expected-sequence.yml: -------------------------------------------------------------------------------- 1 | --- !!seq {foo, bar, baz} 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/fetch-complex-value-bug.yml: -------------------------------------------------------------------------------- 1 | ? "foo" 2 | : "bar" 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/forbidden-entry.yml: -------------------------------------------------------------------------------- 1 | test: - foo 2 | - bar 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/forbidden-key.yml: -------------------------------------------------------------------------------- 1 | test: ? foo 2 | : bar 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/forbidden-value.yml: -------------------------------------------------------------------------------- 1 | test: key: value 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-anchor-2.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - [ 3 | &correct foo, 4 | *correct, 5 | *correct] # still correct 6 | - *correct: still correct 7 | - &correct-or-not[foo, bar] 8 | 9 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-base64-data-2.yml: -------------------------------------------------------------------------------- 1 | --- !!binary 2 | двоичные данные в base64 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-base64-data.yml: -------------------------------------------------------------------------------- 1 | --- !!binary 2 | binary data encoded in base64 should be here. 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-block-scalar-indicator.yml: -------------------------------------------------------------------------------- 1 | --- > what is this? # a comment 2 | data 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-directive-line.yml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 ? # extra symbol 2 | --- 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-directive-name-1.yml: -------------------------------------------------------------------------------- 1 | % # no name at all 2 | --- 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-directive-name-2.yml: -------------------------------------------------------------------------------- 1 | %invalid-characters:in-directive name 2 | --- 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-escape-character.yml: -------------------------------------------------------------------------------- 1 | "some escape characters are \ncorrect, but this one \?\nis not\n" 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-escape-numbers.yml: -------------------------------------------------------------------------------- 1 | "hm.... \u123?" 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-indentation-indicator-1.yml: -------------------------------------------------------------------------------- 1 | --- >0 # not valid 2 | data 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-indentation-indicator-2.yml: -------------------------------------------------------------------------------- 1 | --- >-0 2 | data 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-item-without-trailing-break.yml: -------------------------------------------------------------------------------- 1 | - 2 | -0 -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-merge-1.yml: -------------------------------------------------------------------------------- 1 | foo: bar 2 | <<: baz 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-merge-2.yml: -------------------------------------------------------------------------------- 1 | foo: bar 2 | <<: [x: 1, y: 2, z, t: 4] 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-omap-1.yml: -------------------------------------------------------------------------------- 1 | --- !!omap 2 | foo: bar 3 | baz: bat 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-omap-2.yml: -------------------------------------------------------------------------------- 1 | --- !!omap 2 | - foo: bar 3 | - baz 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-omap-3.yml: -------------------------------------------------------------------------------- 1 | --- !!omap 2 | - foo: bar 3 | - baz: bar 4 | bar: bar 5 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-pairs-1.yml: -------------------------------------------------------------------------------- 1 | --- !!pairs 2 | foo: bar 3 | baz: bat 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-pairs-2.yml: -------------------------------------------------------------------------------- 1 | --- !!pairs 2 | - foo: bar 3 | - baz 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-pairs-3.yml: -------------------------------------------------------------------------------- 1 | --- !!pairs 2 | - foo: bar 3 | - baz: bar 4 | bar: bar 5 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-simple-key.yml: -------------------------------------------------------------------------------- 1 | key: value 2 | invalid simple key 3 | next key: next value 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-starting-character.yml: -------------------------------------------------------------------------------- 1 | @@@@@@@@@@@@@@@@@@@ 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-tag-2.yml: -------------------------------------------------------------------------------- 1 | - !prefix!foo#bar baz 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-tag-directive-handle.yml: -------------------------------------------------------------------------------- 1 | %TAG !!! !!! 2 | --- 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-tag-handle-1.yml: -------------------------------------------------------------------------------- 1 | %TAG foo bar 2 | --- 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-tag-handle-2.yml: -------------------------------------------------------------------------------- 1 | %TAG !foo bar 2 | --- 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-uri-escapes-1.yml: -------------------------------------------------------------------------------- 1 | --- ! foo 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-uri.yml: -------------------------------------------------------------------------------- 1 | --- !foo! bar 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-yaml-directive-version-1.yml: -------------------------------------------------------------------------------- 1 | # No version at all. 2 | %YAML 3 | --- 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-yaml-directive-version-2.yml: -------------------------------------------------------------------------------- 1 | %YAML 1e-5 2 | --- 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-yaml-directive-version-3.yml: -------------------------------------------------------------------------------- 1 | %YAML 1. 2 | --- 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-yaml-directive-version-4.yml: -------------------------------------------------------------------------------- 1 | %YAML 1.132.435 2 | --- 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-yaml-directive-version-5.yml: -------------------------------------------------------------------------------- 1 | %YAML A.0 2 | --- 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-yaml-directive-version-6.yml: -------------------------------------------------------------------------------- 1 | %YAML 123.C 2 | --- 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/invalid-yaml-version.yml: -------------------------------------------------------------------------------- 1 | %YAML 2.0 2 | --- foo 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/no-block-collection-end.yml: -------------------------------------------------------------------------------- 1 | - foo 2 | - bar 3 | baz: bar 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/no-block-mapping-end-2.yml: -------------------------------------------------------------------------------- 1 | ? foo 2 | : bar 3 | : baz 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/no-block-mapping-end.yml: -------------------------------------------------------------------------------- 1 | foo: "bar" "baz" 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/no-document-start.yml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | # no --- 3 | foo: bar 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/no-flow-mapping-end.yml: -------------------------------------------------------------------------------- 1 | { foo: bar ] 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/no-flow-sequence-end.yml: -------------------------------------------------------------------------------- 1 | [foo, bar} 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/no-node-1.yml: -------------------------------------------------------------------------------- 1 | - !foo ] 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/no-node-2.yml: -------------------------------------------------------------------------------- 1 | - [ !foo } ] 2 | -------------------------------------------------------------------------------- /test/samples-load-errors/remove-possible-simple-key-bug.yml: -------------------------------------------------------------------------------- 1 | foo: &A bar 2 | *A ] # The ']' indicator triggers remove_possible_simple_key, 3 | # which should raise an error. 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/unclosed-bracket.yml: -------------------------------------------------------------------------------- 1 | test: 2 | - [ foo: bar 3 | # comment the rest of the stream to let the scanner detect the problem. 4 | # - baz 5 | #"we could have detected the unclosed bracket on the above line, but this would forbid such syntax as": { 6 | #} 7 | -------------------------------------------------------------------------------- /test/samples-load-errors/unclosed-quoted-scalar.yml: -------------------------------------------------------------------------------- 1 | 'foo 2 | bar 3 | -------------------------------------------------------------------------------- /test/samples-load-errors/undefined-anchor.yml: -------------------------------------------------------------------------------- 1 | - foo 2 | - &bar baz 3 | - *bat 4 | -------------------------------------------------------------------------------- /test/samples-load-errors/undefined-tag-handle.yml: -------------------------------------------------------------------------------- 1 | --- !foo!bar baz 2 | -------------------------------------------------------------------------------- /test/units/bom-strip.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('BOM strip', function () { 9 | assert.deepStrictEqual(yaml.load('\uFEFFfoo: bar\n'), { foo: 'bar' }); 10 | assert.deepStrictEqual(yaml.load('foo: bar\n'), { foo: 'bar' }); 11 | }); 12 | -------------------------------------------------------------------------------- /test/units/character-set.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Allow astral characters', function () { 9 | assert.deepStrictEqual(yaml.load('𝑘𝑒𝑦: 𝑣𝑎𝑙𝑢𝑒'), { '𝑘𝑒𝑦': '𝑣𝑎𝑙𝑢𝑒' }); 10 | }); 11 | 12 | it('Forbid non-printable characters', function () { 13 | assert.throws(function () { yaml.load('\x01'); }, yaml.YAMLException); 14 | assert.throws(function () { yaml.load('\x7f'); }, yaml.YAMLException); 15 | assert.throws(function () { yaml.load('\x9f'); }, yaml.YAMLException); 16 | }); 17 | 18 | it('Forbid lone surrogates', function () { 19 | assert.throws(function () { yaml.load('\udc00\ud800'); }, yaml.YAMLException); 20 | }); 21 | 22 | it('Allow non-printable characters inside quoted scalars', function () { 23 | assert.strictEqual(yaml.load('"\x7f\x9f\udc00\ud800"'), '\x7f\x9f\udc00\ud800'); 24 | }); 25 | 26 | it('Forbid control sequences inside quoted scalars', function () { 27 | assert.throws(function () { yaml.load('"\x03"'); }, yaml.YAMLException); 28 | }); 29 | -------------------------------------------------------------------------------- /test/units/is-negative-zero.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | 6 | var isNegativeZero = require('../../lib/common').isNegativeZero; 7 | 8 | 9 | it('isNegativeZero', function () { 10 | assert(!isNegativeZero(0)); 11 | assert(!isNegativeZero(0.0)); 12 | assert(isNegativeZero(-0)); 13 | assert(isNegativeZero(-0.0)); 14 | }); 15 | -------------------------------------------------------------------------------- /test/units/single-document-error.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | it('Loading multidocument source using `load` should cause an error', function () { 9 | assert.throws(function () { 10 | yaml.load('--- # first document\n--- # second document\n'); 11 | }, yaml.YAMLException); 12 | 13 | assert.throws(function () { 14 | yaml.load('---\nfoo: bar\n---\nfoo: bar\n'); 15 | }, yaml.YAMLException); 16 | 17 | assert.throws(function () { 18 | yaml.load('foo: bar\n---\nfoo: bar\n'); 19 | }, yaml.YAMLException); 20 | }); 21 | -------------------------------------------------------------------------------- /test/units/skip-invalid.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | 8 | var sample = { 9 | number: 42, 10 | string: 'hello', 11 | func: function (a, b) { return a + b; }, 12 | regexp: /^hel+o/, 13 | array: [ 1, 2, 3 ] 14 | }; 15 | 16 | 17 | var expected = { 18 | number: 42, 19 | string: 'hello', 20 | array: [ 1, 2, 3 ] 21 | }; 22 | 23 | 24 | it('Dumper must throw an exception on invalid type when option `skipInvalid` is false.', function () { 25 | assert.throws(function () { 26 | yaml.dump(sample, { skipInvalid: false }); 27 | }, yaml.YAMLException); 28 | }); 29 | 30 | 31 | it('Dumper must skip pairs and values with invalid types when option `skipInvalid` is true.', function () { 32 | assert.deepStrictEqual(yaml.load(yaml.dump(sample, { skipInvalid: true })), expected); 33 | }); 34 | -------------------------------------------------------------------------------- /test/units/sort-keys.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | var sample = { b: 1, a: 2, c: 3 }; 8 | var unsortedExpected = 'b: 1\na: 2\nc: 3\n'; 9 | var simpleExpected = 'a: 2\nb: 1\nc: 3\n'; 10 | var reverseExpected = 'c: 3\nb: 1\na: 2\n'; 11 | 12 | it('Dumper should sort preserve key insertion order', function () { 13 | assert.deepStrictEqual(yaml.dump(sample, { sortKeys: false }), unsortedExpected); 14 | }); 15 | 16 | it('Dumper should sort keys when sortKeys is true', function () { 17 | assert.deepStrictEqual(yaml.dump(sample, { sortKeys: true }), simpleExpected); 18 | }); 19 | 20 | it('Dumper should sort keys by sortKeys function when specified', function () { 21 | assert.deepStrictEqual(yaml.dump(sample, { 22 | sortKeys: function (a, b) { 23 | return a < b ? 1 : a > b ? -1 : 0; 24 | } 25 | }), reverseExpected); 26 | }); 27 | -------------------------------------------------------------------------------- /test/units/tagmultikind.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | var assert = require('assert'); 5 | var yaml = require('../../'); 6 | 7 | var tags = [ { 8 | tag: 'Include', 9 | type: 'scalar' 10 | }, { 11 | tag: 'Include', 12 | type: 'mapping' 13 | } ].map(function (fn) { 14 | return new yaml.Type('!' + fn.tag, { 15 | kind: fn.type, 16 | resolve: function () { 17 | return true; 18 | }, 19 | construct: function (obj) { 20 | return obj; 21 | } 22 | }); 23 | }); 24 | 25 | var schema = yaml.DEFAULT_SCHEMA.extend(tags); 26 | 27 | 28 | it('Process tag with kind: scalar', function () { 29 | assert.deepStrictEqual(yaml.load('!Include foobar', { 30 | schema: schema 31 | }), 'foobar'); 32 | }); 33 | 34 | 35 | it('Process tag with kind: mapping', function () { 36 | assert.deepStrictEqual(yaml.load('!Include\n location: foobar', { 37 | schema: schema 38 | }), { location: 'foobar' }); 39 | }); 40 | -------------------------------------------------------------------------------- /test/unported/aliases-cdumper-bug.code: -------------------------------------------------------------------------------- 1 | [ today, today ] 2 | -------------------------------------------------------------------------------- /test/unported/aliases.events: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart 3 | - !SequenceStart 4 | - !Scalar { anchor: 'myanchor', tag: '!mytag', value: 'data' } 5 | - !Alias { anchor: 'myanchor' } 6 | - !SequenceEnd 7 | - !DocumentEnd 8 | - !StreamEnd 9 | -------------------------------------------------------------------------------- /test/unported/documents.events: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart { explicit: false } 3 | - !Scalar { implicit: [true,false], value: 'data' } 4 | - !DocumentEnd 5 | - !DocumentStart 6 | - !Scalar { implicit: [true,false] } 7 | - !DocumentEnd 8 | - !DocumentStart { version: [1,1], tags: { '!': '!foo', '!yaml!': 'tag:yaml.org,2002:', '!ugly!': '!!!!!!!' } } 9 | - !Scalar { implicit: [true,false] } 10 | - !DocumentEnd 11 | - !StreamEnd 12 | -------------------------------------------------------------------------------- /test/unported/emit-block-scalar-in-simple-key-context-bug.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- !!map 3 | { 4 | ? !!str "foo" 5 | : !!str "bar" 6 | } 7 | -------------------------------------------------------------------------------- /test/unported/emit-block-scalar-in-simple-key-context-bug.data: -------------------------------------------------------------------------------- 1 | ? |- 2 | foo 3 | : |- 4 | bar 5 | -------------------------------------------------------------------------------- /test/unported/emitting-unacceptable-unicode-character-bug.skip-ext: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unported/emitting-unacceptable-unicode-character-bug.skip-ext -------------------------------------------------------------------------------- /test/unported/empty-anchor.emitter-error: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart 3 | - !Scalar { anchor: '', value: 'foo' } 4 | - !DocumentEnd 5 | - !StreamEnd 6 | -------------------------------------------------------------------------------- /test/unported/empty-document-bug.canonical: -------------------------------------------------------------------------------- 1 | # This YAML stream contains no YAML documents. 2 | -------------------------------------------------------------------------------- /test/unported/empty-document-bug.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unported/empty-document-bug.data -------------------------------------------------------------------------------- /test/unported/empty-document-bug.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unported/empty-document-bug.empty -------------------------------------------------------------------------------- /test/unported/empty-tag-handle.emitter-error: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart { tags: { '': 'bar' } } 3 | - !Scalar { value: 'foo' } 4 | - !DocumentEnd 5 | - !StreamEnd 6 | -------------------------------------------------------------------------------- /test/unported/empty-tag-prefix.emitter-error: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart { tags: { '!': '' } } 3 | - !Scalar { value: 'foo' } 4 | - !DocumentEnd 5 | - !StreamEnd 6 | -------------------------------------------------------------------------------- /test/unported/empty-tag.emitter-error: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart 3 | - !Scalar { tag: '', value: 'key', implicit: [false,false] } 4 | - !DocumentEnd 5 | - !StreamEnd 6 | -------------------------------------------------------------------------------- /test/unported/expected-document-end.emitter-error: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart 3 | - !Scalar { value: 'data 1' } 4 | - !Scalar { value: 'data 2' } 5 | - !DocumentEnd 6 | - !StreamEnd 7 | -------------------------------------------------------------------------------- /test/unported/expected-document-start.emitter-error: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !MappingStart 3 | - !MappingEnd 4 | - !StreamEnd 5 | -------------------------------------------------------------------------------- /test/unported/expected-node-1.emitter-error: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart 3 | - !DocumentEnd 4 | - !StreamEnd 5 | -------------------------------------------------------------------------------- /test/unported/expected-node-2.emitter-error: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart 3 | - !MappingStart 4 | - !Scalar { value: 'key' } 5 | - !MappingEnd 6 | - !DocumentEnd 7 | - !StreamEnd 8 | -------------------------------------------------------------------------------- /test/unported/expected-nothing.emitter-error: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !StreamEnd 3 | - !StreamStart 4 | - !StreamEnd 5 | -------------------------------------------------------------------------------- /test/unported/expected-stream-start.emitter-error: -------------------------------------------------------------------------------- 1 | - !DocumentStart 2 | - !DocumentEnd 3 | -------------------------------------------------------------------------------- /test/unported/invalid-anchor.emitter-error: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart 3 | - !Scalar { anchor: '5*5=25', value: 'foo' } 4 | - !DocumentEnd 5 | - !StreamEnd 6 | -------------------------------------------------------------------------------- /test/unported/invalid-tag-handle-1.emitter-error: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart { tags: { '!foo': 'bar' } } 3 | - !Scalar { value: 'foo' } 4 | - !DocumentEnd 5 | - !StreamEnd 6 | -------------------------------------------------------------------------------- /test/unported/invalid-tag-handle-2.emitter-error: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart { tags: { '!!!': 'bar' } } 3 | - !Scalar { value: 'foo' } 4 | - !DocumentEnd 5 | - !StreamEnd 6 | -------------------------------------------------------------------------------- /test/unported/invalid-utf8-byte.loader-error: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unported/invalid-utf8-byte.loader-error -------------------------------------------------------------------------------- /test/unported/invalid-utf8-byte.stream-error: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unported/invalid-utf8-byte.stream-error -------------------------------------------------------------------------------- /test/unported/no-alias-anchor.emitter-error: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart 3 | - !SequenceStart 4 | - !Scalar { anchor: A, value: data } 5 | - !Alias { } 6 | - !SequenceEnd 7 | - !DocumentEnd 8 | - !StreamEnd 9 | -------------------------------------------------------------------------------- /test/unported/no-alias-anchor.skip-ext: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unported/no-alias-anchor.skip-ext -------------------------------------------------------------------------------- /test/unported/no-tag.emitter-error: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart 3 | - !Scalar { value: 'foo', implicit: [false,false] } 4 | - !DocumentEnd 5 | - !StreamEnd 6 | -------------------------------------------------------------------------------- /test/unported/recursive-anchor.former-loader-error: -------------------------------------------------------------------------------- 1 | - &foo [1 2 | 2, 3 | 3, 4 | *foo] 5 | -------------------------------------------------------------------------------- /test/unported/recursive-dict.recursive: -------------------------------------------------------------------------------- 1 | value = {} 2 | instance = AnInstance(value, value) 3 | value[instance] = instance 4 | -------------------------------------------------------------------------------- /test/unported/recursive-list.recursive: -------------------------------------------------------------------------------- 1 | value = [] 2 | value.append(value) 3 | -------------------------------------------------------------------------------- /test/unported/recursive-set.recursive: -------------------------------------------------------------------------------- 1 | try: 2 | set 3 | except NameError: 4 | from sets import Set as set 5 | value = set() 6 | value.add(AnInstance(foo=value, bar=value)) 7 | value.add(AnInstance(foo=value, bar=value)) 8 | -------------------------------------------------------------------------------- /test/unported/recursive-state.recursive: -------------------------------------------------------------------------------- 1 | value = [] 2 | value.append(AnInstanceWithState(value, value)) 3 | -------------------------------------------------------------------------------- /test/unported/recursive-tuple.recursive: -------------------------------------------------------------------------------- 1 | value = ([], []) 2 | value[0].append(value) 3 | value[1].append(value[0]) 4 | -------------------------------------------------------------------------------- /test/unported/recursive.former-dumper-error: -------------------------------------------------------------------------------- 1 | data = [] 2 | data.append(data) 3 | dump(data) 4 | -------------------------------------------------------------------------------- /test/unported/resolver.data: -------------------------------------------------------------------------------- 1 | --- 2 | "this scalar should be selected" 3 | --- 4 | key11: !foo 5 | key12: 6 | is: [selected] 7 | key22: 8 | key13: [not, selected] 9 | key23: [not, selected] 10 | key32: 11 | key31: [not, selected] 12 | key32: [not, selected] 13 | key33: {not: selected} 14 | key21: !bar 15 | - not selected 16 | - selected 17 | - not selected 18 | key31: !baz 19 | key12: 20 | key13: 21 | key14: {selected} 22 | key23: 23 | key14: [not, selected] 24 | key33: 25 | key14: {selected} 26 | key24: {not: selected} 27 | key22: 28 | - key14: {selected} 29 | key24: {not: selected} 30 | - key14: {selected} 31 | -------------------------------------------------------------------------------- /test/unported/run-parser-crash-bug.data: -------------------------------------------------------------------------------- 1 | --- 2 | - Harry Potter and the Prisoner of Azkaban 3 | - Harry Potter and the Goblet of Fire 4 | - Harry Potter and the Order of the Phoenix 5 | --- 6 | - Memoirs Found in a Bathtub 7 | - Snow Crash 8 | - Ghost World 9 | -------------------------------------------------------------------------------- /test/unported/scan-document-end-bug.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!null "" 4 | -------------------------------------------------------------------------------- /test/unported/scan-document-end-bug.data: -------------------------------------------------------------------------------- 1 | # Ticket #4 2 | --- 3 | ... -------------------------------------------------------------------------------- /test/unported/scan-line-break-bug.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { ? !!str "foo" : !!str "bar baz" } 4 | -------------------------------------------------------------------------------- /test/unported/scan-line-break-bug.data: -------------------------------------------------------------------------------- 1 | foo: 2 | bar 3 | baz 4 | -------------------------------------------------------------------------------- /test/unported/serializer-is-already-opened.dumper-error: -------------------------------------------------------------------------------- 1 | dumper = yaml.Dumper(StringIO()) 2 | dumper.open() 3 | dumper.open() 4 | -------------------------------------------------------------------------------- /test/unported/serializer-is-closed-1.dumper-error: -------------------------------------------------------------------------------- 1 | dumper = yaml.Dumper(StringIO()) 2 | dumper.open() 3 | dumper.close() 4 | dumper.open() 5 | -------------------------------------------------------------------------------- /test/unported/serializer-is-closed-2.dumper-error: -------------------------------------------------------------------------------- 1 | dumper = yaml.Dumper(StringIO()) 2 | dumper.open() 3 | dumper.close() 4 | dumper.serialize(yaml.ScalarNode(tag='!foo', value='bar')) 5 | -------------------------------------------------------------------------------- /test/unported/serializer-is-not-opened-1.dumper-error: -------------------------------------------------------------------------------- 1 | dumper = yaml.Dumper(StringIO()) 2 | dumper.close() 3 | -------------------------------------------------------------------------------- /test/unported/serializer-is-not-opened-2.dumper-error: -------------------------------------------------------------------------------- 1 | dumper = yaml.Dumper(StringIO()) 2 | dumper.serialize(yaml.ScalarNode(tag='!foo', value='bar')) 3 | -------------------------------------------------------------------------------- /test/unported/sloppy-indentation.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "in the block context" 5 | : !!map { 6 | ? !!str "indentation should be kept" 7 | : !!map { 8 | ? !!str "but in the flow context" 9 | : !!seq [ !!str "it may be violated" ] 10 | } 11 | } 12 | } 13 | --- !!str 14 | "the parser does not require scalars to be indented with at least one space" 15 | --- !!str 16 | "the parser does not require scalars to be indented with at least one space" 17 | --- !!map 18 | { ? !!str "foo": { ? !!str "bar" : !!str "quoted scalars may not adhere indentation" } } 19 | -------------------------------------------------------------------------------- /test/unported/sloppy-indentation.data: -------------------------------------------------------------------------------- 1 | --- 2 | in the block context: 3 | indentation should be kept: { 4 | but in the flow context: [ 5 | it may be violated] 6 | } 7 | --- 8 | the parser does not require scalars 9 | to be indented with at least one space 10 | ... 11 | --- 12 | "the parser does not require scalars 13 | to be indented with at least one space" 14 | --- 15 | foo: 16 | bar: 'quoted scalars 17 | may not adhere indentation' 18 | -------------------------------------------------------------------------------- /test/unported/spec-02-01.data: -------------------------------------------------------------------------------- 1 | - Mark McGwire 2 | - Sammy Sosa 3 | - Ken Griffey 4 | -------------------------------------------------------------------------------- /test/unported/spec-02-02.data: -------------------------------------------------------------------------------- 1 | hr: 65 # Home runs 2 | avg: 0.278 # Batting average 3 | rbi: 147 # Runs Batted In 4 | -------------------------------------------------------------------------------- /test/unported/spec-02-03.data: -------------------------------------------------------------------------------- 1 | american: 2 | - Boston Red Sox 3 | - Detroit Tigers 4 | - New York Yankees 5 | national: 6 | - New York Mets 7 | - Chicago Cubs 8 | - Atlanta Braves 9 | -------------------------------------------------------------------------------- /test/unported/spec-02-04.data: -------------------------------------------------------------------------------- 1 | - 2 | name: Mark McGwire 3 | hr: 65 4 | avg: 0.278 5 | - 6 | name: Sammy Sosa 7 | hr: 63 8 | avg: 0.288 9 | -------------------------------------------------------------------------------- /test/unported/spec-02-05.data: -------------------------------------------------------------------------------- 1 | - [name , hr, avg ] 2 | - [Mark McGwire, 65, 0.278] 3 | - [Sammy Sosa , 63, 0.288] 4 | -------------------------------------------------------------------------------- /test/unported/spec-02-06.data: -------------------------------------------------------------------------------- 1 | Mark McGwire: {hr: 65, avg: 0.278} 2 | Sammy Sosa: { 3 | hr: 63, 4 | avg: 0.288 5 | } 6 | -------------------------------------------------------------------------------- /test/unported/spec-02-07.data: -------------------------------------------------------------------------------- 1 | # Ranking of 1998 home runs 2 | --- 3 | - Mark McGwire 4 | - Sammy Sosa 5 | - Ken Griffey 6 | 7 | # Team ranking 8 | --- 9 | - Chicago Cubs 10 | - St Louis Cardinals 11 | -------------------------------------------------------------------------------- /test/unported/spec-02-08.data: -------------------------------------------------------------------------------- 1 | --- 2 | time: 20:03:20 3 | player: Sammy Sosa 4 | action: strike (miss) 5 | ... 6 | --- 7 | time: 20:03:47 8 | player: Sammy Sosa 9 | action: grand slam 10 | ... 11 | -------------------------------------------------------------------------------- /test/unported/spec-02-09.data: -------------------------------------------------------------------------------- 1 | --- 2 | hr: # 1998 hr ranking 3 | - Mark McGwire 4 | - Sammy Sosa 5 | rbi: 6 | # 1998 rbi ranking 7 | - Sammy Sosa 8 | - Ken Griffey 9 | -------------------------------------------------------------------------------- /test/unported/spec-02-10.data: -------------------------------------------------------------------------------- 1 | --- 2 | hr: 3 | - Mark McGwire 4 | # Following node labeled SS 5 | - &SS Sammy Sosa 6 | rbi: 7 | - *SS # Subsequent occurrence 8 | - Ken Griffey 9 | -------------------------------------------------------------------------------- /test/unported/spec-02-11.data: -------------------------------------------------------------------------------- 1 | ? - Detroit Tigers 2 | - Chicago cubs 3 | : 4 | - 2001-07-23 5 | 6 | ? [ New York Yankees, 7 | Atlanta Braves ] 8 | : [ 2001-07-02, 2001-08-12, 9 | 2001-08-14 ] 10 | -------------------------------------------------------------------------------- /test/unported/spec-02-12.data: -------------------------------------------------------------------------------- 1 | --- 2 | # products purchased 3 | - item : Super Hoop 4 | quantity: 1 5 | - item : Basketball 6 | quantity: 4 7 | - item : Big Shoes 8 | quantity: 1 9 | -------------------------------------------------------------------------------- /test/unported/spec-02-13.data: -------------------------------------------------------------------------------- 1 | # ASCII Art 2 | --- | 3 | \//||\/|| 4 | // || ||__ 5 | -------------------------------------------------------------------------------- /test/unported/spec-02-14.data: -------------------------------------------------------------------------------- 1 | --- 2 | Mark McGwire's 3 | year was crippled 4 | by a knee injury. 5 | -------------------------------------------------------------------------------- /test/unported/spec-02-15.data: -------------------------------------------------------------------------------- 1 | > 2 | Sammy Sosa completed another 3 | fine season with great stats. 4 | 5 | 63 Home Runs 6 | 0.288 Batting Average 7 | 8 | What a year! 9 | -------------------------------------------------------------------------------- /test/unported/spec-02-16.data: -------------------------------------------------------------------------------- 1 | name: Mark McGwire 2 | accomplishment: > 3 | Mark set a major league 4 | home run record in 1998. 5 | stats: | 6 | 65 Home Runs 7 | 0.278 Batting Average 8 | -------------------------------------------------------------------------------- /test/unported/spec-02-17.data: -------------------------------------------------------------------------------- 1 | unicode: "Sosa did fine.\u263A" 2 | control: "\b1998\t1999\t2000\n" 3 | hexesc: "\x13\x10 is \r\n" 4 | 5 | single: '"Howdy!" he cried.' 6 | quoted: ' # not a ''comment''.' 7 | tie-fighter: '|\-*-/|' 8 | -------------------------------------------------------------------------------- /test/unported/spec-02-18.data: -------------------------------------------------------------------------------- 1 | plain: 2 | This unquoted scalar 3 | spans many lines. 4 | 5 | quoted: "So does this 6 | quoted scalar.\n" 7 | -------------------------------------------------------------------------------- /test/unported/spec-02-19.data: -------------------------------------------------------------------------------- 1 | canonical: 12345 2 | decimal: +12,345 3 | sexagesimal: 3:25:45 4 | octal: 014 5 | hexadecimal: 0xC 6 | -------------------------------------------------------------------------------- /test/unported/spec-02-20.data: -------------------------------------------------------------------------------- 1 | canonical: 1.23015e+3 2 | exponential: 12.3015e+02 3 | sexagesimal: 20:30.15 4 | fixed: 1,230.15 5 | negative infinity: -.inf 6 | not a number: .NaN 7 | -------------------------------------------------------------------------------- /test/unported/spec-02-21.data: -------------------------------------------------------------------------------- 1 | null: ~ 2 | true: y 3 | false: n 4 | string: '12345' 5 | -------------------------------------------------------------------------------- /test/unported/spec-02-22.data: -------------------------------------------------------------------------------- 1 | canonical: 2001-12-15T02:59:43.1Z 2 | iso8601: 2001-12-14t21:59:43.10-05:00 3 | spaced: 2001-12-14 21:59:43.10 -5 4 | date: 2002-12-14 5 | -------------------------------------------------------------------------------- /test/unported/spec-02-23.data: -------------------------------------------------------------------------------- 1 | --- 2 | not-date: !!str 2002-04-28 3 | 4 | picture: !!binary | 5 | R0lGODlhDAAMAIQAAP//9/X 6 | 17unp5WZmZgAAAOfn515eXv 7 | Pz7Y6OjuDg4J+fn5OTk6enp 8 | 56enmleECcgggoBADs= 9 | 10 | application specific tag: !something | 11 | The semantics of the tag 12 | above may be different for 13 | different documents. 14 | -------------------------------------------------------------------------------- /test/unported/spec-02-24.data: -------------------------------------------------------------------------------- 1 | %TAG ! tag:clarkevans.com,2002: 2 | --- !shape 3 | # Use the ! handle for presenting 4 | # tag:clarkevans.com,2002:circle 5 | - !circle 6 | center: &ORIGIN {x: 73, y: 129} 7 | radius: 7 8 | - !line 9 | start: *ORIGIN 10 | finish: { x: 89, y: 102 } 11 | - !label 12 | start: *ORIGIN 13 | color: 0xFFEEBB 14 | text: Pretty vector drawing. 15 | -------------------------------------------------------------------------------- /test/unported/spec-02-25.data: -------------------------------------------------------------------------------- 1 | # sets are represented as a 2 | # mapping where each key is 3 | # associated with the empty string 4 | --- !!set 5 | ? Mark McGwire 6 | ? Sammy Sosa 7 | ? Ken Griff 8 | -------------------------------------------------------------------------------- /test/unported/spec-02-26.data: -------------------------------------------------------------------------------- 1 | # ordered maps are represented as 2 | # a sequence of mappings, with 3 | # each mapping having one key 4 | --- !!omap 5 | - Mark McGwire: 65 6 | - Sammy Sosa: 63 7 | - Ken Griffy: 58 8 | -------------------------------------------------------------------------------- /test/unported/spec-02-27.data: -------------------------------------------------------------------------------- 1 | --- ! 2 | invoice: 34843 3 | date : 2001-01-23 4 | bill-to: &id001 5 | given : Chris 6 | family : Dumars 7 | address: 8 | lines: | 9 | 458 Walkman Dr. 10 | Suite #292 11 | city : Royal Oak 12 | state : MI 13 | postal : 48046 14 | ship-to: *id001 15 | product: 16 | - sku : BL394D 17 | quantity : 4 18 | description : Basketball 19 | price : 450.00 20 | - sku : BL4438H 21 | quantity : 1 22 | description : Super Hoop 23 | price : 2392.00 24 | tax : 251.42 25 | total: 4443.52 26 | comments: 27 | Late afternoon is best. 28 | Backup contact is Nancy 29 | Billsmer @ 338-4338. 30 | -------------------------------------------------------------------------------- /test/unported/spec-02-28.data: -------------------------------------------------------------------------------- 1 | --- 2 | Time: 2001-11-23 15:01:42 -5 3 | User: ed 4 | Warning: 5 | This is an error message 6 | for the log file 7 | --- 8 | Time: 2001-11-23 15:02:31 -5 9 | User: ed 10 | Warning: 11 | A slightly different error 12 | message. 13 | --- 14 | Date: 2001-11-23 15:03:17 -5 15 | User: ed 16 | Fatal: 17 | Unknown variable "bar" 18 | Stack: 19 | - file: TopClass.py 20 | line: 23 21 | code: | 22 | x = MoreObject("345\n") 23 | - file: MoreClass.py 24 | line: 58 25 | code: |- 26 | foo = bar 27 | -------------------------------------------------------------------------------- /test/unported/spec-05-01-utf8.data: -------------------------------------------------------------------------------- 1 | # Comment only. 2 | -------------------------------------------------------------------------------- /test/unported/spec-05-01-utf8.empty: -------------------------------------------------------------------------------- 1 | # This stream contains no 2 | # documents, only comments. 3 | -------------------------------------------------------------------------------- /test/unported/spec-05-02-utf8.data: -------------------------------------------------------------------------------- 1 | # Invalid use of BOM 2 | # inside a 3 | # document. 4 | -------------------------------------------------------------------------------- /test/unported/spec-05-02-utf8.error: -------------------------------------------------------------------------------- 1 | ERROR: 2 | A BOM must not appear 3 | inside a document. 4 | -------------------------------------------------------------------------------- /test/unported/spec-05-03.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "sequence" 5 | : !!seq [ 6 | !!str "one", !!str "two" 7 | ], 8 | ? !!str "mapping" 9 | : !!map { 10 | ? !!str "sky" : !!str "blue", 11 | # ? !!str "sea" : !!str "green", 12 | ? !!map { ? !!str "sea" : !!str "green" } : !!null "", 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/unported/spec-05-03.data: -------------------------------------------------------------------------------- 1 | sequence: 2 | - one 3 | - two 4 | mapping: 5 | ? sky 6 | : blue 7 | ? sea : green 8 | -------------------------------------------------------------------------------- /test/unported/spec-05-04.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "sequence" 5 | : !!seq [ 6 | !!str "one", !!str "two" 7 | ], 8 | ? !!str "mapping" 9 | : !!map { 10 | ? !!str "sky" : !!str "blue", 11 | ? !!str "sea" : !!str "green", 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/unported/spec-05-04.data: -------------------------------------------------------------------------------- 1 | sequence: [ one, two, ] 2 | mapping: { sky: blue, sea: green } 3 | -------------------------------------------------------------------------------- /test/unported/spec-05-05.data: -------------------------------------------------------------------------------- 1 | # Comment only. 2 | -------------------------------------------------------------------------------- /test/unported/spec-05-05.empty: -------------------------------------------------------------------------------- 1 | # This stream contains no 2 | # documents, only comments. 3 | -------------------------------------------------------------------------------- /test/unported/spec-05-06.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "anchored" 5 | : &A1 !local "value", 6 | ? !!str "alias" 7 | : *A1, 8 | } 9 | -------------------------------------------------------------------------------- /test/unported/spec-05-06.data: -------------------------------------------------------------------------------- 1 | anchored: !local &anchor value 2 | alias: *anchor 3 | -------------------------------------------------------------------------------- /test/unported/spec-05-07.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "literal" 5 | : !!str "text\n", 6 | ? !!str "folded" 7 | : !!str "text\n", 8 | } 9 | -------------------------------------------------------------------------------- /test/unported/spec-05-07.data: -------------------------------------------------------------------------------- 1 | literal: | 2 | text 3 | folded: > 4 | text 5 | -------------------------------------------------------------------------------- /test/unported/spec-05-08.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "single" 5 | : !!str "text", 6 | ? !!str "double" 7 | : !!str "text", 8 | } 9 | -------------------------------------------------------------------------------- /test/unported/spec-05-08.data: -------------------------------------------------------------------------------- 1 | single: 'text' 2 | double: "text" 3 | -------------------------------------------------------------------------------- /test/unported/spec-05-09.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "text" 4 | -------------------------------------------------------------------------------- /test/unported/spec-05-09.data: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- text 3 | -------------------------------------------------------------------------------- /test/unported/spec-05-10.data: -------------------------------------------------------------------------------- 1 | commercial-at: @text 2 | grave-accent: `text 3 | -------------------------------------------------------------------------------- /test/unported/spec-05-10.error: -------------------------------------------------------------------------------- 1 | ERROR: 2 | Reserved indicators can't 3 | start a plain scalar. 4 | -------------------------------------------------------------------------------- /test/unported/spec-05-11.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- !!str 3 | "Generic line break (no glyph)\n\ 4 | Generic line break (glyphed)\n\ 5 | Line separator\u2028\ 6 | Paragraph separator\u2029" 7 | -------------------------------------------------------------------------------- /test/unported/spec-05-11.data: -------------------------------------------------------------------------------- 1 | | 2 | Generic line break (no glyph) 3 | Generic line break (glyphed)… Line separator
 Paragraph separator
 -------------------------------------------------------------------------------- /test/unported/spec-05-12.data: -------------------------------------------------------------------------------- 1 | # Tabs do's and don'ts: 2 | # comment: 3 | quoted: "Quoted " 4 | block: | 5 | void main() { 6 | printf("Hello, world!\n"); 7 | } 8 | elsewhere: # separation 9 | indentation, in plain scalar 10 | -------------------------------------------------------------------------------- /test/unported/spec-05-12.error: -------------------------------------------------------------------------------- 1 | ERROR: 2 | Tabs may appear inside 3 | comments and quoted or 4 | block scalar content. 5 | Tabs must not appear 6 | elsewhere, such as 7 | in indentation and 8 | separation spaces. 9 | -------------------------------------------------------------------------------- /test/unported/spec-05-13.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- !!str 3 | "Text containing \ 4 | both space and \ 5 | tab characters" 6 | -------------------------------------------------------------------------------- /test/unported/spec-05-13.data: -------------------------------------------------------------------------------- 1 | "Text containing 2 | both space and 3 | tab characters" 4 | -------------------------------------------------------------------------------- /test/unported/spec-05-14.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | "Fun with \x5C 4 | \x22 \x07 \x08 \x1B \x0C 5 | \x0A \x0D \x09 \x0B \x00 6 | \x20 \xA0 \x85 \u2028 \u2029 7 | A A A" 8 | -------------------------------------------------------------------------------- /test/unported/spec-05-14.data: -------------------------------------------------------------------------------- 1 | "Fun with \\ 2 | \" \a \b \e \f \… \n \r \t \v \0 \
 \ \_ \N \L \P \
 \x41 \u0041 \U00000041" 3 | -------------------------------------------------------------------------------- /test/unported/spec-05-15.data: -------------------------------------------------------------------------------- 1 | Bad escapes: 2 | "\c 3 | \xq-" 4 | -------------------------------------------------------------------------------- /test/unported/spec-05-15.error: -------------------------------------------------------------------------------- 1 | ERROR: 2 | - c is an invalid escaped character. 3 | - q and - are invalid hex digits. 4 | -------------------------------------------------------------------------------- /test/unported/spec-06-01.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "Not indented" 5 | : !!map { 6 | ? !!str "By one space" 7 | : !!str "By four\n spaces\n", 8 | ? !!str "Flow style" 9 | : !!seq [ 10 | !!str "By two", 11 | !!str "Also by two", 12 | !!str "Still by two", 13 | ] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/unported/spec-06-01.data: -------------------------------------------------------------------------------- 1 | # Leading comment line spaces are 2 | # neither content nor indentation. 3 | 4 | Not indented: 5 | By one space: | 6 | By four 7 | spaces 8 | Flow style: [ # Leading spaces 9 | By two, # in flow style 10 | Also by two, # are neither 11 | # Tabs are not allowed: 12 | # Still by two # content nor 13 | Still by two # content nor 14 | ] # indentation. 15 | -------------------------------------------------------------------------------- /test/unported/spec-06-02.data: -------------------------------------------------------------------------------- 1 | # Comment 2 | 3 | 4 | -------------------------------------------------------------------------------- /test/unported/spec-06-02.empty: -------------------------------------------------------------------------------- 1 | # This stream contains no 2 | # documents, only comments. 3 | -------------------------------------------------------------------------------- /test/unported/spec-06-03.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "key" 5 | : !!str "value" 6 | } 7 | -------------------------------------------------------------------------------- /test/unported/spec-06-03.data: -------------------------------------------------------------------------------- 1 | key: # Comment 2 | value 3 | -------------------------------------------------------------------------------- /test/unported/spec-06-04.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "key" 5 | : !!str "value" 6 | } 7 | -------------------------------------------------------------------------------- /test/unported/spec-06-04.data: -------------------------------------------------------------------------------- 1 | key: # Comment 2 | # lines 3 | value 4 | 5 | -------------------------------------------------------------------------------- /test/unported/spec-06-05.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!map { 5 | ? !!str "first" 6 | : !!str "Sammy", 7 | ? !!str "last" 8 | : !!str "Sosa" 9 | } 10 | : !!map { 11 | ? !!str "hr" 12 | : !!int "65", 13 | ? !!str "avg" 14 | : !!float "0.278" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/unported/spec-06-05.data: -------------------------------------------------------------------------------- 1 | { first: Sammy, last: Sosa }: 2 | # Statistics: 3 | hr: # Home runs 4 | 65 5 | avg: # Average 6 | 0.278 7 | -------------------------------------------------------------------------------- /test/unported/spec-06-06.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "plain" 5 | : !!str "text lines", 6 | ? !!str "quoted" 7 | : !!str "text lines", 8 | ? !!str "block" 9 | : !!str "text\n lines\n" 10 | } 11 | -------------------------------------------------------------------------------- /test/unported/spec-06-06.data: -------------------------------------------------------------------------------- 1 | plain: text 2 | lines 3 | quoted: "text 4 | lines" 5 | block: | 6 | text 7 | lines 8 | -------------------------------------------------------------------------------- /test/unported/spec-06-07.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!str "foo\nbar", 5 | !!str "foo\n\nbar" 6 | ] 7 | -------------------------------------------------------------------------------- /test/unported/spec-06-07.data: -------------------------------------------------------------------------------- 1 | - foo 2 | 3 | bar 4 | - |- 5 | foo 6 | 7 | bar 8 | 9 | -------------------------------------------------------------------------------- /test/unported/spec-06-08.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- !!str 3 | "specific\L\ 4 | trimmed\n\n\n\ 5 | as space" 6 | -------------------------------------------------------------------------------- /test/unported/spec-06-08.data: -------------------------------------------------------------------------------- 1 | >- 2 | specific
 trimmed… … …… as… space 3 | -------------------------------------------------------------------------------- /test/unported/spec-07-01.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- !!str 3 | "foo" 4 | -------------------------------------------------------------------------------- /test/unported/spec-07-01.data: -------------------------------------------------------------------------------- 1 | %FOO bar baz # Should be ignored 2 | # with a warning. 3 | --- "foo" 4 | -------------------------------------------------------------------------------- /test/unported/spec-07-01.skip-ext: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unported/spec-07-01.skip-ext -------------------------------------------------------------------------------- /test/unported/spec-07-02.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "foo" 4 | -------------------------------------------------------------------------------- /test/unported/spec-07-02.data: -------------------------------------------------------------------------------- 1 | %YAML 1.2 # Attempt parsing 2 | # with a warning 3 | --- 4 | "foo" 5 | -------------------------------------------------------------------------------- /test/unported/spec-07-02.skip-ext: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unported/spec-07-02.skip-ext -------------------------------------------------------------------------------- /test/unported/spec-07-03.data: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %YAML 1.1 3 | foo 4 | -------------------------------------------------------------------------------- /test/unported/spec-07-03.error: -------------------------------------------------------------------------------- 1 | ERROR: 2 | The YAML directive must only be 3 | given at most once per document. 4 | -------------------------------------------------------------------------------- /test/unported/spec-07-04.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "foo" 4 | -------------------------------------------------------------------------------- /test/unported/spec-07-04.data: -------------------------------------------------------------------------------- 1 | %TAG !yaml! tag:yaml.org,2002: 2 | --- 3 | !yaml!str "foo" 4 | -------------------------------------------------------------------------------- /test/unported/spec-07-05.data: -------------------------------------------------------------------------------- 1 | %TAG ! !foo 2 | %TAG ! !foo 3 | bar 4 | -------------------------------------------------------------------------------- /test/unported/spec-07-05.error: -------------------------------------------------------------------------------- 1 | ERROR: 2 | The TAG directive must only 3 | be given at most once per 4 | handle in the same document. 5 | -------------------------------------------------------------------------------- /test/unported/spec-07-06.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | ! "baz", 5 | ! "string" 6 | ] 7 | -------------------------------------------------------------------------------- /test/unported/spec-07-06.data: -------------------------------------------------------------------------------- 1 | %TAG ! !foo 2 | %TAG !yaml! tag:yaml.org,2002: 3 | --- 4 | - !bar "baz" 5 | - !yaml!str "string" 6 | -------------------------------------------------------------------------------- /test/unported/spec-07-07a.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | ! "bar" 4 | -------------------------------------------------------------------------------- /test/unported/spec-07-07a.data: -------------------------------------------------------------------------------- 1 | # Private application: 2 | !foo "bar" 3 | -------------------------------------------------------------------------------- /test/unported/spec-07-07b.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | ! "bar" 4 | -------------------------------------------------------------------------------- /test/unported/spec-07-07b.data: -------------------------------------------------------------------------------- 1 | # Migrated to global: 2 | %TAG ! tag:ben-kiki.org,2000:app/ 3 | --- 4 | !foo "bar" 5 | -------------------------------------------------------------------------------- /test/unported/spec-07-08.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | ! "bar", 5 | ! "string", 6 | ! "baz" 7 | ] 8 | -------------------------------------------------------------------------------- /test/unported/spec-07-08.data: -------------------------------------------------------------------------------- 1 | # Explicitly specify default settings: 2 | %TAG ! ! 3 | %TAG !! tag:yaml.org,2002: 4 | # Named handles have no default: 5 | %TAG !o! tag:ben-kiki.org,2000: 6 | --- 7 | - !foo "bar" 8 | - !!str "string" 9 | - !o!type "baz" 10 | -------------------------------------------------------------------------------- /test/unported/spec-07-09.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "foo" 4 | %YAML 1.1 5 | --- 6 | !!str "bar" 7 | %YAML 1.1 8 | --- 9 | !!str "baz" 10 | -------------------------------------------------------------------------------- /test/unported/spec-07-09.data: -------------------------------------------------------------------------------- 1 | --- 2 | foo 3 | ... 4 | # Repeated end marker. 5 | ... 6 | --- 7 | bar 8 | # No end marker. 9 | --- 10 | baz 11 | ... 12 | -------------------------------------------------------------------------------- /test/unported/spec-07-10.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "Root flow scalar" 4 | %YAML 1.1 5 | --- 6 | !!str "Root block scalar\n" 7 | %YAML 1.1 8 | --- 9 | !!map { 10 | ? !!str "foo" 11 | : !!str "bar" 12 | } 13 | --- 14 | #!!str "" 15 | !!null "" 16 | -------------------------------------------------------------------------------- /test/unported/spec-07-10.data: -------------------------------------------------------------------------------- 1 | "Root flow 2 | scalar" 3 | --- !!str > 4 | Root block 5 | scalar 6 | --- 7 | # Root collection: 8 | foo : bar 9 | ... # Is optional. 10 | --- 11 | # Explicit document may be empty. 12 | -------------------------------------------------------------------------------- /test/unported/spec-07-11.data: -------------------------------------------------------------------------------- 1 | # A stream may contain 2 | # no documents. 3 | -------------------------------------------------------------------------------- /test/unported/spec-07-11.empty: -------------------------------------------------------------------------------- 1 | # This stream contains no 2 | # documents, only comments. 3 | -------------------------------------------------------------------------------- /test/unported/spec-07-12a.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "foo" 5 | : !!str "bar" 6 | } 7 | -------------------------------------------------------------------------------- /test/unported/spec-07-12a.data: -------------------------------------------------------------------------------- 1 | # Implicit document. Root 2 | # collection (mapping) node. 3 | foo : bar 4 | -------------------------------------------------------------------------------- /test/unported/spec-07-12b.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "Text content\n" 4 | -------------------------------------------------------------------------------- /test/unported/spec-07-12b.data: -------------------------------------------------------------------------------- 1 | # Explicit document. Root 2 | # scalar (literal) node. 3 | --- | 4 | Text content 5 | -------------------------------------------------------------------------------- /test/unported/spec-07-13.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "First document" 4 | --- 5 | ! "No directives" 6 | --- 7 | ! "With directives" 8 | --- 9 | ! "Reset settings" 10 | -------------------------------------------------------------------------------- /test/unported/spec-07-13.data: -------------------------------------------------------------------------------- 1 | ! "First document" 2 | --- 3 | !foo "No directives" 4 | %TAG ! !foo 5 | --- 6 | !bar "With directives" 7 | %YAML 1.1 8 | --- 9 | !baz "Reset settings" 10 | -------------------------------------------------------------------------------- /test/unported/spec-08-01.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? &A1 !!str "foo" 5 | : !!str "bar", 6 | ? &A2 !!str "baz" 7 | : *A1 8 | } 9 | -------------------------------------------------------------------------------- /test/unported/spec-08-01.data: -------------------------------------------------------------------------------- 1 | !!str &a1 "foo" : !!str bar 2 | &a2 baz : *a1 3 | -------------------------------------------------------------------------------- /test/unported/spec-08-02.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "First occurrence" 5 | : &A !!str "Value", 6 | ? !!str "Second occurrence" 7 | : *A 8 | } 9 | -------------------------------------------------------------------------------- /test/unported/spec-08-02.data: -------------------------------------------------------------------------------- 1 | First occurrence: &anchor Value 2 | Second occurrence: *anchor 3 | -------------------------------------------------------------------------------- /test/unported/spec-08-03.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? ! "foo" 5 | : ! "baz" 6 | } 7 | -------------------------------------------------------------------------------- /test/unported/spec-08-03.data: -------------------------------------------------------------------------------- 1 | ! foo : 2 | ! baz 3 | -------------------------------------------------------------------------------- /test/unported/spec-08-04.data: -------------------------------------------------------------------------------- 1 | - ! foo 2 | - !<$:?> bar 3 | -------------------------------------------------------------------------------- /test/unported/spec-08-04.error: -------------------------------------------------------------------------------- 1 | ERROR: 2 | - Verbatim tags aren't resolved, 3 | so ! is invalid. 4 | - The $:? tag is neither a global 5 | URI tag nor a local tag starting 6 | with “!”. 7 | -------------------------------------------------------------------------------- /test/unported/spec-08-05.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | ! "foo", 5 | ! "bar", 6 | ! "baz", 7 | ] 8 | -------------------------------------------------------------------------------- /test/unported/spec-08-05.data: -------------------------------------------------------------------------------- 1 | %TAG !o! tag:ben-kiki.org,2000: 2 | --- 3 | - !local foo 4 | - !!str bar 5 | - !o!type baz 6 | -------------------------------------------------------------------------------- /test/unported/spec-08-06.data: -------------------------------------------------------------------------------- 1 | %TAG !o! tag:ben-kiki.org,2000: 2 | --- 3 | - !$a!b foo 4 | - !o! bar 5 | - !h!type baz 6 | -------------------------------------------------------------------------------- /test/unported/spec-08-06.error: -------------------------------------------------------------------------------- 1 | ERROR: 2 | - The !$a! looks like a handle. 3 | - The !o! handle has no suffix. 4 | - The !h! handle wasn't declared. 5 | -------------------------------------------------------------------------------- /test/unported/spec-08-07.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | ! "12", 5 | ! "12", 6 | # ! "12", 7 | ! "12", 8 | ] 9 | -------------------------------------------------------------------------------- /test/unported/spec-08-07.data: -------------------------------------------------------------------------------- 1 | # Assuming conventional resolution: 2 | - "12" 3 | - 12 4 | - ! 12 5 | -------------------------------------------------------------------------------- /test/unported/spec-08-08.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "foo" 5 | : !!str "bar baz" 6 | } 7 | %YAML 1.1 8 | --- 9 | !!str "foo bar" 10 | %YAML 1.1 11 | --- 12 | !!str "foo bar" 13 | %YAML 1.1 14 | --- 15 | !!str "foo\n" 16 | -------------------------------------------------------------------------------- /test/unported/spec-08-08.data: -------------------------------------------------------------------------------- 1 | --- 2 | foo: 3 | "bar 4 | baz" 5 | --- 6 | "foo 7 | bar" 8 | --- 9 | foo 10 | bar 11 | --- | 12 | foo 13 | ... 14 | -------------------------------------------------------------------------------- /test/unported/spec-08-09.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- !!map { 3 | ? !!str "scalars" : !!map { 4 | ? !!str "plain" 5 | : !!str "some text", 6 | ? !!str "quoted" 7 | : !!map { 8 | ? !!str "single" 9 | : !!str "some text", 10 | ? !!str "double" 11 | : !!str "some text" 12 | } }, 13 | ? !!str "collections" : !!map { 14 | ? !!str "sequence" : !!seq [ 15 | !!str "entry", 16 | !!map { 17 | ? !!str "key" : !!str "value" 18 | } ], 19 | ? !!str "mapping" : !!map { 20 | ? !!str "key" : !!str "value" 21 | } } } 22 | -------------------------------------------------------------------------------- /test/unported/spec-08-09.data: -------------------------------------------------------------------------------- 1 | --- 2 | scalars: 3 | plain: !!str some text 4 | quoted: 5 | single: 'some text' 6 | double: "some text" 7 | collections: 8 | sequence: !!seq [ !!str entry, 9 | # Mapping entry: 10 | key: value ] 11 | mapping: { key: value } 12 | -------------------------------------------------------------------------------- /test/unported/spec-08-10.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "block styles" : !!map { 5 | ? !!str "scalars" : !!map { 6 | ? !!str "literal" 7 | : !!str "#!/usr/bin/perl\n\ 8 | print \"Hello, 9 | world!\\n\";\n", 10 | ? !!str "folded" 11 | : !!str "This sentence 12 | is false.\n" 13 | }, 14 | ? !!str "collections" : !!map { 15 | ? !!str "sequence" : !!seq [ 16 | !!str "entry", 17 | !!map { 18 | ? !!str "key" : !!str "value" 19 | } 20 | ], 21 | ? !!str "mapping" : !!map { 22 | ? !!str "key" : !!str "value" 23 | } } } } 24 | -------------------------------------------------------------------------------- /test/unported/spec-08-10.data: -------------------------------------------------------------------------------- 1 | block styles: 2 | scalars: 3 | literal: !!str | 4 | #!/usr/bin/perl 5 | print "Hello, world!\n"; 6 | folded: > 7 | This sentence 8 | is false. 9 | collections: !!map 10 | sequence: !!seq # Entry: 11 | - entry # Plain 12 | # Mapping entry: 13 | - key: value 14 | mapping: 15 | key: value 16 | -------------------------------------------------------------------------------- /test/unported/spec-08-11.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "First occurrence" 5 | : &A !!str "Value", 6 | ? !!str "Second occurrence" 7 | : *A 8 | } 9 | -------------------------------------------------------------------------------- /test/unported/spec-08-11.data: -------------------------------------------------------------------------------- 1 | First occurrence: &anchor Value 2 | Second occurrence: *anchor 3 | -------------------------------------------------------------------------------- /test/unported/spec-08-12.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!str "Without properties", 5 | &A !!str "Anchored", 6 | !!str "Tagged", 7 | *A, 8 | !!str "", 9 | !!str "", 10 | ] 11 | -------------------------------------------------------------------------------- /test/unported/spec-08-12.data: -------------------------------------------------------------------------------- 1 | [ 2 | Without properties, 3 | &anchor "Anchored", 4 | !!str 'Tagged', 5 | *anchor, # Alias node 6 | !!str , # Empty plain scalar 7 | '', # Empty plain scalar 8 | ] 9 | -------------------------------------------------------------------------------- /test/unported/spec-08-13.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "foo" 5 | # : !!str "", 6 | # ? !!str "" 7 | : !!null "", 8 | ? !!null "" 9 | : !!str "bar", 10 | } 11 | -------------------------------------------------------------------------------- /test/unported/spec-08-13.data: -------------------------------------------------------------------------------- 1 | { 2 | ? foo :, 3 | ? : bar, 4 | } 5 | -------------------------------------------------------------------------------- /test/unported/spec-08-13.skip-ext: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unported/spec-08-13.skip-ext -------------------------------------------------------------------------------- /test/unported/spec-08-14.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!str "flow in block", 5 | !!str "Block scalar\n", 6 | !!map { 7 | ? !!str "foo" 8 | : !!str "bar" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test/unported/spec-08-14.data: -------------------------------------------------------------------------------- 1 | - "flow in block" 2 | - > 3 | Block scalar 4 | - !!map # Block collection 5 | foo : bar 6 | -------------------------------------------------------------------------------- /test/unported/spec-08-15.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!null "", 5 | !!map { 6 | ? !!str "foo" 7 | : !!null "", 8 | ? !!null "" 9 | : !!str "bar", 10 | } 11 | ] 12 | -------------------------------------------------------------------------------- /test/unported/spec-08-15.data: -------------------------------------------------------------------------------- 1 | - # Empty plain scalar 2 | - ? foo 3 | : 4 | ? 5 | : bar 6 | -------------------------------------------------------------------------------- /test/unported/spec-09-01.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "simple key" 5 | : !!map { 6 | ? !!str "also simple" 7 | : !!str "value", 8 | ? !!str "not a simple key" 9 | : !!str "any value" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/unported/spec-09-01.data: -------------------------------------------------------------------------------- 1 | "simple key" : { 2 | "also simple" : value, 3 | ? "not a 4 | simple key" : "any 5 | value" 6 | } 7 | -------------------------------------------------------------------------------- /test/unported/spec-09-02.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "as space \ 4 | trimmed\n\ 5 | specific\L\n\ 6 | escaped\t\n\ 7 | none" 8 | -------------------------------------------------------------------------------- /test/unported/spec-09-02.data: -------------------------------------------------------------------------------- 1 | "as space 2 | trimmed 3 | 4 | specific
 5 | escaped \
 6 | none" 7 | -------------------------------------------------------------------------------- /test/unported/spec-09-03.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!str " last", 5 | !!str " last", 6 | !!str " \tfirst last", 7 | ] 8 | -------------------------------------------------------------------------------- /test/unported/spec-09-03.data: -------------------------------------------------------------------------------- 1 | - " 2 | last" 3 | - " 4 | last" 5 | - " first 6 | last" 7 | -------------------------------------------------------------------------------- /test/unported/spec-09-04.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "first \ 4 | inner 1 \ 5 | inner 2 \ 6 | last" 7 | -------------------------------------------------------------------------------- /test/unported/spec-09-04.data: -------------------------------------------------------------------------------- 1 | "first 2 | inner 1 3 | \ inner 2 \ 4 | last" 5 | -------------------------------------------------------------------------------- /test/unported/spec-09-05.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!str "first ", 5 | !!str "first\nlast", 6 | !!str "first inner \tlast", 7 | ] 8 | -------------------------------------------------------------------------------- /test/unported/spec-09-05.data: -------------------------------------------------------------------------------- 1 | - "first 2 | " 3 | - "first 4 | 5 | last" 6 | - "first 7 | inner 8 | \ last" 9 | -------------------------------------------------------------------------------- /test/unported/spec-09-06.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "here's to \"quotes\"" 4 | -------------------------------------------------------------------------------- /test/unported/spec-09-06.data: -------------------------------------------------------------------------------- 1 | 'here''s to "quotes"' 2 | -------------------------------------------------------------------------------- /test/unported/spec-09-07.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "simple key" 5 | : !!map { 6 | ? !!str "also simple" 7 | : !!str "value", 8 | ? !!str "not a simple key" 9 | : !!str "any value" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/unported/spec-09-07.data: -------------------------------------------------------------------------------- 1 | 'simple key' : { 2 | 'also simple' : value, 3 | ? 'not a 4 | simple key' : 'any 5 | value' 6 | } 7 | -------------------------------------------------------------------------------- /test/unported/spec-09-08.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "as space \ 4 | trimmed\n\ 5 | specific\L\n\ 6 | none" 7 | -------------------------------------------------------------------------------- /test/unported/spec-09-08.data: -------------------------------------------------------------------------------- 1 | 'as space … trimmed …… specific
… none' 2 | -------------------------------------------------------------------------------- /test/unported/spec-09-09.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!str " last", 5 | !!str " last", 6 | !!str " \tfirst last", 7 | ] 8 | -------------------------------------------------------------------------------- /test/unported/spec-09-09.data: -------------------------------------------------------------------------------- 1 | - ' 2 | last' 3 | - ' 4 | last' 5 | - ' first 6 | last' 7 | -------------------------------------------------------------------------------- /test/unported/spec-09-10.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "first \ 4 | inner \ 5 | last" 6 | -------------------------------------------------------------------------------- /test/unported/spec-09-10.data: -------------------------------------------------------------------------------- 1 | 'first 2 | inner 3 | last' 4 | -------------------------------------------------------------------------------- /test/unported/spec-09-11.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!str "first ", 5 | !!str "first\nlast", 6 | ] 7 | -------------------------------------------------------------------------------- /test/unported/spec-09-11.data: -------------------------------------------------------------------------------- 1 | - 'first 2 | ' 3 | - 'first 4 | 5 | last' 6 | -------------------------------------------------------------------------------- /test/unported/spec-09-12.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!str "::std::vector", 5 | !!str "Up, up, and away!", 6 | !!int "-123", 7 | !!seq [ 8 | !!str "::std::vector", 9 | !!str "Up, up, and away!", 10 | !!int "-123", 11 | ] 12 | ] 13 | -------------------------------------------------------------------------------- /test/unported/spec-09-12.data: -------------------------------------------------------------------------------- 1 | # Outside flow collection: 2 | - ::std::vector 3 | - Up, up, and away! 4 | - -123 5 | # Inside flow collection: 6 | - [ '::std::vector', 7 | "Up, up, and away!", 8 | -123 ] 9 | -------------------------------------------------------------------------------- /test/unported/spec-09-13.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "simple key" 5 | : !!map { 6 | ? !!str "also simple" 7 | : !!str "value", 8 | ? !!str "not a simple key" 9 | : !!str "any value" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/unported/spec-09-13.data: -------------------------------------------------------------------------------- 1 | simple key : { 2 | also simple : value, 3 | ? not a 4 | simple key : any 5 | value 6 | } 7 | -------------------------------------------------------------------------------- /test/unported/spec-09-14.data: -------------------------------------------------------------------------------- 1 | --- 2 | --- ||| : foo 3 | ... >>>: bar 4 | --- 5 | [ 6 | --- 7 | , 8 | ... , 9 | { 10 | --- : 11 | ... # Nested 12 | } 13 | ] 14 | ... 15 | -------------------------------------------------------------------------------- /test/unported/spec-09-14.error: -------------------------------------------------------------------------------- 1 | ERROR: 2 | The --- and ... document 3 | start and end markers must 4 | not be specified as the 5 | first content line of a 6 | non-indented plain scalar. 7 | -------------------------------------------------------------------------------- /test/unported/spec-09-15.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "---" 5 | : !!str "foo", 6 | ? !!str "..." 7 | : !!str "bar" 8 | } 9 | %YAML 1.1 10 | --- 11 | !!seq [ 12 | !!str "---", 13 | !!str "...", 14 | !!map { 15 | ? !!str "---" 16 | : !!str "..." 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test/unported/spec-09-15.data: -------------------------------------------------------------------------------- 1 | --- 2 | "---" : foo 3 | ...: bar 4 | --- 5 | [ 6 | ---, 7 | ..., 8 | { 9 | ? --- 10 | : ... 11 | } 12 | ] 13 | ... 14 | -------------------------------------------------------------------------------- /test/unported/spec-09-16.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "as space \ 4 | trimmed\n\ 5 | specific\L\n\ 6 | none" 7 | -------------------------------------------------------------------------------- /test/unported/spec-09-16.data: -------------------------------------------------------------------------------- 1 | # Tabs are confusing: 2 | # as space/trimmed/specific/none 3 | as space … trimmed …… specific
… none 4 | -------------------------------------------------------------------------------- /test/unported/spec-09-17.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "first line\n\ 4 | more line" 5 | -------------------------------------------------------------------------------- /test/unported/spec-09-17.data: -------------------------------------------------------------------------------- 1 | first line 2 | 3 | more line 4 | -------------------------------------------------------------------------------- /test/unported/spec-09-18.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!str "literal\n", 5 | !!str " folded\n", 6 | !!str "keep\n\n", 7 | !!str " strip", 8 | ] 9 | -------------------------------------------------------------------------------- /test/unported/spec-09-18.data: -------------------------------------------------------------------------------- 1 | - | # Just the style 2 | literal 3 | - >1 # Indentation indicator 4 | folded 5 | - |+ # Chomping indicator 6 | keep 7 | 8 | - >-1 # Both indicators 9 | strip 10 | -------------------------------------------------------------------------------- /test/unported/spec-09-19.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!str "literal\n", 5 | !!str "folded\n", 6 | ] 7 | -------------------------------------------------------------------------------- /test/unported/spec-09-19.data: -------------------------------------------------------------------------------- 1 | - | 2 | literal 3 | - > 4 | folded 5 | -------------------------------------------------------------------------------- /test/unported/spec-09-20.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!str "detected\n", 5 | !!str "\n\n# detected\n", 6 | !!str " explicit\n", 7 | !!str "\t\ndetected\n", 8 | ] 9 | -------------------------------------------------------------------------------- /test/unported/spec-09-20.data: -------------------------------------------------------------------------------- 1 | - | 2 | detected 3 | - > 4 | 5 | 6 | # detected 7 | - |1 8 | explicit 9 | - > 10 | 11 | detected 12 | -------------------------------------------------------------------------------- /test/unported/spec-09-20.skip-ext: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unported/spec-09-20.skip-ext -------------------------------------------------------------------------------- /test/unported/spec-09-21.data: -------------------------------------------------------------------------------- 1 | - | 2 | 3 | text 4 | - > 5 | text 6 | text 7 | - |1 8 | text 9 | -------------------------------------------------------------------------------- /test/unported/spec-09-21.error: -------------------------------------------------------------------------------- 1 | ERROR: 2 | - A leading all-space line must 3 | not have too many spaces. 4 | - A following text line must 5 | not be less indented. 6 | - The text is less indented 7 | than the indicated level. 8 | -------------------------------------------------------------------------------- /test/unported/spec-09-22.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "strip" 5 | : !!str "text", 6 | ? !!str "clip" 7 | : !!str "text\n", 8 | ? !!str "keep" 9 | : !!str "text\L", 10 | } 11 | -------------------------------------------------------------------------------- /test/unported/spec-09-22.data: -------------------------------------------------------------------------------- 1 | strip: |- 2 | text
clip: | 3 | text…keep: |+ 4 | text
 -------------------------------------------------------------------------------- /test/unported/spec-09-23.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "strip" 5 | : !!str "# text", 6 | ? !!str "clip" 7 | : !!str "# text\n", 8 | ? !!str "keep" 9 | : !!str "# text\L\n", 10 | } 11 | -------------------------------------------------------------------------------- /test/unported/spec-09-23.data: -------------------------------------------------------------------------------- 1 | # Strip 2 | # Comments: 3 | strip: |- 4 | # text
 
 # Clip 5 | # comments: 6 | …clip: | 7 | # text… 
 # Keep 8 | # comments: 9 | …keep: |+ 10 | # text
… # Trail 11 | # comments. 12 | -------------------------------------------------------------------------------- /test/unported/spec-09-24.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "strip" 5 | : !!str "", 6 | ? !!str "clip" 7 | : !!str "", 8 | ? !!str "keep" 9 | : !!str "\n", 10 | } 11 | -------------------------------------------------------------------------------- /test/unported/spec-09-24.data: -------------------------------------------------------------------------------- 1 | strip: >- 2 | 3 | clip: > 4 | 5 | keep: |+ 6 | 7 | -------------------------------------------------------------------------------- /test/unported/spec-09-25.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "literal\n\ 4 | \ttext\n" 5 | -------------------------------------------------------------------------------- /test/unported/spec-09-25.data: -------------------------------------------------------------------------------- 1 | | # Simple block scalar 2 | literal 3 | text 4 | -------------------------------------------------------------------------------- /test/unported/spec-09-26.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "\n\nliteral\n\ntext\n" 4 | -------------------------------------------------------------------------------- /test/unported/spec-09-26.data: -------------------------------------------------------------------------------- 1 | | 2 | 3 | 4 | literal 5 | 6 | text 7 | 8 | # Comment 9 | -------------------------------------------------------------------------------- /test/unported/spec-09-27.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "\n\nliteral\n\ntext\n" 4 | -------------------------------------------------------------------------------- /test/unported/spec-09-27.data: -------------------------------------------------------------------------------- 1 | | 2 | 3 | 4 | literal 5 | 6 | text 7 | 8 | # Comment 9 | -------------------------------------------------------------------------------- /test/unported/spec-09-28.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "\n\nliteral\n\ntext\n" 4 | -------------------------------------------------------------------------------- /test/unported/spec-09-28.data: -------------------------------------------------------------------------------- 1 | | 2 | 3 | 4 | literal 5 | 6 | text 7 | 8 | # Comment 9 | -------------------------------------------------------------------------------- /test/unported/spec-09-29.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "folded text\n\ 4 | \tlines\n" 5 | -------------------------------------------------------------------------------- /test/unported/spec-09-29.data: -------------------------------------------------------------------------------- 1 | > # Simple folded scalar 2 | folded 3 | text 4 | lines 5 | -------------------------------------------------------------------------------- /test/unported/spec-09-30.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "folded line\n\ 4 | next line\n\n\ 5 | \ * bullet\n\ 6 | \ * list\n\n\ 7 | last line\n" 8 | -------------------------------------------------------------------------------- /test/unported/spec-09-30.data: -------------------------------------------------------------------------------- 1 | > 2 | folded 3 | line 4 | 5 | next 6 | line 7 | 8 | * bullet 9 | * list 10 | 11 | last 12 | line 13 | 14 | # Comment 15 | -------------------------------------------------------------------------------- /test/unported/spec-09-31.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "folded line\n\ 4 | next line\n\n\ 5 | \ * bullet\n\ 6 | \ * list\n\n\ 7 | last line\n" 8 | -------------------------------------------------------------------------------- /test/unported/spec-09-31.data: -------------------------------------------------------------------------------- 1 | > 2 | folded 3 | line 4 | 5 | next 6 | line 7 | 8 | * bullet 9 | * list 10 | 11 | last 12 | line 13 | 14 | # Comment 15 | -------------------------------------------------------------------------------- /test/unported/spec-09-32.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "folded line\n\ 4 | next line\n\n\ 5 | \ * bullet\n\ 6 | \ * list\n\n\ 7 | last line\n" 8 | -------------------------------------------------------------------------------- /test/unported/spec-09-32.data: -------------------------------------------------------------------------------- 1 | > 2 | folded 3 | line 4 | 5 | next 6 | line 7 | 8 | * bullet 9 | * list 10 | 11 | last 12 | line 13 | 14 | # Comment 15 | -------------------------------------------------------------------------------- /test/unported/spec-09-33.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!str "folded line\n\ 4 | next line\n\n\ 5 | \ * bullet\n\ 6 | \ * list\n\n\ 7 | last line\n" 8 | -------------------------------------------------------------------------------- /test/unported/spec-09-33.data: -------------------------------------------------------------------------------- 1 | > 2 | folded 3 | line 4 | 5 | next 6 | line 7 | 8 | * bullet 9 | * list 10 | 11 | last 12 | line 13 | 14 | # Comment 15 | -------------------------------------------------------------------------------- /test/unported/spec-10-01.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!seq [ 5 | !!str "inner", 6 | !!str "inner", 7 | ], 8 | !!seq [ 9 | !!str "inner", 10 | !!str "last", 11 | ], 12 | ] 13 | -------------------------------------------------------------------------------- /test/unported/spec-10-01.data: -------------------------------------------------------------------------------- 1 | - [ inner, inner, ] 2 | - [inner,last] 3 | -------------------------------------------------------------------------------- /test/unported/spec-10-02.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!str "double quoted", 5 | !!str "single quoted", 6 | !!str "plain text", 7 | !!seq [ 8 | !!str "nested", 9 | ], 10 | !!map { 11 | ? !!str "single" 12 | : !!str "pair" 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test/unported/spec-10-02.data: -------------------------------------------------------------------------------- 1 | [ 2 | "double 3 | quoted", 'single 4 | quoted', 5 | plain 6 | text, [ nested ], 7 | single: pair , 8 | ] 9 | -------------------------------------------------------------------------------- /test/unported/spec-10-03.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "block" 5 | : !!seq [ 6 | !!str "one", 7 | !!map { 8 | ? !!str "two" 9 | : !!str "three" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /test/unported/spec-10-03.data: -------------------------------------------------------------------------------- 1 | block: # Block 2 | # sequence 3 | - one 4 | - two : three 5 | -------------------------------------------------------------------------------- /test/unported/spec-10-04.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "block" 5 | : !!seq [ 6 | !!str "one", 7 | !!seq [ 8 | !!str "two" 9 | ] 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/unported/spec-10-04.data: -------------------------------------------------------------------------------- 1 | block: 2 | - one 3 | - 4 | - two 5 | -------------------------------------------------------------------------------- /test/unported/spec-10-05.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!null "", 5 | !!str "block node\n", 6 | !!seq [ 7 | !!str "one", 8 | !!str "two", 9 | ], 10 | !!map { 11 | ? !!str "one" 12 | : !!str "two", 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test/unported/spec-10-05.data: -------------------------------------------------------------------------------- 1 | - # Empty 2 | - | 3 | block node 4 | - - one # in-line 5 | - two # sequence 6 | - one: two # in-line 7 | # mapping 8 | -------------------------------------------------------------------------------- /test/unported/spec-10-06.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!map { 5 | ? !!str "inner" 6 | : !!str "entry", 7 | ? !!str "also" 8 | : !!str "inner" 9 | }, 10 | !!map { 11 | ? !!str "inner" 12 | : !!str "entry", 13 | ? !!str "last" 14 | : !!str "entry" 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /test/unported/spec-10-06.data: -------------------------------------------------------------------------------- 1 | - { inner : entry , also: inner , } 2 | - {inner: entry,last : entry} 3 | -------------------------------------------------------------------------------- /test/unported/spec-10-07.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!null "" 5 | : !!str "value", 6 | ? !!str "explicit key" 7 | : !!str "value", 8 | ? !!str "simple key" 9 | : !!str "value", 10 | ? !!seq [ 11 | !!str "collection", 12 | !!str "simple", 13 | !!str "key" 14 | ] 15 | : !!str "value" 16 | } 17 | -------------------------------------------------------------------------------- /test/unported/spec-10-07.data: -------------------------------------------------------------------------------- 1 | { 2 | ? : value, # Empty key 3 | ? explicit 4 | key: value, 5 | simple key : value, 6 | [ collection, simple, key ]: value 7 | } 8 | -------------------------------------------------------------------------------- /test/unported/spec-10-08.error: -------------------------------------------------------------------------------- 1 | ERROR: 2 | - A simple key is restricted 3 | to only one line. 4 | - A simple key must not be 5 | longer than 1024 characters. 6 | -------------------------------------------------------------------------------- /test/unported/spec-10-09.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "key" 5 | : !!str "value", 6 | ? !!str "empty" 7 | : !!null "", 8 | } 9 | -------------------------------------------------------------------------------- /test/unported/spec-10-09.data: -------------------------------------------------------------------------------- 1 | { 2 | key : value, 3 | empty: # empty value↓ 4 | } 5 | -------------------------------------------------------------------------------- /test/unported/spec-10-10.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "explicit key1" 5 | : !!str "explicit value", 6 | ? !!str "explicit key2" 7 | : !!null "", 8 | ? !!str "explicit key3" 9 | : !!null "", 10 | ? !!str "simple key1" 11 | : !!str "explicit value", 12 | ? !!str "simple key2" 13 | : !!null "", 14 | ? !!str "simple key3" 15 | : !!null "", 16 | } 17 | -------------------------------------------------------------------------------- /test/unported/spec-10-10.data: -------------------------------------------------------------------------------- 1 | { 2 | ? explicit key1 : explicit value, 3 | ? explicit key2 : , # Explicit empty 4 | ? explicit key3, # Empty value 5 | simple key1 : explicit value, 6 | simple key2 : , # Explicit empty 7 | simple key3, # Empty value 8 | } 9 | -------------------------------------------------------------------------------- /test/unported/spec-10-11.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!map { 5 | ? !!str "explicit key1" 6 | : !!str "explicit value", 7 | }, 8 | !!map { 9 | ? !!str "explicit key2" 10 | : !!null "", 11 | }, 12 | !!map { 13 | ? !!str "explicit key3" 14 | : !!null "", 15 | }, 16 | !!map { 17 | ? !!str "simple key1" 18 | : !!str "explicit value", 19 | }, 20 | !!map { 21 | ? !!str "simple key2" 22 | : !!null "", 23 | }, 24 | ] 25 | -------------------------------------------------------------------------------- /test/unported/spec-10-11.data: -------------------------------------------------------------------------------- 1 | [ 2 | ? explicit key1 : explicit value, 3 | ? explicit key2 : , # Explicit empty 4 | ? explicit key3, # Implicit empty 5 | simple key1 : explicit value, 6 | simple key2 : , # Explicit empty 7 | ] 8 | -------------------------------------------------------------------------------- /test/unported/spec-10-12.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "block" 5 | : !!map { 6 | ? !!str "key" 7 | : !!str "value" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/unported/spec-10-12.data: -------------------------------------------------------------------------------- 1 | block: # Block 2 | # mapping 3 | key: value 4 | -------------------------------------------------------------------------------- /test/unported/spec-10-13.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "explicit key" 5 | : !!null "", 6 | ? !!str "block key\n" 7 | : !!seq [ 8 | !!str "one", 9 | !!str "two", 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/unported/spec-10-13.data: -------------------------------------------------------------------------------- 1 | ? explicit key # implicit value 2 | ? | 3 | block key 4 | : - one # explicit in-line 5 | - two # block value 6 | -------------------------------------------------------------------------------- /test/unported/spec-10-14.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!map { 4 | ? !!str "plain key" 5 | : !!null "", 6 | ? !!str "quoted key" 7 | : !!seq [ 8 | !!str "one", 9 | !!str "two", 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/unported/spec-10-14.data: -------------------------------------------------------------------------------- 1 | plain key: # empty value 2 | "quoted key": 3 | - one # explicit next-line 4 | - two # block value 5 | -------------------------------------------------------------------------------- /test/unported/spec-10-15.canonical: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | !!seq [ 4 | !!map { 5 | ? !!str "sun" 6 | : !!str "yellow" 7 | }, 8 | !!map { 9 | ? !!map { 10 | ? !!str "earth" 11 | : !!str "blue" 12 | } 13 | : !!map { 14 | ? !!str "moon" 15 | : !!str "white" 16 | } 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test/unported/spec-10-15.data: -------------------------------------------------------------------------------- 1 | - sun: yellow 2 | - ? earth: blue 3 | : moon: white 4 | -------------------------------------------------------------------------------- /test/unported/tags.events: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart 3 | - !SequenceStart 4 | - !Scalar { value: 'data' } 5 | #- !Scalar { tag: '!', value: 'data' } 6 | - !Scalar { tag: 'tag:yaml.org,2002:str', value: 'data' } 7 | - !Scalar { tag: '!myfunnytag', value: 'data' } 8 | - !Scalar { tag: '!my!ugly!tag', value: 'data' } 9 | - !Scalar { tag: 'tag:my.domain.org,2002:data!? #', value: 'data' } 10 | - !SequenceEnd 11 | - !DocumentEnd 12 | - !StreamEnd 13 | -------------------------------------------------------------------------------- /test/unported/unknown.dumper-error: -------------------------------------------------------------------------------- 1 | yaml.safe_dump(object) 2 | -------------------------------------------------------------------------------- /test/unported/unsupported-version.emitter-error: -------------------------------------------------------------------------------- 1 | - !StreamStart 2 | - !DocumentStart { version: [5,6] } 3 | - !Scalar { value: foo } 4 | - !DocumentEnd 5 | - !StreamEnd 6 | -------------------------------------------------------------------------------- /test/unsupported/bool.detect: -------------------------------------------------------------------------------- 1 | tag:yaml.org,2002:bool 2 | -------------------------------------------------------------------------------- /test/unsupported/colon-in-flow-context.loader-error: -------------------------------------------------------------------------------- 1 | { foo:bar } 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-bool.code: -------------------------------------------------------------------------------- 1 | [ True, False ] 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-bool.data: -------------------------------------------------------------------------------- 1 | [ !!python/bool True, !!python/bool False ] 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-bytes-py3.code: -------------------------------------------------------------------------------- 1 | b'some binary data' 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-bytes-py3.data: -------------------------------------------------------------------------------- 1 | --- !!python/bytes 'c29tZSBiaW5hcnkgZGF0YQ==' 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-complex.code: -------------------------------------------------------------------------------- 1 | [0.5+0j, 0.5+0.5j, 0.5j, -0.5+0.5j, -0.5+0j, -0.5-0.5j, -0.5j, 0.5-0.5j] 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-complex.data: -------------------------------------------------------------------------------- 1 | - !!python/complex 0.5+0j 2 | - !!python/complex 0.5+0.5j 3 | - !!python/complex 0.5j 4 | - !!python/complex -0.5+0.5j 5 | - !!python/complex -0.5+0j 6 | - !!python/complex -0.5-0.5j 7 | - !!python/complex -0.5j 8 | - !!python/complex 0.5-0.5j 9 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-float.code: -------------------------------------------------------------------------------- 1 | 123.456 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-float.data: -------------------------------------------------------------------------------- 1 | !!python/float 123.456 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-int.code: -------------------------------------------------------------------------------- 1 | 123 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-int.data: -------------------------------------------------------------------------------- 1 | !!python/int 123 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-long-short-py2.code: -------------------------------------------------------------------------------- 1 | 123L 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-long-short-py2.data: -------------------------------------------------------------------------------- 1 | !!python/long 123 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-long-short-py3.code: -------------------------------------------------------------------------------- 1 | 123 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-long-short-py3.data: -------------------------------------------------------------------------------- 1 | !!python/long 123 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-name-module.code: -------------------------------------------------------------------------------- 1 | [str, yaml.Loader, yaml.dump, abs, yaml.tokens] 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-name-module.data: -------------------------------------------------------------------------------- 1 | - !!python/name:str 2 | - !!python/name:yaml.Loader 3 | - !!python/name:yaml.dump 4 | - !!python/name:abs 5 | - !!python/module:yaml.tokens 6 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-none.code: -------------------------------------------------------------------------------- 1 | None 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-none.data: -------------------------------------------------------------------------------- 1 | !!python/none 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-object.code: -------------------------------------------------------------------------------- 1 | [ 2 | AnObject(1, 'two', [3,3,3]), 3 | AnInstance(1, 'two', [3,3,3]), 4 | 5 | AnObject(1, 'two', [3,3,3]), 6 | AnInstance(1, 'two', [3,3,3]), 7 | 8 | AState(1, 'two', [3,3,3]), 9 | ACustomState(1, 'two', [3,3,3]), 10 | 11 | InitArgs(1, 'two', [3,3,3]), 12 | InitArgsWithState(1, 'two', [3,3,3]), 13 | 14 | NewArgs(1, 'two', [3,3,3]), 15 | NewArgsWithState(1, 'two', [3,3,3]), 16 | 17 | Reduce(1, 'two', [3,3,3]), 18 | ReduceWithState(1, 'two', [3,3,3]), 19 | 20 | MyInt(3), 21 | MyList(3), 22 | MyDict(3), 23 | ] 24 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-str-ascii.code: -------------------------------------------------------------------------------- 1 | "ascii string" 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-str-ascii.data: -------------------------------------------------------------------------------- 1 | --- !!python/str "ascii string" 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-str-utf8-py2.code: -------------------------------------------------------------------------------- 1 | u'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430'.encode('utf-8') 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-str-utf8-py2.data: -------------------------------------------------------------------------------- 1 | --- !!python/str "Это уникодная строка" 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-str-utf8-py3.code: -------------------------------------------------------------------------------- 1 | '\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-str-utf8-py3.data: -------------------------------------------------------------------------------- 1 | --- !!python/str "Это уникодная строка" 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-tuple-list-dict.code: -------------------------------------------------------------------------------- 1 | [ 2 | [1, 2, 3, 4], 3 | (1, 2, 3, 4), 4 | {1: 2, 3: 4}, 5 | {(0,0): 0, (0,1): 1, (1,0): 1, (1,1): 0}, 6 | ] 7 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-tuple-list-dict.data: -------------------------------------------------------------------------------- 1 | - !!python/list [1, 2, 3, 4] 2 | - !!python/tuple [1, 2, 3, 4] 3 | - !!python/dict {1: 2, 3: 4} 4 | - !!python/dict 5 | !!python/tuple [0,0]: 0 6 | !!python/tuple [0,1]: 1 7 | !!python/tuple [1,0]: 1 8 | !!python/tuple [1,1]: 0 9 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-unicode-ascii-py2.code: -------------------------------------------------------------------------------- 1 | u"ascii string" 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-unicode-ascii-py2.data: -------------------------------------------------------------------------------- 1 | --- !!python/unicode "ascii string" 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-unicode-ascii-py3.code: -------------------------------------------------------------------------------- 1 | "ascii string" 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-unicode-ascii-py3.data: -------------------------------------------------------------------------------- 1 | --- !!python/unicode "ascii string" 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-unicode-utf8-py2.code: -------------------------------------------------------------------------------- 1 | u'\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-unicode-utf8-py2.data: -------------------------------------------------------------------------------- 1 | --- !!python/unicode "Это уникодная строка" 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-unicode-utf8-py3.code: -------------------------------------------------------------------------------- 1 | '\u042d\u0442\u043e \u0443\u043d\u0438\u043a\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430' 2 | -------------------------------------------------------------------------------- /test/unsupported/construct-python-unicode-utf8-py3.data: -------------------------------------------------------------------------------- 1 | --- !!python/unicode "Это уникодная строка" 2 | -------------------------------------------------------------------------------- /test/unsupported/duplicate-anchor-1.loader-error: -------------------------------------------------------------------------------- 1 | - &foo bar 2 | - &bar bar 3 | - &foo bar 4 | -------------------------------------------------------------------------------- /test/unsupported/duplicate-anchor-2.loader-error: -------------------------------------------------------------------------------- 1 | &foo [1, 2, 3, &foo 4] 2 | -------------------------------------------------------------------------------- /test/unsupported/duplicate-mapping-key.data: -------------------------------------------------------------------------------- 1 | --- 2 | &anchor foo: 3 | foo: bar 4 | *anchor: duplicate key 5 | baz: bat 6 | *anchor: duplicate key 7 | -------------------------------------------------------------------------------- /test/unsupported/empty-python-module.loader-error: -------------------------------------------------------------------------------- 1 | --- !!python:module: 2 | -------------------------------------------------------------------------------- /test/unsupported/empty-python-name.loader-error: -------------------------------------------------------------------------------- 1 | --- !!python/name: empty 2 | -------------------------------------------------------------------------------- /test/unsupported/float-representer-2.3-bug.code: -------------------------------------------------------------------------------- 1 | { 2 | # 0.0: 0, 3 | 1.0: 1, 4 | 1e300000: +10, 5 | -1e300000: -10, 6 | 1e300000/1e300000: 100, 7 | } 8 | -------------------------------------------------------------------------------- /test/unsupported/float-representer-2.3-bug.data: -------------------------------------------------------------------------------- 1 | #0.0: # hash(0) == hash(nan) and 0 == nan in Python 2.3 2 | 1.0: 1 3 | +.inf: 10 4 | -.inf: -10 5 | .nan: 100 6 | -------------------------------------------------------------------------------- /test/unsupported/float.detect: -------------------------------------------------------------------------------- 1 | tag:yaml.org,2002:float 2 | -------------------------------------------------------------------------------- /test/unsupported/function.detect: -------------------------------------------------------------------------------- 1 | tag:yaml.org,2002:js/function 2 | -------------------------------------------------------------------------------- /test/unsupported/int.detect: -------------------------------------------------------------------------------- 1 | tag:yaml.org,2002:int 2 | -------------------------------------------------------------------------------- /test/unsupported/invalid-anchor-1.loader-error: -------------------------------------------------------------------------------- 1 | --- &? foo # we allow only ascii and numeric characters in anchor names. 2 | -------------------------------------------------------------------------------- /test/unsupported/invalid-python-bytes-2-py3.loader-error: -------------------------------------------------------------------------------- 1 | --- !!python/bytes 2 | двоичные данные в base64 3 | -------------------------------------------------------------------------------- /test/unsupported/invalid-python-bytes-py3.loader-error: -------------------------------------------------------------------------------- 1 | --- !!python/bytes 2 | binary data encoded in base64 should be here. 3 | -------------------------------------------------------------------------------- /test/unsupported/invalid-python-module-kind.loader-error: -------------------------------------------------------------------------------- 1 | --- !!python/module:sys { must, be, scalar } 2 | -------------------------------------------------------------------------------- /test/unsupported/invalid-python-module-value.loader-error: -------------------------------------------------------------------------------- 1 | --- !!python/module:sys "non-empty value" 2 | -------------------------------------------------------------------------------- /test/unsupported/invalid-python-module.loader-error: -------------------------------------------------------------------------------- 1 | --- !!python/module:no.such.module 2 | -------------------------------------------------------------------------------- /test/unsupported/invalid-python-name-kind.loader-error: -------------------------------------------------------------------------------- 1 | --- !!python/name:sys.modules {} 2 | -------------------------------------------------------------------------------- /test/unsupported/invalid-python-name-module-2.loader-error: -------------------------------------------------------------------------------- 1 | --- !!python/name:xml.parsers 2 | -------------------------------------------------------------------------------- /test/unsupported/invalid-python-name-module.loader-error: -------------------------------------------------------------------------------- 1 | --- !!python/name:sys.modules.keys 2 | -------------------------------------------------------------------------------- /test/unsupported/invalid-python-name-object.loader-error: -------------------------------------------------------------------------------- 1 | --- !!python/name:os.path.rm_rf 2 | -------------------------------------------------------------------------------- /test/unsupported/invalid-python-name-value.loader-error: -------------------------------------------------------------------------------- 1 | --- !!python/name:sys.modules 5 2 | -------------------------------------------------------------------------------- /test/unsupported/invalid-tag-1.loader-error: -------------------------------------------------------------------------------- 1 | - ! baz 2 | -------------------------------------------------------------------------------- /test/unsupported/invalid-tag-directive-prefix.loader-error: -------------------------------------------------------------------------------- 1 | %TAG ! tag:zz.com/foo#bar # '#' is not allowed in URLs 2 | --- 3 | -------------------------------------------------------------------------------- /test/unsupported/invalid-uri-escapes-2.loader-error: -------------------------------------------------------------------------------- 1 | --- !<%FF> foo 2 | -------------------------------------------------------------------------------- /test/unsupported/invalid-uri-escapes-3.loader-error: -------------------------------------------------------------------------------- 1 | --- ! baz 2 | -------------------------------------------------------------------------------- /test/unsupported/merge.detect: -------------------------------------------------------------------------------- 1 | tag:yaml.org,2002:merge 2 | -------------------------------------------------------------------------------- /test/unsupported/null.detect: -------------------------------------------------------------------------------- 1 | tag:yaml.org,2002:null 2 | -------------------------------------------------------------------------------- /test/unsupported/odd-utf16.stream-error: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unsupported/odd-utf16.stream-error -------------------------------------------------------------------------------- /test/unsupported/spec-02-01.structure: -------------------------------------------------------------------------------- 1 | [true, true, true] 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-01.tokens: -------------------------------------------------------------------------------- 1 | [[ , _ , _ , _ ]} 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-02.structure: -------------------------------------------------------------------------------- 1 | [[true, true], [true, true], [true, true]] 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-02.tokens: -------------------------------------------------------------------------------- 1 | {{ 2 | ? _ : _ 3 | ? _ : _ 4 | ? _ : _ 5 | ]} 6 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-03.structure: -------------------------------------------------------------------------------- 1 | [[true, [true, true, true]], [true, [true, true, true]]] 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-03.tokens: -------------------------------------------------------------------------------- 1 | {{ 2 | ? _ : [[ , _ , _ , _ ]} 3 | ? _ : [[ , _ , _ , _ ]} 4 | ]} 5 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-04.structure: -------------------------------------------------------------------------------- 1 | [ 2 | [[true, true], [true, true], [true, true]], 3 | [[true, true], [true, true], [true, true]] 4 | ] 5 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-04.tokens: -------------------------------------------------------------------------------- 1 | [[ 2 | , {{ ? _ : _ ? _ : _ ? _ : _ ]} 3 | , {{ ? _ : _ ? _ : _ ? _ : _ ]} 4 | ]} 5 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-05.structure: -------------------------------------------------------------------------------- 1 | [ 2 | [true, true, true], 3 | [true, true, true], 4 | [true, true, true] 5 | ] 6 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-05.tokens: -------------------------------------------------------------------------------- 1 | [[ 2 | , [ _ , _ , _ ] 3 | , [ _ , _ , _ ] 4 | , [ _ , _ , _ ] 5 | ]} 6 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-06.structure: -------------------------------------------------------------------------------- 1 | [ 2 | [true, [[true, true], [true, true]]], 3 | [true, [[true, true], [true, true]]] 4 | ] 5 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-06.tokens: -------------------------------------------------------------------------------- 1 | {{ 2 | ? _ : { ? _ : _ , ? _ : _ } 3 | ? _ : { ? _ : _ , ? _ : _ } 4 | ]} 5 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-07.structure: -------------------------------------------------------------------------------- 1 | [ 2 | [true, true, true], 3 | [true, true] 4 | ] 5 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-07.tokens: -------------------------------------------------------------------------------- 1 | --- 2 | [[ 3 | , _ 4 | , _ 5 | , _ 6 | ]} 7 | 8 | --- 9 | [[ 10 | , _ 11 | , _ 12 | ]} 13 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-08.structure: -------------------------------------------------------------------------------- 1 | [ 2 | [[true, true], [true, true], [true, true]], 3 | [[true, true], [true, true], [true, true]] 4 | ] 5 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-08.tokens: -------------------------------------------------------------------------------- 1 | --- 2 | {{ 3 | ? _ : _ 4 | ? _ : _ 5 | ? _ : _ 6 | ]} 7 | ... 8 | 9 | --- 10 | {{ 11 | ? _ : _ 12 | ? _ : _ 13 | ? _ : _ 14 | ]} 15 | ... 16 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-09.structure: -------------------------------------------------------------------------------- 1 | [[true, [true, true]], [true, [true, true]]] 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-09.tokens: -------------------------------------------------------------------------------- 1 | --- 2 | {{ 3 | ? _ : [[ , _ , _ ]} 4 | ? _ : [[ , _ , _ ]} 5 | ]} 6 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-10.structure: -------------------------------------------------------------------------------- 1 | [[true, [true, true]], [true, ["*", true]]] 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-10.tokens: -------------------------------------------------------------------------------- 1 | --- 2 | {{ 3 | ? _ : [[ , _ , & _ ]} 4 | ? _ : [[ , * , _ ]} 5 | ]} 6 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-11.structure: -------------------------------------------------------------------------------- 1 | [ 2 | [[true, true], [true]], 3 | [[true, true], [true, true, true]] 4 | ] 5 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-11.tokens: -------------------------------------------------------------------------------- 1 | {{ 2 | ? [[ , _ , _ ]} 3 | : [[ , _ ]} 4 | ? [ _ , _ ] 5 | : [ _ , _ , _ ] 6 | ]} 7 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-12.structure: -------------------------------------------------------------------------------- 1 | [ 2 | [[true, true], [true, true]], 3 | [[true, true], [true, true]], 4 | [[true, true], [true, true]] 5 | ] 6 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-12.tokens: -------------------------------------------------------------------------------- 1 | --- 2 | [[ 3 | , {{ ? _ : _ ? _ : _ ]} 4 | , {{ ? _ : _ ? _ : _ ]} 5 | , {{ ? _ : _ ? _ : _ ]} 6 | ]} 7 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-13.structure: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-13.tokens: -------------------------------------------------------------------------------- 1 | --- _ 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-14.structure: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-14.tokens: -------------------------------------------------------------------------------- 1 | --- _ 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-15.structure: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-15.tokens: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-16.structure: -------------------------------------------------------------------------------- 1 | [[true, true], [true, true], [true, true]] 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-16.tokens: -------------------------------------------------------------------------------- 1 | {{ 2 | ? _ : _ 3 | ? _ : _ 4 | ? _ : _ 5 | ]} 6 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-17.structure: -------------------------------------------------------------------------------- 1 | [[true, true], [true, true], [true, true], [true, true], [true, true], [true, true]] 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-17.tokens: -------------------------------------------------------------------------------- 1 | {{ 2 | ? _ : _ 3 | ? _ : _ 4 | ? _ : _ 5 | ? _ : _ 6 | ? _ : _ 7 | ? _ : _ 8 | ]} 9 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-18.structure: -------------------------------------------------------------------------------- 1 | [[true, true], [true, true]] 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-18.tokens: -------------------------------------------------------------------------------- 1 | {{ 2 | ? _ : _ 3 | ? _ : _ 4 | ]} 5 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-19.structure: -------------------------------------------------------------------------------- 1 | [[true, true], [true, true], [true, true], [true, true], [true, true]] 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-19.tokens: -------------------------------------------------------------------------------- 1 | {{ 2 | ? _ : _ 3 | ? _ : _ 4 | ? _ : _ 5 | ? _ : _ 6 | ? _ : _ 7 | ]} 8 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-20.structure: -------------------------------------------------------------------------------- 1 | [[true, true], [true, true], [true, true], [true, true], [true, true], [true, true]] 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-20.tokens: -------------------------------------------------------------------------------- 1 | {{ 2 | ? _ : _ 3 | ? _ : _ 4 | ? _ : _ 5 | ? _ : _ 6 | ? _ : _ 7 | ? _ : _ 8 | ]} 9 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-21.structure: -------------------------------------------------------------------------------- 1 | [[true, true], [true, true], [true, true], [true, true]] 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-21.tokens: -------------------------------------------------------------------------------- 1 | {{ 2 | ? _ : _ 3 | ? _ : _ 4 | ? _ : _ 5 | ? _ : _ 6 | ]} 7 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-22.structure: -------------------------------------------------------------------------------- 1 | [[true, true], [true, true], [true, true], [true, true]] 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-22.tokens: -------------------------------------------------------------------------------- 1 | {{ 2 | ? _ : _ 3 | ? _ : _ 4 | ? _ : _ 5 | ? _ : _ 6 | ]} 7 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-23.structure: -------------------------------------------------------------------------------- 1 | [[true, true], [true, true], [true, true]] 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-23.tokens: -------------------------------------------------------------------------------- 1 | --- 2 | {{ 3 | ? _ : ! _ 4 | ? _ : ! _ 5 | ? _ : ! _ 6 | ]} 7 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-24.structure: -------------------------------------------------------------------------------- 1 | [ 2 | [[true, [[true, true], [true, true]]], [true, true]], 3 | [[true, "*"], [true, [[true, true], [true, true]]]], 4 | [[true, "*"], [true, true], [true, true]] 5 | ] 6 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-24.tokens: -------------------------------------------------------------------------------- 1 | % 2 | --- ! 3 | [[ 4 | , ! 5 | {{ 6 | ? _ : & { ? _ : _ , ? _ : _ } 7 | ? _ : _ 8 | ]} 9 | , ! 10 | {{ 11 | ? _ : * 12 | ? _ : { ? _ : _ , ? _ : _ } 13 | ]} 14 | , ! 15 | {{ 16 | ? _ : * 17 | ? _ : _ 18 | ? _ : _ 19 | ]} 20 | ]} 21 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-25.structure: -------------------------------------------------------------------------------- 1 | [[true, false], [true, false], [true, false]] 2 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-25.tokens: -------------------------------------------------------------------------------- 1 | --- ! 2 | {{ 3 | ? _ 4 | ? _ 5 | ? _ 6 | ]} 7 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-26.structure: -------------------------------------------------------------------------------- 1 | [ 2 | [[true, true]], 3 | [[true, true]], 4 | [[true, true]] 5 | ] 6 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-26.tokens: -------------------------------------------------------------------------------- 1 | --- ! 2 | [[ 3 | , {{ ? _ : _ ]} 4 | , {{ ? _ : _ ]} 5 | , {{ ? _ : _ ]} 6 | ]} 7 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-27.structure: -------------------------------------------------------------------------------- 1 | [ 2 | [true, true], 3 | [true, true], 4 | [true, [ 5 | [true, true], 6 | [true, true], 7 | [true, [[true, true], [true, true], [true, true], [true, true]]] 8 | ]], 9 | [true, "*"], 10 | [true, [ 11 | [[true, true], [true, true], [true, true], [true, true]], 12 | [[true, true], [true, true], [true, true], [true, true]] 13 | ]], 14 | [true, true], 15 | [true, true], 16 | [true, true] 17 | ] 18 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-27.tokens: -------------------------------------------------------------------------------- 1 | --- ! 2 | {{ 3 | ? _ : _ 4 | ? _ : _ 5 | ? _ : & 6 | {{ 7 | ? _ : _ 8 | ? _ : _ 9 | ? _ : {{ ? _ : _ ? _ : _ ? _ : _ ? _ : _ ]} 10 | ]} 11 | ? _ : * 12 | ? _ : 13 | [[ 14 | , {{ ? _ : _ ? _ : _ ? _ : _ ? _ : _ ]} 15 | , {{ ? _ : _ ? _ : _ ? _ : _ ? _ : _ ]} 16 | ]} 17 | ? _ : _ 18 | ? _ : _ 19 | ? _ : _ 20 | ]} 21 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-28.structure: -------------------------------------------------------------------------------- 1 | [ 2 | [[true, true], [true, true], [true, true]], 3 | [[true, true], [true, true], [true, true]], 4 | [[true, true], [true, true], [true, true], 5 | [true, [ 6 | [[true, true], [true, true], [true, true]], 7 | [[true, true], [true, true], [true, true]] 8 | ]] 9 | ] 10 | ] 11 | -------------------------------------------------------------------------------- /test/unsupported/spec-02-28.tokens: -------------------------------------------------------------------------------- 1 | --- 2 | {{ 3 | ? _ : _ 4 | ? _ : _ 5 | ? _ : _ 6 | ]} 7 | --- 8 | {{ 9 | ? _ : _ 10 | ? _ : _ 11 | ? _ : _ 12 | ]} 13 | --- 14 | {{ 15 | ? _ : _ 16 | ? _ : _ 17 | ? _ : _ 18 | ? _ : 19 | [[ 20 | , {{ ? _ : _ ? _ : _ ? _ : _ ]} 21 | , {{ ? _ : _ ? _ : _ ? _ : _ ]} 22 | ]} 23 | ]} 24 | -------------------------------------------------------------------------------- /test/unsupported/spec-05-01-utf16be.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unsupported/spec-05-01-utf16be.data -------------------------------------------------------------------------------- /test/unsupported/spec-05-01-utf16be.empty: -------------------------------------------------------------------------------- 1 | # This stream contains no 2 | # documents, only comments. 3 | -------------------------------------------------------------------------------- /test/unsupported/spec-05-01-utf16le.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unsupported/spec-05-01-utf16le.data -------------------------------------------------------------------------------- /test/unsupported/spec-05-01-utf16le.empty: -------------------------------------------------------------------------------- 1 | # This stream contains no 2 | # documents, only comments. 3 | -------------------------------------------------------------------------------- /test/unsupported/spec-05-02-utf16be.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unsupported/spec-05-02-utf16be.data -------------------------------------------------------------------------------- /test/unsupported/spec-05-02-utf16be.error: -------------------------------------------------------------------------------- 1 | ERROR: 2 | A BOM must not appear 3 | inside a document. 4 | -------------------------------------------------------------------------------- /test/unsupported/spec-05-02-utf16le.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unsupported/spec-05-02-utf16le.data -------------------------------------------------------------------------------- /test/unsupported/spec-05-02-utf16le.error: -------------------------------------------------------------------------------- 1 | ERROR: 2 | A BOM must not appear 3 | inside a document. 4 | -------------------------------------------------------------------------------- /test/unsupported/str.detect: -------------------------------------------------------------------------------- 1 | tag:yaml.org,2002:str 2 | -------------------------------------------------------------------------------- /test/unsupported/timestamp.detect: -------------------------------------------------------------------------------- 1 | tag:yaml.org,2002:timestamp 2 | -------------------------------------------------------------------------------- /test/unsupported/undefined-constructor.loader-error: -------------------------------------------------------------------------------- 1 | --- !foo bar 2 | -------------------------------------------------------------------------------- /test/unsupported/utf16be.code: -------------------------------------------------------------------------------- 1 | "UTF-16-BE" 2 | -------------------------------------------------------------------------------- /test/unsupported/utf16be.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unsupported/utf16be.data -------------------------------------------------------------------------------- /test/unsupported/utf16le.code: -------------------------------------------------------------------------------- 1 | "UTF-16-LE" 2 | -------------------------------------------------------------------------------- /test/unsupported/utf16le.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodeca/js-yaml/0d3ca7a27b03a6c974790a30a89e456007d62976/test/unsupported/utf16le.data -------------------------------------------------------------------------------- /test/unsupported/value.data: -------------------------------------------------------------------------------- 1 | - = 2 | -------------------------------------------------------------------------------- /test/unsupported/value.detect: -------------------------------------------------------------------------------- 1 | tag:yaml.org,2002:value 2 | -------------------------------------------------------------------------------- /test/unsupported/yaml.data: -------------------------------------------------------------------------------- 1 | - !!yaml '!' 2 | - !!yaml '&' 3 | - !!yaml '*' 4 | -------------------------------------------------------------------------------- /test/unsupported/yaml.detect: -------------------------------------------------------------------------------- 1 | tag:yaml.org,2002:yaml 2 | --------------------------------------------------------------------------------