# YAML Test Matrix

--- &test-RZT7
  Title: Spec Example 2.28. Log File
  Tags: [ header, literal, mapping, sequence, spec ]

YAML

---
Time: 2001-11-23 15:01:42 -5
User: ed
Warning:
  This is an error message
  for the log file
---
Time: 2001-11-23 15:02:31 -5
User: ed
Warning:
  A slightly different error
  message.
---
Date: 2001-11-23 15:03:17 -5
User: ed
Fatal:
  Unknown variable "bar"
Stack:
  - file: TopClass.py
    line: 23
    code: |
      x = MoreObject("345\n")
  - file: MoreClass.py
    line: 58
    code: |-
      foo = bar

Expected Events

+STR
+DOC ---
+MAP
=VAL :Time
=VAL :2001-11-23 15:01:42 -5
=VAL :User
=VAL :ed
=VAL :Warning
=VAL :This is an error message for the log file
-MAP
-DOC
+DOC ---
+MAP
=VAL :Time
=VAL :2001-11-23 15:02:31 -5
=VAL :User
=VAL :ed
=VAL :Warning
=VAL :A slightly different error message.
-MAP
-DOC
+DOC ---
+MAP
=VAL :Date
=VAL :2001-11-23 15:03:17 -5
=VAL :User
=VAL :ed
=VAL :Fatal
=VAL :Unknown variable "bar"
=VAL :Stack
+SEQ
+MAP
=VAL :file
=VAL :TopClass.py
=VAL :line
=VAL :23
=VAL :code
=VAL |x = MoreObject("345\\n")\n
-MAP
+MAP
=VAL :file
=VAL :MoreClass.py
=VAL :line
=VAL :58
=VAL :code
=VAL |foo = bar
-MAP
-SEQ
-MAP
-DOC
-STR

Expected JSON

{
"Time": "2001-11-23 15:01:42 -5",
"User": "ed",
"Warning": "This is an error message for the log file"
}
{
"Time": "2001-11-23 15:02:31 -5",
"User": "ed",
"Warning": "A slightly different error message."
}
{
"Date": "2001-11-23 15:03:17 -5",
"User": "ed",
"Fatal": "Unknown variable \"bar\"",
"Stack": [
{
"file": "TopClass.py",
"line": 23,
"code": "x = MoreObject(\"345\\n\")\n"
},
{
"file": "MoreClass.py",
"line": 58,
"code": "foo = bar"
}
]
}

cpp-event

 ok

hs-yaml-event

 ok

java-event

 ok

js-event

 ok

libyaml-event

 ok

nimyaml-event

 ok

perl5-pp-event

 ok

pyyaml-event

 ok

ruamel-event

 ok

hs-yaml-json

 json_ok

js-json

 json_ok

perl5-pp-json

 json_ok

perl5-syck-json

 json_ok

perl5-xs-json

 json_ok

java-json

 json_diff
{
  "Time": "Nov 23, 2001 8:01:42 PM",
  "User": "ed",
  "Warning": "This is an error message for the log file"
}
{
  "Time": "Nov 23, 2001 8:02:31 PM",
  "User": "ed",
  "Warning": "A slightly different error message."
}
{
  "Date": "Nov 23, 2001 8:03:17 PM",
  "Fatal": "Unknown variable \"bar\"",
  "Stack": [
    {
      "code": "x = MoreObject(\"345\\n\")\n",
      "file": "TopClass.py",
      "line": 23
    },
    {
      "code": "foo = bar",
      "file": "MoreClass.py",
      "line": 58
    }
  ],
  "User": "ed"
}

js-yaml-json

 json_diff
{
  "Time": "2001-11-23T20:01:42.000Z",
  "User": "ed",
  "Warning": "This is an error message for the log file"
}
{
  "Time": "2001-11-23T20:02:31.000Z",
  "User": "ed",
  "Warning": "A slightly different error message."
}
{
  "Date": "2001-11-23T20:03:17.000Z",
  "Fatal": "Unknown variable \"bar\"",
  "Stack": [
    {
      "code": "x = MoreObject(\"345\\n\")\n",
      "file": "TopClass.py",
      "line": 23
    },
    {
      "code": "foo = bar",
      "file": "MoreClass.py",
      "line": 58
    }
  ],
  "User": "ed"
}

luajit-json

 json_diff
{
  "Time": 2001,
  "User": "ed",
  "Warning": "This is an error message for the log file"
}
{
  "Time": 2001,
  "User": "ed",
  "Warning": "A slightly different error message."
}
{
  "Date": 2001,
  "Fatal": "Unknown variable \"bar\"",
  "Stack": [
    {
      "code": "x = MoreObject(\"345\\n\")\n",
      "file": "TopClass.py",
      "line": 23
    },
    {
      "code": "foo = bar",
      "file": "MoreClass.py",
      "line": 58
    }
  ],
  "User": "ed"
}

ruby-json

 json_diff
{
  "Time": "2001-11-23 20:01:42 +0000",
  "User": "ed",
  "Warning": "This is an error message for the log file"
}
{
  "Time": "2001-11-23 20:02:31 +0000",
  "User": "ed",
  "Warning": "A slightly different error message."
}
{
  "Date": "2001-11-23 20:03:17 +0000",
  "Fatal": "Unknown variable \"bar\"",
  "Stack": [
    {
      "code": "x = MoreObject(\"345\\n\")\n",
      "file": "TopClass.py",
      "line": 23
    },
    {
      "code": "foo = bar",
      "file": "MoreClass.py",
      "line": 58
    }
  ],
  "User": "ed"
}

perl5-pegex-event

 error
Maximum parsing rules reached (1000)

perl5-pm-json

 error
YAML Error: Expected separator '---'
   Code: YAML_PARSE_ERR_NO_SEPARATOR
   Line: 5
   Document: 2
 at /lib/perl5/YAML/Loader.pm line 88.

perl5-pm-pl

 error
YAML Error: Expected separator '---'
   Code: YAML_PARSE_ERR_NO_SEPARATOR
   Line: 5
   Document: 2
 at /lib/perl5/YAML/Loader.pm line 88.

perl5-tiny-json

 error
YAML::Tiny failed to classify line '  This is an error message' at /bin/perl5-tiny-json line 12.

perl5-tiny-pl

 error
YAML::Tiny failed to classify line '  This is an error message' at /bin/perl5-tiny-pl line 15.

pyyaml-json

 error
Error json.dumps: <type 'exceptions.TypeError'>
Traceback (most recent call last):
  File "/bin/pyyaml-json", line 21, in <module>
    print json.dumps(doc, sort_keys=True, skipkeys=True, indent=2)
  File "/usr/lib/python2.7/json/__init__.py", line 251, in dumps
    sort_keys=sort_keys, **kw).encode(obj)
  File "/usr/lib/python2.7/json/encoder.py", line 209, in encode
    chunks = list(chunks)
  File "/usr/lib/python2.7/json/encoder.py", line 434, in _iterencode
    for chunk in _iterencode_dict(o, _current_indent_level):
  File "/usr/lib/python2.7/json/encoder.py", line 408, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib/python2.7/json/encoder.py", line 442, in _iterencode
    o = _default(o)
  File "/usr/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: datetime.datetime(2001, 11, 23, 20, 1, 42) is not JSON serializable

ruamel-json

 error
Error json.dumps: <type 'exceptions.TypeError'>
Traceback (most recent call last):
  File "/bin/ruamel-json", line 21, in <module>
    print json.dumps(doc, sort_keys=True, skipkeys=True, indent=2)
  File "/usr/lib/python2.7/json/__init__.py", line 251, in dumps
    sort_keys=sort_keys, **kw).encode(obj)
  File "/usr/lib/python2.7/json/encoder.py", line 209, in encode
    chunks = list(chunks)
  File "/usr/lib/python2.7/json/encoder.py", line 434, in _iterencode
    for chunk in _iterencode_dict(o, _current_indent_level):
  File "/usr/lib/python2.7/json/encoder.py", line 408, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib/python2.7/json/encoder.py", line 442, in _iterencode
    o = _default(o)
  File "/usr/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: datetime.datetime(2001, 11, 23, 20, 1, 42) is not JSON serializable

perl5-pp-pl

 na
{
  'Time' => '2001-11-23 15:01:42 -5',
  'User' => 'ed',
  'Warning' => 'This is an error message for the log file'
}
{
  'Time' => '2001-11-23 15:02:31 -5',
  'User' => 'ed',
  'Warning' => 'A slightly different error message.'
}
{
  'Date' => '2001-11-23 15:03:17 -5',
  'Fatal' => 'Unknown variable "bar"',
  'Stack' => [
             {
               'code' => 'x = MoreObject("345\\n")
',
               'file' => 'TopClass.py',
               'line' => 23
             },
             {
               'code' => 'foo = bar',
               'file' => 'MoreClass.py',
               'line' => 58
             }
           ],
  'User' => 'ed'
}

perl5-syck-pl

 na
{
  'Time' => '2001-11-23 15:01:42 -5',
  'User' => 'ed',
  'Warning' => 'This is an error message for the log file'
}
{
  'Time' => '2001-11-23 15:02:31 -5',
  'User' => 'ed',
  'Warning' => 'A slightly different error message.'
}
{
  'Date' => '2001-11-23 15:03:17 -5',
  'Fatal' => 'Unknown variable "bar"',
  'Stack' => [
             {
               'code' => 'x = MoreObject("345\\n")
',
               'file' => 'TopClass.py',
               'line' => 23
             },
             {
               'code' => 'foo = bar',
               'file' => 'MoreClass.py',
               'line' => 58
             }
           ],
  'User' => 'ed'
}

perl5-xs-pl

 na
{
  'Time' => '2001-11-23 15:01:42 -5',
  'User' => 'ed',
  'Warning' => 'This is an error message for the log file'
}
{
  'Time' => '2001-11-23 15:02:31 -5',
  'User' => 'ed',
  'Warning' => 'A slightly different error message.'
}
{
  'Date' => '2001-11-23 15:03:17 -5',
  'Fatal' => 'Unknown variable "bar"',
  'Stack' => [
               {
                 'code' => 'x = MoreObject("345\\n")
',
                 'file' => 'TopClass.py',
                 'line' => 23
               },
               {
                 'code' => 'foo = bar',
                 'file' => 'MoreClass.py',
                 'line' => 58
               }
             ],
  'User' => 'ed'
}

pyyaml-py

 na
{'Time': datetime.datetime(2001, 11, 23, 20, 1, 42),
 'User': 'ed',
 'Warning': 'This is an error message for the log file'}
{'Time': datetime.datetime(2001, 11, 23, 20, 2, 31),
 'User': 'ed',
 'Warning': 'A slightly different error message.'}
{'Date': datetime.datetime(2001, 11, 23, 20, 3, 17),
 'Fatal': 'Unknown variable "bar"',
 'Stack': [{'code': 'x = MoreObject("345\\n")\n',
            'file': 'TopClass.py',
            'line': 23},
           {'code': 'foo = bar', 'file': 'MoreClass.py', 'line': 58}],
 'User': 'ed'}

ruamel-py

 na
{'Time': datetime.datetime(2001, 11, 23, 20, 1, 42),
 'User': 'ed',
 'Warning': 'This is an error message for the log file'}
{'Time': datetime.datetime(2001, 11, 23, 20, 2, 31),
 'User': 'ed',
 'Warning': 'A slightly different error message.'}
{'Date': datetime.datetime(2001, 11, 23, 20, 3, 17),
 'Fatal': 'Unknown variable "bar"',
 'Stack': [{'code': 'x = MoreObject("345\\n")\n',
            'file': 'TopClass.py',
            'line': 23},
           {'code': 'foo = bar', 'file': 'MoreClass.py', 'line': 58}],
 'User': 'ed'}