CC: | cpan [...] audreyt.org |
Subject: | YAML::Syck incompatibility with YAML.pm (comma-separated lists) |
Date: | Mon, 5 Feb 2007 16:43:16 +1100 |
To: | bug-YAML-Syck [...] rt.cpan.org |
From: | David.Pitt [...] nab.com.au |
Hi Audrey,
Great work with YAML::Syck, we have found it invaluable. I discovered an
anomaly between YAML::Syck and YAML. Consider the following YAML statement,
where there is no space after the comma in a comma-separated list:
FS : [Mark McGwire,65]
This is interpreted as follows:
YAML: FS => [ 'Mark McGwire', '65' ]
YAML::Syck: FS => [ 'Mark McGwire,65' ]
Adding a space afer the comma causes YAML::Syck to interpret the list
correctly. YAML::Syck requires a 'comma-and-space separated list' within
square brackets, whereas YAML requires a 'comma-separated list'. My reading
of the standard http://yaml.org/spec/current.html (2.1 Collections) - "The
flow sequence is written as a comma separated list within square brackets"
- indicates that the YAML treats this correctly, and YAML::Syck treats it
incorrectly.
Environment:
YAML-Syck-0.82 (also 0.67)
YAML: 0.62
perl 5.8.8 built for sun4-solaris-64
SunOS tdevs183 5.8 Generic_117350-41 sun4u sparc SUNW,Netra-T12
Test case:
#!/usr/local/bin/perl
use strict;
use warnings;
use YAML();
use YAML::Syck();
use Test::More tests => 2;
use Test::Differences;
# http://yaml.org/spec/current.html 2.1 Collections
my $stream = <<EoY;
FS : [Mark McGwire,65]
EoY
my $expected = { FS => [ 'Mark McGwire', '65' ] };
eq_or_diff(YAML::Load($stream), $expected, 'YAML');
eq_or_diff(YAML::Syck::Load($stream), $expected, 'YAML::Syck');
Output:
1..2
ok 1 - YAML
not ok 2 - YAML::Syck
# Failed test 'YAML::Syck'
# in ./bug01.pl at line 21.
# +----+-----------------------+----+---------------------+
# | Elt|Got | Elt|Expected |
# +----+-----------------------+----+---------------------+
# | 0|{ | 0|{ |
# | 1| FS => [ | 1| FS => [ |
# * 2| 'Mark McGwire,65' * 2| 'Mark McGwire', *
# | | * 3| '65' *
# | 3| ] | 4| ] |
# | 4|} | 5|} |
# +----+-----------------------+----+---------------------+
# Looks like you failed 1 test of 2.
Regards,
David Pitt | Enterprise Services Technology | National Australia Bank
Limited
Phone +61 3 8641 2014 | Email david.pitt@nab.com.au | Level 26, 500 Bourke
Street, Melbourne
National Australia Bank Ltd - ABN 12 004 044 937
This email may contain confidential information. If you are not the intended recipient, please immediately notify us at postmaster@nab.com.au or by replying to the sender, and then destroy all copies of this email. Except where this email indicates otherwise, views expressed in this email are those of the sender and not of National Australia Bank Ltd. Advice in this email does not take account of your objectives, financial situation, or needs. It is important for you to consider these matters and, if the e-mail refers to a product(s), you should read the relevant Product Disclosure Statement(s)/other disclosure document(s) before making any decisions. If you do not want email marketing from us in future, forward this email with "unsubscribe" in the subject line to Unsubscriptions@nab.com.au in order to stop marketing emails from this sender. National Australia Bank Ltd does not represent that this email is free of errors, viruses or interference.