| 1 | # Copyright 2025 The go-yaml Project Contributors |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | |
| 4 | # Parser events test cases for go-yaml parser |
| 5 | # |
| 6 | # Purpose: Tests the YAML parser's ability to generate correct event sequences |
| 7 | # from YAML input. Events represent the structural elements of YAML documents |
| 8 | # (document start/end, mappings, sequences, scalars, etc.). |
| 9 | # |
| 10 | # Format: Test cases use type-as-key format: |
| 11 | # - test-type: |
| 12 | # name: Test case name |
| 13 | # ... |
| 14 | # |
| 15 | # Test Types: |
| 16 | # parser-events - Verifies parser event output matches expected event sequence |
| 17 | # |
| 18 | # Common Keys: |
| 19 | # name - Test case name (string) |
| 20 | # yaml - Input YAML to parse (string) |
| 21 | # want - Expected event sequence (string with events on separate lines) |
| 22 | # |
| 23 | # Event Format: |
| 24 | # Events are represented as text with specific prefixes: |
| 25 | # +STR - Stream start |
| 26 | # -STR - Stream end |
| 27 | # +DOC - Document start |
| 28 | # -DOC - Document end |
| 29 | # +MAP - Mapping start |
| 30 | # -MAP - Mapping end |
| 31 | # +SEQ - Sequence start |
| 32 | # -SEQ - Sequence end |
| 33 | # =VAL - Scalar value (followed by :value) |
| 34 | # =ALI - Alias reference (followed by :*anchor) |
| 35 | |
| 36 | - parser-events: |
| 37 | name: ImplicitDocumentStart |
| 38 | yaml: | |
| 39 | a: b |
| 40 | want: | |
| 41 | +STR |
| 42 | +DOC |
| 43 | +MAP |
| 44 | =VAL :a |
| 45 | =VAL :b |
| 46 | -MAP |
| 47 | -DOC |
| 48 | -STR |
| 49 | |
| 50 | - parser-events: |
| 51 | name: ExplicitDocumentStart |
| 52 | yaml: | |
| 53 | --- |
| 54 | a: b |
| 55 | want: | |
| 56 | +STR |
| 57 | +DOC --- |
| 58 | +MAP |
| 59 | =VAL :a |
| 60 | =VAL :b |
| 61 | -MAP |
| 62 | -DOC |
| 63 | -STR |