Jonathan Rockway wrote:
> I like the "YAML" syntax, but can we live with:
>
> got: |
> this is line 1
> this is line 2
> expected: |
> this is line 1
> this is line 2
>
> Instead? That way a real YAML parser can parse the output of TAP, which
> could be important for adoption by other languages. Rather than require
> others to write a TAP parser, we can just tell them to use their YAML
> parser in streaming mode. Since we aren't using *all* the features of
> YAML here, we can still have a light implementation for Perl. (Not that
> I'm against using a full YAML parser... but I think others are :)
I'm with Jonathan here. If we can stick to a subset of an existing format
without extending it life for TAP implementors will be much easier. They can
use something off the shelf. TAP producers have a wide range of formats to use
to best fit their data.
For example, if we want to represent C<got => "foo\nbar\nbaz\n"> we can do:
got: |
foo
bar
baz
but when there's leading whitespace we get into trouble, such as C<got => "
foo\nbar\nbaz">
# invalid YAML
got: |
foo
bar
baz
That's not valid YAML, all lines in the scalar value block have to be indented
as far as the leading line. But that's ok, you can give an explicit
indentation level:
got: |2
foo
bar
baz
And then there's a ton of other scalar value formats which can be used....
# got => "foo"
got: foo
# got => " foo"
got: " foo"
# got => " foo "
got: ' foo '
# got => "foo\nbar\nbaz\n"
got: "foo\nbar\nbaz\n"
# got => "There's a really long string here which doesn't contain any newlines
in it but..."
got: >
There's a really long string here which doesn't contain any
newlines in it but its nice to soft wrap it for easier reading
without actually putting any newlines into the resulting data.
# got => qq[This literal block has\nno trailing newline.\nIt is "chomped".]
got: |-
This literal block has
no trailing newline.
It is "chomped".
got:
While this is valid YAML,
YAML.pm does not support it
so I'm not entirely sure
what it does.
YAML also has the benefit of being a nearly complete functional superset of
JSON so TAP producers can output their diagnostics as JSON if they like and we
can parse it for free.
http://redhanded.hobix.com/inspect/yamlIsJson.html