# YAML Test Matrix

--- &test-UGM3
  Title: Spec Example 2.27. Invoice
  Tags: [ alias, literal, mapping, sequence, spec, tag ]

YAML

--- !<tag:clarkevans.com,2002:invoice>
invoice: 34843
date   : 2001-01-23
bill-to: &id001
    given  : Chris
    family : Dumars
    address:
        lines: |
            458 Walkman Dr.
            Suite #292
        city    : Royal Oak
        state   : MI
        postal  : 48046
ship-to: *id001
product:
    - sku         : BL394D
      quantity    : 4
      description : Basketball
      price       : 450.00
    - sku         : BL4438H
      quantity    : 1
      description : Super Hoop
      price       : 2392.00
tax  : 251.42
total: 4443.52
comments:
    Late afternoon is best.
    Backup contact is Nancy
    Billsmer @ 338-4338.

Expected Events

+STR
+DOC ---
+MAP <tag:clarkevans.com,2002:invoice>
=VAL :invoice
=VAL :34843
=VAL :date
=VAL :2001-01-23
=VAL :bill-to
+MAP &id001
=VAL :given
=VAL :Chris
=VAL :family
=VAL :Dumars
=VAL :address
+MAP
=VAL :lines
=VAL |458 Walkman Dr.\nSuite #292\n
=VAL :city
=VAL :Royal Oak
=VAL :state
=VAL :MI
=VAL :postal
=VAL :48046
-MAP
-MAP
=VAL :ship-to
=ALI *id001
=VAL :product
+SEQ
+MAP
=VAL :sku
=VAL :BL394D
=VAL :quantity
=VAL :4
=VAL :description
=VAL :Basketball
=VAL :price
=VAL :450.00
-MAP
+MAP
=VAL :sku
=VAL :BL4438H
=VAL :quantity
=VAL :1
=VAL :description
=VAL :Super Hoop
=VAL :price
=VAL :2392.00
-MAP
-SEQ
=VAL :tax
=VAL :251.42
=VAL :total
=VAL :4443.52
=VAL :comments
=VAL :Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.
-MAP
-DOC
-STR

Expected JSON

{
"invoice": 34843,
"date": "2001-01-23",
"bill-to": {
"given": "Chris",
"family": "Dumars",
"address": {
"lines": "458 Walkman Dr.\nSuite #292\n",
"city": "Royal Oak",
"state": "MI",
"postal": 48046
}
},
"ship-to": {
"given": "Chris",
"family": "Dumars",
"address": {
"lines": "458 Walkman Dr.\nSuite #292\n",
"city": "Royal Oak",
"state": "MI",
"postal": 48046
}
},
"product": [
{
"sku": "BL394D",
"quantity": 4,
"description": "Basketball",
"price": 450
},
{
"sku": "BL4438H",
"quantity": 1,
"description": "Super Hoop",
"price": 2392
}
],
"tax": 251.42,
"total": 4443.52,
"comments": "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338."
}

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

ruby-json

 json_ok

perl5-pegex-event

 diff
Got Events:
+STR
+DOC ---
+MAP <!<tag:clarkevans.com,2002:invoice>>
=VAL :invoice
=VAL :34843
-MAP
-DOC
+DOC
+MAP
=VAL :date
=VAL :2001-01-23
=VAL :bill-to
+MAP &id001
=VAL :given
=VAL :Chris
=VAL :family
=VAL :Dumars
=VAL :address
+MAP
=VAL :lines
=VAL |458 Walkman Dr.\nSuite #292\n
=VAL :city
=VAL :Royal Oak
=VAL :state
=VAL :MI
=VAL :postal
=VAL :48046
-MAP
-MAP
=VAL :ship-to
=ALI *id001
=VAL :product
+SEQ
=VAL :sku
-SEQ
=VAL :
=VAL :BL394D
-MAP
-DOC
+DOC
+MAP
=VAL :quantity
=VAL :4
=VAL :description
=VAL :Basketball
=VAL :price
=VAL :450.00
-MAP
-DOC
+DOC
+SEQ
=VAL :sku
-SEQ
-DOC
+DOC
+MAP
=VAL :
=VAL :BL4438H
-MAP
-DOC
+DOC
+MAP
=VAL :quantity
=VAL :1
=VAL :description
=VAL :Super Hoop
=VAL :price
=VAL :2392.00
-MAP
-DOC
+DOC
+MAP
=VAL :tax
=VAL :251.42
=VAL :total
=VAL :4443.52
=VAL :comments
=VAL :    Late afternoon is best.
-MAP
-DOC
+DOC
=VAL :    Backup contact is Nancy
-DOC
+DOC
=VAL :    Billsmer @ 338-4338.
-DOC
-STR

luajit-json

 json_diff
{
  "bill-to": {
    "address": {
      "city": "Royal Oak",
      "lines": "458 Walkman Dr.\nSuite #292\n",
      "postal": 48046,
      "state": "MI"
    },
    "family": "Dumars",
    "given": "Chris"
  },
  "comments": "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.",
  "date": 2001,
  "invoice": 34843,
  "product": [
    {
      "description": "Basketball",
      "price": 450,
      "quantity": 4,
      "sku": "BL394D"
    },
    {
      "description": "Super Hoop",
      "price": 2392,
      "quantity": 1,
      "sku": "BL4438H"
    }
  ],
  "ship-to": {
    "address": {
      "city": "Royal Oak",
      "lines": "458 Walkman Dr.\nSuite #292\n",
      "postal": 48046,
      "state": "MI"
    },
    "family": "Dumars",
    "given": "Chris"
  },
  "tax": 251.42,
  "total": 4443.52
}

perl5-syck-json

 json_diff
null

java-json

 error
Exception in thread "main" Can't construct a java object for tag:clarkevans.com,2002:invoice; exception=Invalid tag: tag:clarkevans.com,2002:invoice
 in 'reader', line 1, column 5:
    --- !<tag:clarkevans.com,2002:invoice>
        ^

	at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:314)
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:204)
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:193)
	at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:159)
	at org.yaml.snakeyaml.constructor.BaseConstructor.getData(BaseConstructor.java:127)
	at org.yaml.snakeyaml.Yaml$1.next(Yaml.java:547)
	at org.yaml.editor.Snake2Json.yamlToJson(Snake2Json.java:18)
	at org.yaml.editor.Snake2Json.main(Snake2Json.java:25)
Caused by: org.yaml.snakeyaml.error.YAMLException: Invalid tag: tag:clarkevans.com,2002:invoice
	at org.yaml.snakeyaml.nodes.Tag.getClassName(Tag.java:112)
	at org.yaml.snakeyaml.constructor.Constructor.getClassForNode(Constructor.java:637)
	at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.getConstructor(Constructor.java:300)
	at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:309)
	... 7 more

js-yaml-json

 error
YAMLException: unknown tag !<tag:clarkevans.com,2002:invoice> at line 30, column 1:
    
    ^
    at generateError (/node_modules/js-yaml/lib/js-yaml/loader.js:165:10)
    at throwError (/node_modules/js-yaml/lib/js-yaml/loader.js:171:9)
    at composeNode (/node_modules/js-yaml/lib/js-yaml/loader.js:1401:7)
    at readDocument (/node_modules/js-yaml/lib/js-yaml/loader.js:1492:3)
    at loadDocuments (/node_modules/js-yaml/lib/js-yaml/loader.js:1548:5)
    at Object.loadAll (/node_modules/js-yaml/lib/js-yaml/loader.js:1556:19)
    at Object.<anonymous> (/bin/js-yaml-json:6:6)
    at Object.<anonymous> (/bin/js-yaml-json:3:1)
    at Module._compile (module.js:652:30)
    at Object.exports.run (/usr/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:173:23)
    at compileScript (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:224:29)
    at compilePath (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:174:14)
    at Object.exports.run (/usr/lib/node_modules/coffee-script/lib/coffee-script/command.js:98:20)
    at Object.<anonymous> (/usr/lib/node_modules/coffee-script/bin/coffee:15:45)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

perl5-pm-json

 error
YAML Error: Expected separator '---'
   Code: YAML_PARSE_ERR_NO_SEPARATOR
   Line: 27
   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: 27
   Document: 2
 at /lib/perl5/YAML/Loader.pm line 88.

perl5-tiny-json

 error
YAML::Tiny does not support a feature in line '!<tag:clarkevans.com,2002:invoice>' at /bin/perl5-tiny-json line 12.

perl5-tiny-pl

 error
YAML::Tiny does not support a feature in line '!<tag:clarkevans.com,2002:invoice>' at /bin/perl5-tiny-pl line 15.

perl5-xs-json

 error
YAML::XS::Load Error: The problem:

    bad tag found for hash: 'tag:clarkevans.com,2002:invoice'

was found at document: 1

perl5-xs-pl

 error
YAML::XS::Load Error: The problem:

    bad tag found for hash: 'tag:clarkevans.com,2002:invoice'

was found at document: 1

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.date(2001, 1, 23) 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.date(2001, 1, 23) is not JSON serializable

perl5-pp-pl

 na
{
  'bill-to' => {
               'address' => {
                            'city' => 'Royal Oak',
                            'lines' => '458 Walkman Dr.
Suite #292
',
                            'postal' => 48046,
                            'state' => 'MI'
                          },
               'family' => 'Dumars',
               'given' => 'Chris'
             },
  'comments' => 'Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.',
  'date' => '2001-01-23',
  'invoice' => 34843,
  'product' => [
               {
                 'description' => 'Basketball',
                 'price' => '450',
                 'quantity' => 4,
                 'sku' => 'BL394D'
               },
               {
                 'description' => 'Super Hoop',
                 'price' => '2392',
                 'quantity' => 1,
                 'sku' => 'BL4438H'
               }
             ],
  'ship-to' => $VAR1->{'bill-to'},
  'tax' => '251.42',
  'total' => '4443.52'
}

perl5-syck-pl

 na
bless( {
         'bill-to' => {
                      'address' => {
                                   'city' => 'Royal Oak',
                                   'lines' => '458 Walkman Dr.
Suite #292
',
                                   'postal' => 48046,
                                   'state' => 'MI'
                                 },
                      'family' => 'Dumars',
                      'given' => 'Chris'
                    },
         'comments' => 'Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.',
         'date' => '2001-01-23',
         'invoice' => 34843,
         'product' => [
                      {
                        'description' => 'Basketball',
                        'price' => '450',
                        'quantity' => 4,
                        'sku' => 'BL394D'
                      },
                      {
                        'description' => 'Super Hoop',
                        'price' => '2392',
                        'quantity' => 1,
                        'sku' => 'BL4438H'
                      }
                    ],
         'ship-to' => $VAR1->{'bill-to'},
         'tax' => '251.42',
         'total' => '4443.52'
       }, '<tag::clarkevans.com,2002:invoice>' )

pyyaml-py

 na
GenericMapping(tag=u'tag:clarkevans.com,2002:invoice', content={'product': [{'sku': 'BL394D', 'price': 450.0, 'description': 'Basketball', 'quantity': 4}, {'sku': 'BL4438H', 'price': 2392.0, 'description': 'Super Hoop', 'quantity': 1}], 'total': 4443.52, 'tax': 251.42, 'comments': 'Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.', 'bill-to': {'given': 'Chris', 'family': 'Dumars', 'address': {'city': 'Royal Oak', 'state': 'MI', 'postal': 48046, 'lines': '458 Walkman Dr.\nSuite #292\n'}}, 'invoice': 34843, 'date': datetime.date(2001, 1, 23), 'ship-to': {'given': 'Chris', 'family': 'Dumars', 'address': {'city': 'Royal Oak', 'state': 'MI', 'postal': 48046, 'lines': '458 Walkman Dr.\nSuite #292\n'}}})

ruamel-py

 na
GenericMapping(tag=u'tag:clarkevans.com,2002:invoice', content={'product': [{'sku': 'BL394D', 'price': 450.0, 'description': 'Basketball', 'quantity': 4}, {'sku': 'BL4438H', 'price': 2392.0, 'description': 'Super Hoop', 'quantity': 1}], 'ship-to': {'given': 'Chris', 'family': 'Dumars', 'address': {'city': 'Royal Oak', 'state': 'MI', 'postal': 48046, 'lines': '458 Walkman Dr.\nSuite #292\n'}}, 'tax': 251.42, 'comments': 'Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.', 'bill-to': {'given': 'Chris', 'family': 'Dumars', 'address': {'city': 'Royal Oak', 'state': 'MI', 'postal': 48046, 'lines': '458 Walkman Dr.\nSuite #292\n'}}, 'invoice': 34843, 'date': datetime.date(2001, 1, 23), 'total': 4443.52})