summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-04-18 15:03:28 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-04-18 15:03:28 +0000
commit2fe5b8de1e9d06482aa76303e7342bc6605700ea (patch)
treecccc47c409970b2db7a8f64f6c25e993270ddf9b /t
downloadYAML-tarball-2fe5b8de1e9d06482aa76303e7342bc6605700ea.tar.gz
Diffstat (limited to 't')
-rw-r--r--t/000-compile-modules.t19
-rw-r--r--t/2-scalars.t37
-rw-r--r--t/TestYAML.pm7
-rw-r--r--t/TestYAMLBase.pm11
-rw-r--r--t/basic-tests.t77
-rw-r--r--t/bugs-emailed.t186
-rw-r--r--t/bugs-rt.t283
-rw-r--r--t/changes.t9
-rw-r--r--t/dump-basics.t75
-rw-r--r--t/dump-blessed-glob.t87
-rw-r--r--t/dump-blessed.t46
-rw-r--r--t/dump-code.t75
-rw-r--r--t/dump-file-utf8.t43
-rw-r--r--t/dump-file.t36
-rw-r--r--t/dump-nested.t110
-rw-r--r--t/dump-opts.t153
-rw-r--r--t/dump-perl-types-512.t28
-rw-r--r--t/dump-perl-types-514.t28
-rw-r--r--t/dump-perl-types.t153
-rw-r--r--t/dump-stringify.t51
-rw-r--r--t/dump-stringy-numbers.t41
-rw-r--r--t/dump-synopsis.t21
-rw-r--r--t/dump-tests-512.t24
-rw-r--r--t/dump-tests-514.t24
-rw-r--r--t/dump-tests.t402
-rw-r--r--t/dump-works.t17
-rw-r--r--t/errors.t387
-rw-r--r--t/export.t18
-rw-r--r--t/freeze-thaw.t32
-rw-r--r--t/global-api.t32
-rw-r--r--t/inbox.t22
-rw-r--r--t/issue-149.t10
-rw-r--r--t/load-fails.t54
-rw-r--r--t/load-passes.t70
-rw-r--r--t/load-slides.t360
-rw-r--r--t/load-spec.t711
-rw-r--r--t/load-tests.t405
-rw-r--r--t/load-works.t18
-rw-r--r--t/long-quoted-value.yaml2
-rw-r--r--t/marshall.t120
-rw-r--r--t/node-info.t166
-rw-r--r--t/pugs-objects.t20
-rw-r--r--t/references.t48
-rw-r--r--t/regexp.t94
-rw-r--r--t/release-pod-syntax.t14
-rw-r--r--t/rt-90593.t21
-rw-r--r--t/svk-config.yaml320
-rw-r--r--t/svk.t20
-rw-r--r--t/test.t5
49 files changed, 4992 insertions, 0 deletions
diff --git a/t/000-compile-modules.t b/t/000-compile-modules.t
new file mode 100644
index 0000000..5857dd6
--- /dev/null
+++ b/t/000-compile-modules.t
@@ -0,0 +1,19 @@
+# This test does a basic `use` check on all the code.
+use Test::More;
+
+use File::Find;
+
+sub test {
+ s{^lib/(.*)\.pm$}{$1} or return;
+ s{/}{::}g;
+ use_ok $_;
+}
+
+$ENV{PERL_ZILD_TEST_000_COMPILE_MODULES} = 1;
+
+find {
+ wanted => \&test,
+ no_chdir => 1,
+}, 'lib';
+
+done_testing;
diff --git a/t/2-scalars.t b/t/2-scalars.t
new file mode 100644
index 0000000..ae4f021
--- /dev/null
+++ b/t/2-scalars.t
@@ -0,0 +1,37 @@
+# This test modified from YAML::Syck suite
+use strict;
+use Test::More;
+
+require YAML;
+YAML->import;
+
+is(Dump(42), "--- 42\n");
+is(Load("--- 42\n"), 42);
+
+is(Dump(undef), "--- ~\n");
+is(Load("--- ~\n"), undef);
+is(Load("---\n"), undef);
+is(Load("--- ''\n"), '');
+
+is(Load("--- true\n"), "true");
+is(Load("--- false\n"), "false");
+
+# $YAML::Syck::ImplicitTyping = $YAML::Syck::ImplicitTyping = 1;
+#
+# is(Load("--- true\n"), 1);
+# is(Load("--- false\n"), '');
+
+my $Data = {
+ Test => '
+ Test Drive D:\\',
+};
+
+is_deeply(Load(Dump($Data)), $Data);
+
+if ($^V ge v5.9.0) {
+# Large data tests. See also https://bugzilla.redhat.com/show_bug.cgi?id=192400.
+ $Data = ' äø<> " \' " \'' x 40_000;
+ is(Load(Dump($Data)), $Data);
+}
+
+done_testing;
diff --git a/t/TestYAML.pm b/t/TestYAML.pm
new file mode 100644
index 0000000..ba0f1a7
--- /dev/null
+++ b/t/TestYAML.pm
@@ -0,0 +1,7 @@
+package TestYAML;
+use lib 'inc';
+use Test::YAML -Base;
+
+$Test::YAML::YAML = 'YAML';
+
+$^W = 1;
diff --git a/t/TestYAMLBase.pm b/t/TestYAMLBase.pm
new file mode 100644
index 0000000..a7aab6f
--- /dev/null
+++ b/t/TestYAMLBase.pm
@@ -0,0 +1,11 @@
+package TestYAMLBase;
+
+sub new {
+ my $self = bless {}, shift;
+ while (my ($k, $v) = splice @_, 0, 2) {
+ $self->{$k} = $v;
+ }
+ return $self;
+}
+
+1;
diff --git a/t/basic-tests.t b/t/basic-tests.t
new file mode 100644
index 0000000..3f8f7d4
--- /dev/null
+++ b/t/basic-tests.t
@@ -0,0 +1,77 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 4;
+
+filters {
+ yaml => [yaml => 'dumper'],
+ perl => [strict => eval => 'dumper'],
+};
+
+run_is yaml => 'perl';
+
+__END__
+=== A simple map
++++ yaml
+---
+one: foo
+two: bar
+three: baz
++++ perl
++{qw(one foo two bar three baz)}
+
+
+=== Common String Types
++++ yaml
+---
+one: simple string
+two: 42
+three: '1 Single Quoted String'
+four: "YAML's Double Quoted String"
+five: |
+ A block
+ with several
+ lines.
+six: |-
+ A "chomped" block
+seven: >
+ A
+ folded
+ string
++++ perl
+{
+ one => "simple string",
+ two => '42',
+ three => "1 Single Quoted String",
+ four => "YAML's Double Quoted String",
+ five => "A block\n with several\n lines.\n",
+ six => 'A "chomped" block',
+ seven => "A folded\n string\n",
+}
+
+
+=== Multiple documents
++++ yaml
+---
+foo: bar
+---
+bar: two
++++ perl
++{qw(foo bar)}, {qw(bar two)};
+
+
+=== Comments
++++ yaml
+# Leading Comment
+---
+# Preceding Comment
+foo: bar
+# Two
+# Comments
+---
+ # Indented comment
+bar: two
+bee: three
+# Intermediate comment
+bore: four
++++ perl
++{qw(foo bar)}, {qw(bar two bee three bore four)}
diff --git a/t/bugs-emailed.t b/t/bugs-emailed.t
new file mode 100644
index 0000000..d4b7f2f
--- /dev/null
+++ b/t/bugs-emailed.t
@@ -0,0 +1,186 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 25;
+
+no_diff;
+run_yaml_tests;
+
+__DATA__
+
+=== Date: Tue, 03 Jan 2006 18:04:56
++++ perl: { key1 => '>value1' }
++++ yaml
+---
+key1: '>value1'
+
+
+
+=== Date: Wed, 04 Jan 2006 10:23:18
++++ perl: { key1 => '|value' }
++++ yaml
+---
+key1: '|value'
+
+
+
+=== Date: Thu, 3 Mar 2005 14:12:10
++++ perl: { "foo,bar" => "baz"}
++++ yaml
+---
+'foo,bar': baz
+
+
+
+=== Date: Wed, 9 Mar 2005 09:16:19
++++ perl: {'a,v' => 'c'}
++++ yaml
+---
+'a,v': c
+
+
+
+=== Date: Fri, 18 Mar 2005 15:08:57
++++ perl: {'foo[bar', 'baz'}
++++ yaml
+---
+'foo[bar': baz
+
+
+
+=== Date: Sun, 20 Mar 2005 16:32:50
++++ subject: Argument "E5" isn't numeric in multiplication (*)
++++ function: load_passes
++++ yaml
+--- #YAML:1.0 !!perl/Blam::Game
+board:
+ E5: R1
+history:
+ - 1E5
+
+
+
+=== Date: Sat, 26 Mar 2005 22:55:55
++++ perl: {"a - a" => 1}
++++ yaml
+---
+'a - a': 1
+
+
+
+=== Date: Sun, 8 May 2005 15:42:04
++++ skip_this_for_now
++++ perl: [{q</.*/> => {any_key => { } }}]
++++ yaml
+---
+- /.*/:
+ any_key: {}
+
+
+
+=== Date: Thu, 12 May 2005 14:57:20
++++ function: load_passes
++++ yaml
+--- #YAML:1.0
+
+WilsonSereno1998:
+ authors:
+ - Wilson, Jeffrey. A
+ - Paul C. Sereno
+ title: Early evolution and Higher-level phylogeny of sauropod dinosaurs
+ year: 1998
+ journal: Journal of Vertebrate Paleontology, memoir
+ volume: 5
+ pages: 1-68
+
+WedelEtAl2000:
+ authors:
+ - Wedel, M. J.
+ - R. L. Cifelli
+ - R. K. Sanders
+ year: 2000
+ title: _Sauroposeidon proteles_, a new sauropod from the Early Cretaceous of Oklahoma.
+ journal: Journal of Vertebrate Paleontology
+ volume: 20
+ issue: 1
+ pages: 109-114
+
+
+
+=== Date: Thu, 09 Jun 2005 18:49:01
++++ perl: {'test' => '|testing'}
++++ yaml
+---
+test: '|testing'
+
+
+
+=== Date: Mon, 22 Aug 2005 16:52:47
++++ skip_this_for_now
++++ perl
+ my $y = {
+
+ ok_list_of_hashes => [
+ {one => 1},
+ {two => 2},
+ ],
+
+ error_list_of_hashes => [
+ {-one => 1},
+ {-two => 2},
+ ],
+
+ };
++++ yaml
+---
+error_list_of_hashes:
+ - -one: 1
+ - -two: 2
+ok_list_of_hashes:
+ - one: 1
+ - two: 2
+
+
+
+=== Date: Wed, 12 Oct 2005 17:16:48
++++ skip_this_for_now
++++ function: load_passes
++++ yaml
+fontsize_small: '9px' # labelsmall
+fontsize: '11px' # maintext, etc
+fontsize_big: '12px' # largetext, button
+fontsize_header: '13px' # sectionheaders
+fontsize_banner: '16px' # title
+
+
+
+=== Date: Mon, 07 Nov 2005 15:49:07
++++ perl: \ '|something'
++++ yaml
+--- !!perl/ref
+=: '|something'
+
+
+
+=== Date: Thu, 24 Nov 2005 10:49:06
++++ perl: { url => 'http://www.test.com/product|1|2|333333', zzz => '' }
++++ yaml
+---
+url: http://www.test.com/product|1|2|333333
+zzz: ''
+
+
+
+=== Date: Sat, 3 Dec 2005 14:26:23
++++ perl
+my @keys = qw/001 002 300 400 500/;
+my $h = {};
+map {$h->{$_} = 1} @keys;
+$h;
++++ yaml
+---
+001: 1
+002: 1
+300: 1
+400: 1
+500: 1
+
diff --git a/t/bugs-rt.t b/t/bugs-rt.t
new file mode 100644
index 0000000..a650c27
--- /dev/null
+++ b/t/bugs-rt.t
@@ -0,0 +1,283 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 41;
+
+run_yaml_tests;
+
+__DATA__
+
+=== Ticket #105-A YAML doesn't serialize odd objects very well
++++ skip_this_for_now
++++ skip_unless_modules: FileHandle
++++ perl: FileHandle->new( ">/tmp/yaml_bugs_rt_$$" );
++++ yaml
+--- !!perl/io:FileHandle
+- xxx
+
+=== Ticket #105-B YAML doesn't serialize odd objects very well
++++ skip_unless_modules: URI
++++ no_round_trip
++++ perl: URI->new( "http://localhost/" )
++++ yaml
+--- !!perl/scalar:URI::http http://localhost/
+
+=== Ticket #105-C YAML doesn't serialize odd objects very well
++++ skip_unless_modules: URI
++++ perl: +{ names => ['james','alexander','duncan'], }
++++ yaml
+---
+names:
+ - james
+ - alexander
+ - duncan
+
+=== Ticket #105-D YAML doesn't serialize odd objects very well
++++ perl
+# CGI->new()
+bless {
+ '.charset' => 'ISO-8859-1',
+ '.fieldnames' => {},
+ '.parameters' => [],
+ escape => 1,
+}, 'CGI';
++++ yaml
+--- !!perl/hash:CGI
+.charset: ISO-8859-1
+.fieldnames: {}
+.parameters: []
+escape: 1
+
+=== Ticket #105-E YAML doesn't serialize odd objects very well
++++ perl
+package MyObj::Class;
+sub new { return bless ['one','two','three'], $_[0]; }
+package main;
+MyObj::Class->new();
++++ yaml
+--- !!perl/array:MyObj::Class
+- one
+- two
+- three
+
+
+
+=== Ticket #2957 Serializing array-elements with dashes
++++ skip_this_for_now
++++ perl: [ { "test - " => 23 } ];
++++ yaml
+---
+- 'test - ': 23
+
+
+
+=== Ticket #3015 wish: folding length option for YAML
++++ skip_this_for_now
+> YAML.pm, line 557, currently has a folding value of 50 hard-coded.
+> It would be great if this value became an option... for those who
+> prefer not to fold, or fold less.
+
+I wanted that too. The attached patch adds in the $YAML::FoldLimit
+config variable to achieve this. I've also got a doc patch which
+describes this, but 'RT' only has one file-upload field so that'll be in
+the next comment ...
+
+Smylers
+
+
+=== Ticket #4066 Number vs. string heuristics for dump
++++ perl: { 'version' => '1.10' };
++++ yaml
+---
+version: 1.10
+
+
+
+=== Ticket #4784 Can't create YAML::Node from 'REF'
++++ skip_this_for_now
++++ perl: my $bar = 1; my $foo = \\\$bar; bless $foo, "bar"
++++ yaml
+
+
+
+=== Ticket #4866 Text with embedded newlines
++++ perl
+{'text' => 'Bla:
+
+- Foo
+- Bar
+'};
++++ yaml
+---
+text: "Bla:\n\n- Foo\n- Bar\n"
+
+
+
+=== Ticket #5299 Load(Dump({"hi, world" => 1})) fails
++++ perl: {"hi, world" => 1}
++++ yaml
+---
+'hi, world': 1
+
+
+
+=== Ticket #5691 Minor doc error in YAML.pod
++++ perl: "YAML:1.0"
++++ yaml
+--- YAML:1.0
+
+
+
+=== Ticket #6095 Hash keys are not always escaped
++++ perl: { 'AVE,' => { '??' => { '??' => 1 } } }
++++ yaml
+---
+'AVE,':
+ '??':
+ '??': 1
+
+
+
+=== Ticket #6139 0.35 can't deserialize blessed scalars
++++ perl: my $x = "abc"; bless \ $x, "ABCD";
++++ yaml
+--- !!perl/scalar:ABCD abc
+
+
+
+=== Ticket #7146 scalar with many spaces doesn't round trip
++++ skip_this_for_now
+Can't get this to work yet.
++++ perl: "A".(" "x200)."B"
++++ yaml
+--- 'A B'
+
+
+
+
+=== Ticket #8795 !!perl/code blocks are evaluated in package main
++++ skip_this_for_now
+This test passes but not sure if this totally represents what was being
+reported. Check back later.
++++ perl: $YAML::UseCode = 1; package Food; sub { 42; }
++++ no_round_trip
++++ yaml
+--- !!perl/code |
+sub {
+ package Food;
+ use warnings;
+ use strict 'refs';
+ 42;
+}
+
+
+=== Ticket #8818 YAML::Load fails if the last value in the stream ends with '|'
++++ perl: ['o|']
++++ yaml
+---
+- 'o|'
+
+
+
+=== Ticket #12729 < and > need to be quoted ?
++++ perl: { a => q(>a), b => q(<b), c => q(<c>)}
++++ yaml
+---
+a: '>a'
+b: <b
+c: '<c>'
+
+
+
+=== Ticket #12770 YAML crashes when tab used for indenting
++++ skip_this_for_now
+Even in the latest version, 0.39, YAML fails when tabulator characters are used for
+indenting. This is expected since the YAML spec forbids this use of tab characters.
+However, there is no error message; YAML.pm just dies. Here's an example:
+
+ perl -MYAML -e "Load(\"Testing:\n\t- Item1\n\")"
+
+fails with
+
+Died at U:\perl-lib\lib/YAML.pm line 1417.
+
+It should at least fail with a message like it does when there's no newline at the
+end:
++++ perl
+
+
+
+=== Ticket #12955 DumpCode claims to support a code ref to serialize code, but doesn't
++++ skip_this_for_now
+The DumpCode option says you can set it to a code ref to control the
+serializing yourself, but this doesn't work.
+
+ $ perl -MYAML -we '
+ $YAML::DumpCode = sub { return "dumped code $_[0]", "test" };
+ print Dump(sub { "foo" });'
+ --- !!perl/code "{\n 'foo';\n}\n"
+ $ _
+
+YAML::Transfer::code::yaml_dump() doesn't look to have any code to
+support a DumpCode which is a code ref, it only tests it as a boolean.
++++ perl
+
+
+
+=== Ticket #12959-a bug - nested inline collections with extra blanks
++++ function: load_passes
++++ yaml
+--- { a: {k: v} }
+
+=== Ticket #12959-b bug - nested inline collections with extra blanks
++++ function: load_passes
++++ yaml
+--- { a: [1] }
+
+=== Ticket #12959-c bug - nested inline collections with extra blanks
++++ function: load_passes
++++ yaml
+--- [ {k: v} ]
+
+=== Ticket #12959-d bug - nested inline collections with extra blanks
++++ function: load_passes
++++ yaml
+--- [ [1] ]
+
+
+
+=== Ticket #13016 Plain Multiline Support
++++ skip_this_for_now
+Fix in upcoming release
++++ function: load_passes
++++ yaml
+quoted: "So does this
+ quoted scalar.\n"
+
+
+
+=== #13500 Load(Dump("|foo")) fails
++++ perl: "|foo"
++++ yaml
+--- '|foo'
+
+
+
+=== Ticket #13510 Another roundtrip fails
++++ skip_this_for_now
++++ perl
+[{'RR1 (Schloflplatz - Wannsee)'=> 1,
+'m‰fliges Kopfsteinpflaster (Teilstrecke)' => 1},
+undef,
+]
++++ yaml
+---
+- 'RR1 (Schloflplatz - Wannsee)': 1
+ m‰fliges Kopfsteinpflaster (Teilstrecke): 1
+- ~
+
+
+
+=== Ticket #14938 Load(Dump(">=")) fails
++++ perl: ">="
++++ yaml
+--- '>='
diff --git a/t/changes.t b/t/changes.t
new file mode 100644
index 0000000..d0dfbf8
--- /dev/null
+++ b/t/changes.t
@@ -0,0 +1,9 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 1;
+
+SKIP: {
+ skip("Can't parse Changes file yet :(", 1);
+}
+
+# my @values = LoadFile("Changes");
diff --git a/t/dump-basics.t b/t/dump-basics.t
new file mode 100644
index 0000000..7c829dc
--- /dev/null
+++ b/t/dump-basics.t
@@ -0,0 +1,75 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 7;
+
+filters {
+ perl => [qw'eval yaml_dump'],
+};
+
+run_is;
+
+__DATA__
+=== A map
++++ perl
++{ foo => 'bar', baz => 'boo' }
++++ yaml
+---
+baz: boo
+foo: bar
+
+=== A list
++++ perl
+[ qw'foo bar baz' ]
++++ yaml
+---
+- foo
+- bar
+- baz
+
+=== A List of maps
++++ perl
+[{ foo => 42, bar => 44}, {one => 'two', three => 'four'}]
++++ yaml
+---
+- bar: 44
+ foo: 42
+- one: two
+ three: four
+
+=== A map of lists
++++ perl
++{numbers => [ 5..7 ], words => [qw'five six seven']}
++++ yaml
+---
+numbers:
+ - 5
+ - 6
+ - 7
+words:
+ - five
+ - six
+ - seven
+
+=== Top level scalar
++++ perl: 'The eagle has landed'
++++ yaml
+--- The eagle has landed
+
+=== Top level literal scalar
++++ perl
+<<'...'
+sub foo {
+ return "Don't eat the foo";
+}
+...
++++ yaml
+--- |
+sub foo {
+ return "Don't eat the foo";
+}
+
+=== Single Dash
++++ perl: {foo => '-'}
++++ yaml
+---
+foo: '-'
diff --git a/t/dump-blessed-glob.t b/t/dump-blessed-glob.t
new file mode 100644
index 0000000..2f21e60
--- /dev/null
+++ b/t/dump-blessed-glob.t
@@ -0,0 +1,87 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 3;
+
+package Foo::Bar;
+
+sub new {
+ my ($class) = @_;
+ my $ref = globref();
+ my $self = bless $ref, $class;
+ return $self;
+}
+
+my $globnum = 0;
+sub globref {
+ my $symbolname = "Foo::Glob::glob$globnum";
+ $globnum ++;
+ no strict 'refs';
+ return \*{ $symbolname };
+}
+
+
+package main;
+
+is(Test::YAML::Dump({ globref => Foo::Bar::globref() }), <<EYAM, "dump glob-in-hash");
+---
+globref: !!perl/ref
+ =: !!perl/glob:
+ PACKAGE: Foo::Glob
+ NAME: glob0
+EYAM
+
+is(Test::YAML::Dump({ blessglob => Foo::Bar->new }), <<EYAM, "dump blessed glob");
+---
+blessglob: !!perl/glob:Foo::Bar
+ PACKAGE: Foo::Glob
+ NAME: glob1
+EYAM
+
+# A glob tricked out with everything
+my $val = Foo::Bar->new;
+${ *$val } = 'wag';
+%{ *$val } = qw( key value hash pairs );
+@{ *$val } = qw( a b c );
+open *$val, '>&', \*STDERR or die "Can't dup STDERR: $!";
+*{$val} = sub { 2 + 2 };
+
+my $dump_tricks = Test::YAML::Dump({ blessglob => $val });
+
+# Redact some highly variable stuff from the IO
+my $changekeys = join '|',
+ qw( fileno device inode mode links uid gid rdev size atime mtime ),
+ qw( ctime blksize blocks tell );
+$dump_tricks =~ s{($changekeys): \S+$}{$1: redact}mg;
+
+is($dump_tricks, <<EYAM, "dump blessed glob");
+---
+blessglob: !!perl/glob:Foo::Bar
+ PACKAGE: Foo::Glob
+ NAME: glob2
+ SCALAR: wag
+ ARRAY:
+ - a
+ - b
+ - c
+ HASH:
+ hash: pairs
+ key: value
+ CODE: !!perl/code '{ "DUMMY" }'
+ IO:
+ fileno: redact
+ stat:
+ device: redact
+ inode: redact
+ mode: redact
+ links: redact
+ uid: redact
+ gid: redact
+ rdev: redact
+ size: redact
+ atime: redact
+ mtime: redact
+ ctime: redact
+ blksize: redact
+ blocks: redact
+ tell: redact
+EYAM
diff --git a/t/dump-blessed.t b/t/dump-blessed.t
new file mode 100644
index 0000000..a2217b3
--- /dev/null
+++ b/t/dump-blessed.t
@@ -0,0 +1,46 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 2;
+
+package Foo::Bar;
+
+use TestYAMLBase;
+
+our @ISA = 'TestYAMLBase';
+
+sub yaml_dump {
+ my $self = shift;
+ my $node = YAML::Node->new({
+ two => $self->{two} - 1,
+ one => $self->{one} + 1,
+ }, 'perl/Foo::Bar');
+ YAML::Node::ynode($node)->keys(['two', 'one']);
+ return $node;
+}
+
+sub yaml_load {
+ my $class = shift;
+ my $node = shift;
+ my $self = $class->new;
+ $self->{one} = ($node->{one} - 1);
+ $self->{two} = ($node->{two} + 1);
+ return $self;
+}
+
+package main;
+
+no_diff;
+run_roundtrip_nyn;
+
+__END__
+
+=== Object class handles marshalling
++++ perl
+my $fb = Foo::Bar->new();
+$fb->{one} = 5;
+$fb->{two} = 3;
+$fb;
++++ yaml
+--- !perl/Foo::Bar
+two: 2
+one: 6
diff --git a/t/dump-code.t b/t/dump-code.t
new file mode 100644
index 0000000..f352c82
--- /dev/null
+++ b/t/dump-code.t
@@ -0,0 +1,75 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 7;
+use YAML (); # [CPAN #74687] must load before B::Deparse for B::Deparse < 0.71
+
+use B::Deparse;
+if (new B::Deparse -> coderef2text ( sub { no strict; 1; use strict; 1; })
+ =~ 'refs') {
+ local $/;
+ (my $data = <DATA>) =~ s/use strict/use strict 'refs'/g if $] < 5.015;
+ if ($B::Deparse::VERSION > 0.67 and $B::Deparse::VERSION < 0.71) { # [CPAN #73702]
+ $data =~ s/use warnings;/BEGIN {\${^WARNING_BITS} = "UUUUUUUUUUUU\\001"}/g;
+ }
+ open DATA, '<', \$data;
+}
+
+no_diff;
+run_roundtrip_nyn('dumper');
+
+__DATA__
+
+=== a code ref
++++ config
+local $YAML::DumpCode = 1;
++++ perl
+package main;
+return sub { 'Something at least 30 chars' };
++++ yaml
+--- !!perl/code |
+{
+ use warnings;
+ use strict;
+ 'Something at least 30 chars';
+}
+
+=== an array of the same code ref
++++ config
+local $YAML::DumpCode = 1;
++++ perl
+package main;
+my $joe_random_global = sub { 'Something at least 30 chars' };
+[$joe_random_global, $joe_random_global, $joe_random_global];
++++ yaml
+---
+- &1 !!perl/code |
+ {
+ use warnings;
+ use strict;
+ 'Something at least 30 chars';
+ }
+- *1
+- *1
+
+=== dummy code ref
++++ config
+local $YAML::DumpCode = 0;
++++ perl
+sub { 'Something at least 30 chars' }
++++ yaml
+--- !!perl/code '{ "DUMMY" }'
+
+=== blessed code ref
++++ config
+local $YAML::DumpCode = 1;
++++ perl
+package main;
+bless sub { 'Something at least 30 chars' }, "Foo::Bar";
++++ no_round_trip
++++ yaml
+--- !!perl/code:Foo::Bar |
+{
+ use warnings;
+ use strict;
+ 'Something at least 30 chars';
+}
diff --git a/t/dump-file-utf8.t b/t/dump-file-utf8.t
new file mode 100644
index 0000000..86c0c5a
--- /dev/null
+++ b/t/dump-file-utf8.t
@@ -0,0 +1,43 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+my $t = -e 't' ? 't' : 'test';
+
+use utf8;
+use lib 'inc';
+use Test::YAML();
+BEGIN {
+ @Test::YAML::EXPORT =
+ grep { not /^(Dump|Load)(File)?$/ } @Test::YAML::EXPORT;
+}
+use TestYAML tests => 6;
+
+use YAML qw/DumpFile LoadFile/;
+
+ok defined &DumpFile,
+ 'DumpFile exported';
+
+ok defined &LoadFile,
+ 'LoadFile exported';
+
+my $file = "$t/dump-file-utf8-$$.yaml";
+
+# A scalar containing non-ASCII characters
+my $data = 'Olivier Mengué';
+is length($data), 14, 'Test source is correctly encoded';
+
+DumpFile($file, $data);
+
+ok -e $file,
+ 'Output file exists';
+
+open IN, '<:utf8', $file or die $!;
+my $yaml = do { local $/; <IN> };
+close IN;
+
+is $yaml, "--- $data\n", 'DumpFile YAML encoding is correct';
+
+
+my $read = LoadFile($file);
+is $read, $data, 'LoadFile is ok';
+
+unlink $file;
diff --git a/t/dump-file.t b/t/dump-file.t
new file mode 100644
index 0000000..8796ba5
--- /dev/null
+++ b/t/dump-file.t
@@ -0,0 +1,36 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+my $t = -e 't' ? 't' : 'test';
+
+use lib 'inc';
+use Test::YAML();
+BEGIN {
+ @Test::YAML::EXPORT =
+ grep { not /^(Dump|Load)(File)?$/ } @Test::YAML::EXPORT;
+}
+use TestYAML tests => 3;
+
+use YAML 'DumpFile';
+
+ok defined &DumpFile,
+ 'Dumpfile exported';
+
+my $file = "$t/dump-file-$$.yaml";
+
+DumpFile($file, [1..3]);
+
+ok -e $file,
+ 'Output file exists';
+
+open IN, $file or die $!;
+my $yaml = join '', <IN>;
+close IN;
+
+is $yaml, <<'...', 'DumpFile YAML is correct';
+---
+- 1
+- 2
+- 3
+...
+
+unlink $file;
diff --git a/t/dump-nested.t b/t/dump-nested.t
new file mode 100644
index 0000000..34afd69
--- /dev/null
+++ b/t/dump-nested.t
@@ -0,0 +1,110 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 20;
+
+no_diff();
+run_roundtrip_nyn();
+
+__DATA__
+===
++++ perl
+['foo ' x 20]
++++ yaml
+---
+- 'foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo '
+===
++++ perl
+[q{YAML(tm) (rhymes with "camel") is a straightforward machine parsable data serialization format designed for human readability and interaction with scripting languages such as Perl and Python. YAML is optimized for data serialization, configuration settings, log files, Internet messaging and filtering. YAML(tm) is a balance of the following design goals:}]
++++ yaml
+---
+- 'YAML(tm) (rhymes with "camel") is a straightforward machine parsable data serialization format designed for human readability and interaction with scripting languages such as Perl and Python. YAML is optimized for data serialization, configuration settings, log files, Internet messaging and filtering. YAML(tm) is a balance of the following design goals:'
+===
++++ perl
+[q{It reads one character at a time, with the ability to push back any number of characters up to a maximum, and with nested mark() / reset() / unmark() functions. The input of the stream reader is any java.io.Reader. The output are characters.
+The parser (and event generator)
+
+The input of the parser are characters. These characters are directly fed into the functions that implement the different productions. The output of the parser are events, a well defined and small set of events.}]
++++ yaml
+---
+- |-
+ It reads one character at a time, with the ability to push back any number of characters up to a maximum, and with nested mark() / reset() / unmark() functions. The input of the stream reader is any java.io.Reader. The output are characters.
+ The parser (and event generator)
+
+ The input of the parser are characters. These characters are directly fed into the functions that implement the different productions. The output of the parser are events, a well defined and small set of events.
+===
++++ perl
+<<END;
+xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx
+xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx
+ 1) xxx xxx xxx xxx
+ 2) xxx xxx xxx xxx
+xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx
+END
++++ yaml
+--- |
+xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx
+xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx
+ 1) xxx xxx xxx xxx
+ 2) xxx xxx xxx xxx
+xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx
+===
++++ perl
+<<END;
+xxx xxx xxx xxx
+xxx xxx xxx xxx
+
+ 1) xxx xxx xxx xxx
+ 2) xxx xxx xxx xxx
+
+xxx xxx xxx xxx
+END
++++ yaml
+--- |
+xxx xxx xxx xxx
+xxx xxx xxx xxx
+
+ 1) xxx xxx xxx xxx
+ 2) xxx xxx xxx xxx
+
+xxx xxx xxx xxx
+===
++++ perl
+<<END;
+xxx xxx xxx xxx
+ 1) xxx xxx xxx xxx
+
+ 2) xxx xxx xxx xxx
+xxx xxx xxx xxx
+END
++++ yaml
+--- |
+xxx xxx xxx xxx
+ 1) xxx xxx xxx xxx
+
+ 2) xxx xxx xxx xxx
+xxx xxx xxx xxx
+===
++++ perl
+"xxx xxx xxx xxx xxx xxx xxx xxx xxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx xxx xxx xxx xxx xxx xxx xxx\n"
++++ yaml
+--- "xxx xxx xxx xxx xxx xxx xxx xxx xxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx xxx xxx xxx xxx xxx xxx xxx\n"
+===
++++ perl
+"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx xxx xxx xxx xxx xxx xxx xxx\n"
++++ yaml
+--- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx xxx xxx xxx xxx xxx xxx xxx\n"
+===
++++ perl
+"xxx xxx xxx xxx\n\n"
++++ yaml
+--- "xxx xxx xxx xxx\n\n"
+
+=== blah
++++ config
+local $YAML::UseBlock = 1
++++ perl
+"xxx xxx xxx xxx\n\n"
++++ yaml -trim
+--- |+
+xxx xxx xxx xxx
+
diff --git a/t/dump-opts.t b/t/dump-opts.t
new file mode 100644
index 0000000..a7e961c
--- /dev/null
+++ b/t/dump-opts.t
@@ -0,0 +1,153 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 19;
+
+run_roundtrip_nyn();
+
+__DATA__
+===
++++ config
+local $YAML::UseHeader = 0
++++ perl
+(['34', '45'], ['56', '67'])
++++ yaml
+- 34
+- 45
+---
+- 56
+- 67
+===
++++ no_round_trip
++++ config
+local $YAML::UseAliases = 0
++++ perl
+my $ref = {foo => 'bar'};
+[$ref, $ref]
++++ yaml
+---
+- foo: bar
+- foo: bar
+===
++++ config
+local $YAML::CompressSeries = 1
++++ perl
+[
+ {foo => 'bar'},
+ {lips => 'red', crown => 'head'},
+ {trix => [ 'foo', {silly => 'rabbit', bratty => 'kids', } ] },
+]
++++ yaml
+---
+- foo: bar
+- crown: head
+ lips: red
+- trix:
+ - foo
+ - bratty: kids
+ silly: rabbit
+===
++++ config
+local $YAML::CompressSeries = 0;
+local $YAML::Indent = 5
++++ perl
+[
+ {one => 'fun', pun => 'none'},
+ two => 'foo',
+ {three => [ {free => 'willy', dally => 'dilly'} ]},
+]
++++ yaml
+---
+-
+ one: fun
+ pun: none
+- two
+- foo
+-
+ three:
+ -
+ dally: dilly
+ free: willy
+===
++++ config
+local $YAML::CompressSeries = 1;
+local $YAML::Indent = 5
++++ perl
+[
+ {one => 'fun', pun => 'none'},
+ two => {foo => {true => 'blue'}},
+ {three => [ {free => 'willy', dally => 'dilly'} ]},
+]
++++ yaml
+---
+- one: fun
+ pun: none
+- two
+- foo:
+ true: blue
+- three:
+ - dally: dilly
+ free: willy
+===
++++ config
+local $YAML::Indent = 3
++++ perl
+[{ one => 'two', three => 'four' }, { foo => 'bar' }, ]
++++ yaml
+---
+- one: two
+ three: four
+- foo: bar
+===
++++ config
+local $YAML::CompressSeries = 1
++++ perl
+[
+ 'The',
+ {speed => 'quick', color => 'brown', &YAML::VALUE => 'fox'},
+ 'jumped over the',
+ {speed => 'lazy', &YAML::VALUE, 'dog'},
+]
++++ yaml
+---
+- The
+- color: brown
+ speed: quick
+ =: fox
+- jumped over the
+- speed: lazy
+ =: dog
+===
++++ config
+local $YAML::InlineSeries = 3
++++ perl
+[
+ ['10', '20', '30'],
+ ['foo', 'bar'],
+ ['thank', 'god', "it's", 'friday'],
+]
++++ yaml
+---
+- [10, 20, 30]
+- [foo, bar]
+-
+ - thank
+ - god
+ - it's
+ - friday
+===
++++ config
+local $YAML::SortKeys = [qw(foo bar baz)]
++++ perl
+{foo=>'42',bar=>'99',baz=>'4'}
++++ yaml
+---
+foo: 42
+bar: 99
+baz: 4
+===
++++ perl
+{foo => '42', bar => 'baz'}
++++ yaml
+---
+bar: baz
+foo: 42
diff --git a/t/dump-perl-types-512.t b/t/dump-perl-types-512.t
new file mode 100644
index 0000000..89b9822
--- /dev/null
+++ b/t/dump-perl-types-512.t
@@ -0,0 +1,28 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use Test::More;
+BEGIN {
+ if ( qr/x/ =~ /\(\?\^/ ){
+ plan skip_all => "test only for perls before v5.13.5-11-gfb85c04";
+ }
+}
+use TestYAML tests => 2;
+
+filters { perl => ['eval', 'yaml_dump'] };
+
+no_diff;
+run_is ( perl => 'yaml' );
+
+__DATA__
+=== Regular Expression
++++ perl: qr{perfect match};
++++ yaml
+--- !!perl/regexp (?-xism:perfect match)
+
+=== Regular Expression with newline
++++ perl
+qr{perfect
+match}x;
++++ yaml
+--- !!perl/regexp "(?x-ism:perfect\nmatch)"
+
diff --git a/t/dump-perl-types-514.t b/t/dump-perl-types-514.t
new file mode 100644
index 0000000..0ba4d9a
--- /dev/null
+++ b/t/dump-perl-types-514.t
@@ -0,0 +1,28 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use Test::More;
+BEGIN {
+ unless ( qr/x/ =~ /\(\?\^/ ){
+ plan skip_all => "test only for perls v5.13.5-11-gfb85c04 or later";
+ }
+}
+use TestYAML tests => 2;
+
+filters { perl => ['eval', 'yaml_dump'] };
+
+no_diff;
+run_is ( perl => 'yaml' );
+
+__DATA__
+=== Regular Expression
++++ perl: qr{perfect match};
++++ yaml
+--- !!perl/regexp (?^:perfect match)
+
+=== Regular Expression with newline
++++ perl
+qr{perfect
+match}x;
++++ yaml
+--- !!perl/regexp "(?^x:perfect\nmatch)"
+
diff --git a/t/dump-perl-types.t b/t/dump-perl-types.t
new file mode 100644
index 0000000..c73378f
--- /dev/null
+++ b/t/dump-perl-types.t
@@ -0,0 +1,153 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 14;
+
+filters { perl => ['eval', 'yaml_dump'] };
+
+use YAML (); # [CPAN #74687] must load before B::Deparse for B::Deparse < 0.71
+use B::Deparse;
+if (new B::Deparse -> coderef2text ( sub { no strict; 1; use strict; 1; })
+ =~ 'refs') {
+ local $/;
+ (my $data = <DATA>) =~ s/use strict/use strict 'refs'/g;
+ if ($B::Deparse::VERSION > 0.67 and $B::Deparse::VERSION < 0.71) { # [CPAN #73702]
+ $data =~ s/use warnings;/BEGIN {\${^WARNING_BITS} = "UUUUUUUUUUUU\\001"}/g;
+ }
+ open DATA, '<', \$data;
+}
+
+no_diff;
+run_is perl => 'yaml';
+
+__DATA__
+
+=== Scalar
++++ perl: 'Hello'
++++ yaml
+--- Hello
+
+=== Hash
++++ perl: +{bar => 'foo', foo => 'bar'}
++++ yaml
+---
+bar: foo
+foo: bar
+
+=== Array
++++ perl: [qw(W O W)]
++++ yaml
+---
+- W
+- O
+- W
+
+=== Code
++++ perl
+$YAML::DumpCode = 1;
+package main;
+sub { print "Hello, world\n"; }
++++ yaml
+--- !!perl/code |
+{
+ use warnings;
+ use strict;
+ print "Hello, world\n";
+}
+
+=== Scalar Reference
++++ perl: \ 'Goodbye'
++++ yaml
+--- !!perl/ref
+=: Goodbye
+
+=== Scalar Glob
++++ perl
+$::var = 'Hola';
+*::var;
++++ yaml
+--- !!perl/glob:
+PACKAGE: main
+NAME: var
+SCALAR: Hola
+
+=== Array Glob
++++ perl
+@::var2 = (qw(xxx yyy zzz));
+*::var2;
++++ yaml
+--- !!perl/glob:
+PACKAGE: main
+NAME: var2
+ARRAY:
+ - xxx
+ - yyy
+ - zzz
+
+=== Code Glob
++++ perl
+$YAML::DumpCode = 1;
+package main;
+sub main::var3 { print "Hello, world\n"; }
+*var3;
++++ yaml
+--- !!perl/glob:
+PACKAGE: main
+NAME: var3
+CODE: !!perl/code |
+ {
+ use warnings;
+ use strict;
+ print "Hello, world\n";
+ }
+
+=== Blessed Empty Hash
++++ perl: bless {}, 'A::B::C';
++++ yaml
+--- !!perl/hash:A::B::C {}
+
+=== Blessed Populated Hash
++++ perl: bless {qw(foo bar bar foo)}, 'A::B::C';
++++ yaml
+--- !!perl/hash:A::B::C
+bar: foo
+foo: bar
+
+=== Blessed Empty Array
++++ perl: bless [], 'A::B::C';
++++ yaml
+--- !!perl/array:A::B::C []
+
+=== Blessed Populated Array
++++ perl: bless [qw(foo bar bar foo)], 'A::B::C';
++++ yaml
+--- !!perl/array:A::B::C
+- foo
+- bar
+- bar
+- foo
+
+=== Blessed Empty String
++++ perl: my $e = ''; bless \ $e, 'A::B::C';
++++ yaml
+--- !!perl/scalar:A::B::C ''
+
+=== Blessed Populated String
++++ perl: my $fbbf = 'foo bar bar foo'; bless \ $fbbf, 'A::B::C';
++++ yaml
+--- !!perl/scalar:A::B::C foo bar bar foo
+
+=== Blessed Regular Expression
++++ SKIP
++++ perl: bless qr{perfect match}, 'A::B::C';
++++ yaml
+--- !!perl/regexp:A::B::C perfect match
+
+=== Blessed Glob
++++ SKIP
++++ perl: $::x = 42; bless \ *::x, 'A::B::C';
++++ yaml
+--- !!perl/glob:A::B::C
+PACKAGE: main
+NAME: x
+SCALAR: 42
+
diff --git a/t/dump-stringify.t b/t/dump-stringify.t
new file mode 100644
index 0000000..5b3d93c
--- /dev/null
+++ b/t/dump-stringify.t
@@ -0,0 +1,51 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 6;
+
+no_diff;
+
+package Foo;
+
+use overload '""' => \&stringy;
+
+sub stringy { 'Hello mate!' }
+
+sub new { bless { 'Hello' => 'mate!' }, shift };
+
+package main;
+
+my $foo = Foo->new;
+
+my $stringy_dump = <<'';
+--- Hello mate!
+
+my $object_dump = <<'';
+--- !!perl/hash:Foo
+Hello: mate!
+
+my $yaml;
+
+$yaml = Dump($foo);
+is $yaml, $object_dump, "Global stringification default dump";
+
+$YAML::Stringify = 1;
+$yaml = Dump($foo);
+is $yaml, $stringy_dump, "Global stringification enabled dump";
+
+$YAML::Stringify = 0;
+$yaml = Dump($foo);
+is $yaml, $object_dump, "Global stringification disabled dump";
+
+require YAML::Dumper;
+my $dumper = YAML::Dumper->new;
+
+$yaml = $dumper->dump($foo);
+is $yaml, $object_dump, "Local stringification default dump";
+
+$dumper->stringify(1);
+$yaml = $dumper->dump($foo);
+is $yaml, $stringy_dump, "Local stringification enabled dump";
+
+$dumper->stringify(0);
+$yaml = $dumper->dump($foo);
+is $yaml, $object_dump, "Local stringification disabled dump";
diff --git a/t/dump-stringy-numbers.t b/t/dump-stringy-numbers.t
new file mode 100644
index 0000000..ac4a625
--- /dev/null
+++ b/t/dump-stringy-numbers.t
@@ -0,0 +1,41 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 6;
+use YAML ();
+use YAML::Dumper;
+
+$YAML::QuoteNumericStrings = 1;
+filters { perl => [qw'eval yaml_dump'], };
+
+ok( YAML::Dumper->is_literal_number(1), '1 is a literal number' );
+ok( !YAML::Dumper->is_literal_number("1"), '"1" is not a literal number' );
+ok( YAML::Dumper->is_literal_number( "1" + 1 ), '"1" +1 is a literal number' );
+
+run_is;
+
+__DATA__
+=== Mixed Literal and Stringy ints
++++ perl
++{ foo => '2', baz => 1 }
++++ yaml
+---
+baz: 1
+foo: '2'
+
+=== Mixed Literal and Stringy floats
++++ perl
++{ foo => '2.000', baz => 1.000 }
++++ yaml
+---
+baz: 1
+foo: '2.000'
+
+=== Numeric Keys
++++ perl
++{ 10 => '2.000', 20 => 1.000, '030' => 2.000 }
++++ yaml
+---
+'030': 2
+'10': '2.000'
+'20': 1
+
diff --git a/t/dump-synopsis.t b/t/dump-synopsis.t
new file mode 100644
index 0000000..d65c49a
--- /dev/null
+++ b/t/dump-synopsis.t
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+my $success = 0;
+my $err;
+{
+ local $@;
+ eval {
+ require YAML::Dumper;
+ my $hash = {};
+ my $dumper = YAML::Dumper->new();
+ my $string = $dumper->dump($hash);
+ $success = 1;
+ };
+ $err = $@;
+}
+is( $success, 1, "Basic YAML::Dumper usage worked as expected" )
+ or diag( explain($err) );
+
diff --git a/t/dump-tests-512.t b/t/dump-tests-512.t
new file mode 100644
index 0000000..cf97c9e
--- /dev/null
+++ b/t/dump-tests-512.t
@@ -0,0 +1,24 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use Test::More;
+BEGIN {
+ if ( qr/x/ =~ /\(\?\^/ ){
+ plan skip_all => "test only for perls before v5.13.5-11-gfb85c04";
+ }
+}
+use TestYAML tests => 1;
+
+no_diff();
+run_roundtrip_nyn('dumper');
+
+__DATA__
+===
++++ no_round_trip
+Since we don't use eval for regexp reconstitution any more (for safety
+sake) this test doesn't roundtrip even though the values are equivalent.
++++ perl
+[qr{bozo$}i]
++++ yaml
+---
+- !!perl/regexp (?i-xsm:bozo$)
+
diff --git a/t/dump-tests-514.t b/t/dump-tests-514.t
new file mode 100644
index 0000000..e115ffc
--- /dev/null
+++ b/t/dump-tests-514.t
@@ -0,0 +1,24 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use Test::More;
+BEGIN {
+ unless ( qr/x/ =~ /\(\?\^/ ){
+ plan skip_all => "test only for perls v5.13.5-11-gfb85c04 or later";
+ }
+}
+use TestYAML tests => 1;
+
+no_diff();
+run_roundtrip_nyn('dumper');
+
+__DATA__
+===
++++ no_round_trip
+Since we don't use eval for regexp reconstitution any more (for safety
+sake) this test doesn't roundtrip even though the values are equivalent.
++++ perl
+[qr{bozo$}i]
++++ yaml
+---
+- !!perl/regexp (?^i:bozo$)
+
diff --git a/t/dump-tests.t b/t/dump-tests.t
new file mode 100644
index 0000000..a27346e
--- /dev/null
+++ b/t/dump-tests.t
@@ -0,0 +1,402 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 57;
+
+no_diff();
+run_roundtrip_nyn('dumper');
+
+__DATA__
+
+===
++++ perl
+[ "foo\nbar", "I like pie\nYou like pie\nWe all like pie" ]
++++ yaml
+---
+- "foo\nbar"
+- |-
+ I like pie
+ You like pie
+ We all like pie
+
+===
++++ perl
+{name => 'Ingy dot Net',
+ rank => 'JAPH',
+ 'serial number' => '8675309',
+};
++++ yaml
+---
+name: Ingy dot Net
+rank: JAPH
+serial number: 8675309
+
+===
++++ perl
+ {fruits => [qw(apples oranges pears)],
+ meats => [qw(beef pork chicken)],
+ vegetables => [qw(carrots peas corn)],
+ }
++++ yaml
+---
+fruits:
+ - apples
+ - oranges
+ - pears
+meats:
+ - beef
+ - pork
+ - chicken
+vegetables:
+ - carrots
+ - peas
+ - corn
+
+===
++++ perl
+['42', '43', '-44', '45']
++++ yaml
+---
+- 42
+- 43
+- -44
+- 45
+
+===
++++ perl
+[
+ 'foo bar',
+ 'http://www.yaml.org',
+ '12:34'
+]
++++ yaml
+---
+- foo bar
+- http://www.yaml.org
+- 12:34
+
+===
++++ perl
+('1', " foo ", "bar\n", [], {})
++++ yaml
+--- 1
+--- ' foo '
+--- "bar\n"
+--- []
+--- {}
+
+===
++++ perl
+'8\'-0" x 24" Lightweight'
++++ yaml
+--- 8'-0" x 24" Lightweight
+
+===
++++ perl
+bless {}, 'Foo::Bar'
++++ yaml
+--- !!perl/hash:Foo::Bar {}
+
+===
++++ perl
+bless {qw(foo 42 bar 43)}, 'Foo::Bar'
++++ yaml
+--- !!perl/hash:Foo::Bar
+bar: 43
+foo: 42
+
+===
++++ perl
+bless [], 'Foo::Bar'
++++ yaml
+--- !!perl/array:Foo::Bar []
+
+===
++++ perl
+bless [map "$_",42..45], 'Foo::Bar'
++++ yaml
+--- !!perl/array:Foo::Bar
+- 42
+- 43
+- 44
+- 45
+
+===
++++ perl
+my $yn = YAML::Node->new({}, 'foo.com/bar');
+$yn->{foo} = 'bar';
+$yn->{bar} = 'baz';
+$yn->{baz} = 'foo';
+$yn
++++ yaml
+--- !foo.com/bar
+foo: bar
+bar: baz
+baz: foo
+
+===
++++ perl
+use YAML::Node;
++++ no_round_trip
++++ perl
+my $a = '';
+bless \$a, 'Foo::Bark';
++++ yaml
+--- !!perl/scalar:Foo::Bark ''
+
+=== Strings with nulls
++++ perl
+"foo\0bar"
++++ yaml
+--- "foo\0bar"
+
+===
++++ no_round_trip
+XXX: probably a YAML.pm bug
++++ perl
+&YAML::VALUE
++++ yaml
+--- =
+
+===
++++ perl
+my $ref = {foo => 'bar'};
+[$ref, $ref]
++++ yaml
+---
+- &1
+ foo: bar
+- *1
+
+===
++++ perl
+no strict;
+package main;
+$joe_random_global = 42;
+@joe_random_global = (43, 44);
+*joe_random_global
++++ yaml
+--- !!perl/glob:
+PACKAGE: main
+NAME: joe_random_global
+SCALAR: 42
+ARRAY:
+ - 43
+ - 44
+
+===
++++ perl
+no strict;
+package main;
+\*joe_random_global
++++ yaml
+--- !!perl/ref
+=: !!perl/glob:
+ PACKAGE: main
+ NAME: joe_random_global
+ SCALAR: 42
+ ARRAY:
+ - 43
+ - 44
+
+===
++++ no_round_trip
++++ perl
+my $foo = {qw(apple 1 banana 2 carrot 3 date 4)};
+YAML::Bless($foo)->keys([qw(banana apple date)]);
+$foo
++++ yaml
+---
+banana: 2
+apple: 1
+date: 4
+
+===
++++ no_round_trip
++++ perl
+use YAML::Node;
+my $foo = {qw(apple 1 banana 2 carrot 3 date 4)};
+my $yn = YAML::Node->new($foo);
+YAML::Bless($foo, $yn)->keys([qw(apple)]); # red herring
+ynode($yn)->keys([qw(banana date)]);
+$foo
++++ yaml
+---
+banana: 2
+date: 4
+
+===
++++ no_round_trip
+XXX: probably a test driver bug
++++ perl
+my $joe_random_global = {qw(apple 1 banana 2 carrot 3 date 4)};
+YAML::Bless($joe_random_global, 'TestBless');
+return [$joe_random_global, $joe_random_global];
+package TestBless;
+use YAML::Node;
+sub yaml_dump {
+ my $yn = YAML::Node->new($_[0]);
+ ynode($yn)->keys([qw(apple pear carrot)]);
+ $yn->{pear} = $yn;
+ return $yn;
+}
++++ yaml
+---
+- &1
+ apple: 1
+ pear: *1
+ carrot: 3
+- *1
+
+===
++++ no_round_trip
++++ perl
+use YAML::Node;
+my $joe_random_global = {qw(apple 1 banana 2 carrot 3 date 4)};
+YAML::Bless($joe_random_global);
+my $yn = YAML::Blessed($joe_random_global);
+delete $yn->{banana};
+$joe_random_global
++++ yaml
+---
+apple: 1
+carrot: 3
+date: 4
+
+===
++++ perl
+my $joe_random_global = \\\\\\\'42';
+[
+ $joe_random_global,
+ $$$$joe_random_global,
+ $joe_random_global,
+ $$$$$$$joe_random_global,
+ $$$$$$$$joe_random_global
+]
++++ yaml
+---
+- &1 !!perl/ref
+ =: !!perl/ref
+ =: !!perl/ref
+ =: &2 !!perl/ref
+ =: !!perl/ref
+ =: !!perl/ref
+ =: &3 !!perl/ref
+ =: 42
+- *2
+- *1
+- *3
+- 42
+
+===
++++ perl
+local $YAML::Indent = 1;
+[{qw(foo 42 bar 44)}]
++++ yaml
+---
+- bar: 44
+ foo: 42
+
+===
++++ perl
+local $YAML::Indent = 4;
+[{qw(foo 42 bar 44)}]
++++ yaml
+---
+- bar: 44
+ foo: 42
+
+===
++++ perl
+[undef, undef]
++++ yaml
+---
+- ~
+- ~
+
+===
++++ perl
+my $joe_random_global = [];
+push @$joe_random_global, $joe_random_global;
+bless $joe_random_global, 'XYZ';
+$joe_random_global
++++ yaml
+--- &1 !!perl/array:XYZ
+- *1
+
+===
++++ perl
+[
+ '23',
+ '3.45',
+ '123456789012345',
+]
++++ yaml
+---
+- 23
+- 3.45
+- 123456789012345
+
+===
++++ perl
+{'foo: bar' => 'baz # boo', 'foo ' => ' monkey', }
++++ yaml
+---
+'foo ': ' monkey'
+'foo: bar': 'baz # boo'
+
+===
++++ no_round_trip
++++ perl
+$a = \\\\\\\\"foo"; $b = $$$$$a;
+([$a, $b], [$b, $a])
++++ yaml
+---
+- !!perl/ref
+ =: !!perl/ref
+ =: !!perl/ref
+ =: !!perl/ref
+ =: &1 !!perl/ref
+ =: !!perl/ref
+ =: !!perl/ref
+ =: !!perl/ref
+ =: foo
+- *1
+---
+- &1 !!perl/ref
+ =: !!perl/ref
+ =: !!perl/ref
+ =: !!perl/ref
+ =: foo
+- !!perl/ref
+ =: !!perl/ref
+ =: !!perl/ref
+ =: !!perl/ref
+ =: *1
+
+===
++++ no_round_trip
+XXX an AutoBless feature could make this rt
++++ perl
+$a = YAML::Node->new({qw(a 1 b 2 c 3 d 4)}, 'ingy.com/foo');
+YAML::Node::ynode($a)->keys([qw(d b a)]);
+$a;
++++ yaml
+--- !ingy.com/foo
+d: 4
+b: 2
+a: 1
+
+===
++++ no_round_trip
++++ perl
+$a = 'bitter buffalo';
+bless \$a, 'Heart';
++++ yaml
+--- !!perl/scalar:Heart bitter buffalo
+
+===
++++ perl
+{ 'foo[bar]' => 'baz' }
++++ yaml
+---
+'foo[bar]': baz
diff --git a/t/dump-works.t b/t/dump-works.t
new file mode 100644
index 0000000..fbbe860
--- /dev/null
+++ b/t/dump-works.t
@@ -0,0 +1,17 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML;
+
+run_is;
+
+sub yaml_dump {
+ return Dump(@_);
+}
+
+__DATA__
+=== A one key hash
++++ perl eval yaml_dump
++{foo => 'bar'}
++++ yaml
+---
+foo: bar
diff --git a/t/errors.t b/t/errors.t
new file mode 100644
index 0000000..b616945
--- /dev/null
+++ b/t/errors.t
@@ -0,0 +1,387 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 35;
+$^W = 1;
+
+use YAML::Error;
+
+filters {
+ error => 'regexp',
+ yaml => [mutate_yaml => 'yaml_load_error_or_warning' => 'check_yaml'],
+ perl => 'perl_eval_error_or_warning',
+};
+
+run_like('yaml' => 'error');
+run_like('perl' => 'error');
+
+sub mutate_yaml {
+ s/\Q<%CNTL-G%>\E/\007/;
+ chomp if /msg_no_newline/;
+}
+
+sub check_yaml {
+ my $yaml = shift;
+ return $yaml unless ref($yaml);
+ print "YAML actually loaded:\n" . Data::Dumper::Dumper($yaml);
+ return '';
+}
+
+__DATA__
+=== YAML_PARSE_ERR_BAD_CHARS
++++ error: YAML_PARSE_ERR_BAD_CHARS
++++ yaml
+# Test msg_bad_chars
+---
+- foo
+# The next line contains an escape character
+- bell -><%CNTL-G%><-
+
+=== YAML_PARSE_ERR_BAD_MAJOR_VERSION
++++ error: YAML_PARSE_ERR_BAD_MAJOR_VERSION
++++ yaml
+# Test msg_bad_major_version
+---
+- one
+- two
+--- #YAML:2.0
+- foo
+- bar
+
+=== YAML_PARSE_WARN_BAD_MINOR_VERSION
++++ error: YAML_PARSE_WARN_BAD_MINOR_VERSION
++++ yaml
+# Test msg_bad_minor_version
+---
+- one
+- two
+--- #YAML:1.5
+- foo
+- bar
+
+=== YAML_PARSE_WARN_MULTIPLE_DIRECTIVES
++++ error: YAML_PARSE_WARN_MULTIPLE_DIRECTIVES
++++ yaml
+# Test msg_multiple_directives
+--- #YAML:1.0 #YAML:1.0
+- foo
+--- #FOO:2 #FOO:3
+- bar
+
+=== YAML_PARSE_ERR_TEXT_AFTER_INDICATOR
++++ error: YAML_PARSE_ERR_TEXT_AFTER_INDICATOR
++++ yaml
+# Test msg_text_after_indicator
+---
+- >
+ This is OK.
+- > But this is not
+- This is OK
+
+=== YAML_PARSE_ERR_NO_ANCHOR
++++ error: YAML_PARSE_ERR_NO_ANCHOR
++++ yaml
+# Test msg_no_anchor
+---
+- &moo foo
+- bar
+- *star
+- &star far
+
+=== YAML_PARSE_ERR_INCONSISTENT_INDENTATION
++++ error: YAML_PARSE_ERR_INCONSISTENT_INDENTATION
++++ yaml
+--- {foo: bar}
+- foo
+- bar
+
+=== YAML_PARSE_ERR_SINGLE_LINE
++++ error: YAML_PARSE_ERR_SINGLE_LINE
++++ yaml
+---
+- "foo" bar
+
+=== YAML_PARSE_ERR_BAD_ANCHOR
++++ error: YAML_PARSE_ERR_BAD_ANCHOR
++++ yaml
+---
+- &X=y 42
+
+#---
+#error: YAML_PARSE_ERR_BAD_NODEX
+#load: |
+#---
+#error: YAML_PARSE_ERR_BAD_EXPLICITX
+#load: |
+# I don't think this one can ever happen (yet)
+#---
+#error: YAML_DUMP_USAGE_DUMPCODE
+#code: |
+# local $YAML::DumpCode = [0];
+# Dump(sub { $foo + 42 });
+
+=== YAML_LOAD_ERR_FILE_INPUT
++++ error: YAML_LOAD_ERR_FILE_INPUT
++++ perl
+LoadFile('fooxxx');
+# XXX - Causing bus error!?!?
+#---
+#error: YAML_DUMP_ERR_FILE_CONCATENATE
+#code: |
+# DumpFile(">> YAML.pod", 42);
+
+=== YAML_DUMP_ERR_FILE_OUTPUT
++++ error: YAML_DUMP_ERR_FILE_OUTPUT
++++ perl
+Test::YAML::DumpFile("x/y/z.yaml", 42);
+
+=== YAML_DUMP_ERR_NO_HEADER
++++ error: YAML_DUMP_ERR_NO_HEADER
++++ perl
+local $YAML::UseHeader = 0;
+Test::YAML::Dump(42);
+
+=== YAML_DUMP_ERR_NO_HEADER
++++ error: YAML_DUMP_ERR_NO_HEADER
++++ perl
+local $YAML::UseHeader = 0;
+Test::YAML::Dump([]);
+
+=== YAML_DUMP_ERR_NO_HEADER
++++ error: YAML_DUMP_ERR_NO_HEADER
++++ perl
+local $YAML::UseHeader = 0;
+Test::YAML::Dump({});
+#---
+#error: xYAML_DUMP_WARN_BAD_NODE_TYPE
+#code: |
+# #
+#---
+#error: YAML_EMIT_WARN_KEYS
+#code: |
+# #
+#---
+#error: YAML_DUMP_WARN_DEPARSE_FAILED
+#code: |
+# #
+#---
+#error: YAML_DUMP_WARN_CODE_DUMMY
+#code: |
+# Dump(sub{ 42 });
+
+=== YAML_PARSE_ERR_MANY_EXPLICIT
++++ error: YAML_PARSE_ERR_MANY_EXPLICIT
++++ yaml
+---
+- !foo !bar 42
+
+=== YAML_PARSE_ERR_MANY_IMPLICIT
++++ error: YAML_PARSE_ERR_MANY_IMPLICIT
++++ yaml
+---
+- ! ! "42"
+
+=== YAML_PARSE_ERR_MANY_ANCHOR
++++ error: YAML_PARSE_ERR_MANY_ANCHOR
++++ yaml
+---
+- &foo &bar 42
+
+=== YAML_PARSE_ERR_ANCHOR_ALIAS
++++ error: YAML_PARSE_ERR_ANCHOR_ALIAS
++++ yaml
+---
+- &bar *foo
+
+=== YAML_PARSE_ERR_BAD_ALIAS
++++ error: YAML_PARSE_ERR_BAD_ALIAS
++++ yaml
+---
+- *foo=bar
+
+=== YAML_PARSE_ERR_MANY_ALIAS
++++ error: YAML_PARSE_ERR_MANY_ALIAS
++++ yaml
+---
+- *foo *bar
+
+=== YAML_LOAD_ERR_NO_CONVERT
++++ SKIP
+Actually this should load into a ynode...
++++ error: YAML_LOAD_ERR_NO_CONVERT
++++ yaml
+---
+- !foo shoe
+
+=== YAML_LOAD_ERR_NO_DEFAULT_VALUE
++++ error: YAML_LOAD_ERR_NO_DEFAULT_VALUE
++++ yaml
+---
+- !perl/ref
+ foo: bar
+#---
+#error: YAML_LOAD_ERR_NON_EMPTY_STRING
+#load: |
+# ---
+# - !map foo
+#---
+#error: YAML_LOAD_ERR_NON_EMPTY_STRING
+#load: |
+# ---
+# - !seq foo
+#---
+#error: YAML_LOAD_ERR_BAD_MAP_TO_SEQ
+#load: |
+# --- !seq
+# 0: zero
+# won: one
+# 2: two
+# 3: three
+#---
+#error: YAML_LOAD_ERR_BAD_GLOB
+#load: |
+# #
+#---
+#error: YAML_LOAD_ERR_BAD_REGEXP
+#load: |
+# #
+
+=== YAML_LOAD_ERR_BAD_MAP_ELEMENT
++++ error: YAML_LOAD_ERR_BAD_MAP_ELEMENT
++++ yaml
+---
+foo: bar
+bar
+
+=== YAML_LOAD_WARN_DUPLICATE_KEY
++++ error: YAML_LOAD_WARN_DUPLICATE_KEY
++++ yaml
+---
+foo: bar
+bar: boo
+foo: baz
+boo: bah
+
+=== YAML_LOAD_ERR_BAD_SEQ_ELEMENT
++++ error: YAML_LOAD_ERR_BAD_SEQ_ELEMENT
++++ yaml
+---
+- 42
+foo
+
+=== YAML_PARSE_ERR_INLINE_MAP
++++ error: YAML_PARSE_ERR_INLINE_MAP
++++ yaml
+---
+- {foo:bar}
+
+=== YAML_PARSE_ERR_INLINE_SEQUENCE
++++ error: YAML_PARSE_ERR_INLINE_SEQUENCE
++++ yaml
+---
+- [foo bar, baz
+
+=== YAML_PARSE_ERR_BAD_DOUBLE
++++ error: YAML_PARSE_ERR_BAD_DOUBLE
++++ yaml
+---
+- "foo baz
+
+=== YAML_PARSE_ERR_BAD_SINGLE
++++ error: YAML_PARSE_ERR_BAD_SINGLE
++++ yaml
+---
+- 'foo bar
+
+=== YAML_PARSE_ERR_BAD_INLINE_IMPLICIT
++++ error: YAML_PARSE_ERR_BAD_INLINE_IMPLICIT
++++ yaml
+---
+- [^gold]
+
+=== YAML_PARSE_ERR_BAD_IMPLICIT
++++ error: YAML_PARSE_ERR_BAD_IMPLICIT
++++ yaml
+--- ! >
+- 4 foo bar
+#---
+#error: xYAML_PARSE_ERR_INDENTATION
+#load: |
+# ---
+
+=== YAML_PARSE_ERR_INCONSISTENT_INDENTATION
++++ error: YAML_PARSE_ERR_INCONSISTENT_INDENTATION
++++ yaml
+---
+foo: bar
+ bar: baz
+#---
+#error: xYAML_LOAD_WARN_UNRESOLVED_ALIAS
+#load: |
+# ---
+# foo: *bar
+
+# === YAML_LOAD_WARN_NO_REGEXP_IN_REGEXP
+# +++ error: YAML_LOAD_WARN_NO_REGEXP_IN_REGEXP
+# +++ yaml
+# ---
+# - !perl/regexp:
+# foo: bar
+#
+# === YAML_LOAD_WARN_BAD_REGEXP_ELEM
+# +++ error: YAML_LOAD_WARN_BAD_REGEXP_ELEM
+# +++ yaml
+# ---
+# - !perl/regexp:
+# REGEXP: foo
+# foo: bar
+
+=== YAML_LOAD_WARN_GLOB_NAME
++++ error: YAML_LOAD_WARN_GLOB_NAME
++++ yaml
+---
+- !perl/glob:
+ foo: bar
+#---
+#error: xYAML_LOAD_WARN_PARSE_CODE
+#load: |
+# ---
+#---
+#error: YAML_LOAD_WARN_CODE_DEPARSE
+#load: |
+# ---
+# - !perl/code |
+# sub { "foo" }
+#---
+#error: xYAML_EMIT_ERR_BAD_LEVEL
+#code:
+# #
+#---
+#error: YAML_PARSE_WARN_AMBIGUOUS_TAB
+#load: |
+# ---
+# - |
+# foo
+# bar
+
+=== YAML_LOAD_WARN_BAD_GLOB_ELEM
++++ error: YAML_LOAD_WARN_BAD_GLOB_ELEM
++++ yaml
+---
+- !perl/glob:
+ NAME: foo
+ bar: SHAME
+
+=== YAML_PARSE_ERR_ZERO_INDENT
++++ error: YAML_PARSE_ERR_ZERO_INDENT
++++ yaml
+---
+- |0
+ foo
+
+=== YAML_PARSE_ERR_NONSPACE_INDENTATION
++++ error: YAML_PARSE_ERR_NONSPACE_INDENTATION
++++ yaml
+---
+some:
+ data-preceded-with-tab: abc
+
diff --git a/t/export.t b/t/export.t
new file mode 100644
index 0000000..9e51d9d
--- /dev/null
+++ b/t/export.t
@@ -0,0 +1,18 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use lib 'inc';
+use Test::YAML();
+BEGIN {
+ @Test::YAML::EXPORT =
+ grep { not /^(Dump|Load)(File)?$/ } @Test::YAML::EXPORT;
+}
+use TestYAML tests => 3;
+
+use YAML;
+
+ok defined(&Dump),
+ 'Dump() is exported';
+ok defined(&Load),
+ 'Load() is exported';
+ok not(defined &Store),
+ 'Store() is not exported';
diff --git a/t/freeze-thaw.t b/t/freeze-thaw.t
new file mode 100644
index 0000000..e52e450
--- /dev/null
+++ b/t/freeze-thaw.t
@@ -0,0 +1,32 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use lib 'inc';
+use Test::YAML();
+BEGIN {
+ @Test::YAML::EXPORT =
+ grep { not /^(Dump|Load)(File)?$/ } @Test::YAML::EXPORT;
+}
+use TestYAML tests => 9;
+
+use YAML qw(Dump Load freeze thaw);
+
+my $hash = { foo => 42, bar => 44 };
+
+my $ice = freeze($hash);
+
+ok defined(&Dump), 'Dump exported';
+ok defined(&Load), 'Load exported';
+ok defined(&freeze), 'freeze exported';
+ok defined(&thaw), 'thaw exported';
+
+like $ice, qr{bar.*foo}s, 'freeze works';
+
+is $ice, Dump($hash), 'freeze produces same thing as Dump';
+
+my $melt = thaw($ice);
+
+is_deeply $melt, Load($ice), 'thaw produces same thing as Load';
+
+is_deeply $melt, $hash, 'freeze/thaw makes a clone';
+
+is ref($melt), 'HASH', 'Melted object really is a hash';
diff --git a/t/global-api.t b/t/global-api.t
new file mode 100644
index 0000000..5932ef9
--- /dev/null
+++ b/t/global-api.t
@@ -0,0 +1,32 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use lib 'inc';
+use Test::YAML();
+BEGIN {
+ @Test::YAML::EXPORT =
+ grep { not /^(Dump|Load)(File)?$/ } @Test::YAML::EXPORT;
+}
+use TestYAML tests => 4;
+use YAML;
+
+{
+ no warnings qw'once redefine';
+ require YAML::Dumper;
+
+ local *YAML::Dumper::dump =
+ sub { return 'got to dumper' };
+
+ require YAML::Loader;
+ local *YAML::Loader::load =
+ sub { return 'got to loader' };
+
+ is Dump(\%ENV), 'got to dumper',
+ 'Dump got to the business end';
+ is Load(\%ENV), 'got to loader',
+ 'Load got to the business end';
+
+ is Dump(\%ENV), 'got to dumper',
+ 'YAML::Dump got to the business end';
+ is Load(\%ENV), 'got to loader',
+ 'YAML::Load got to the business end';
+}
diff --git a/t/inbox.t b/t/inbox.t
new file mode 100644
index 0000000..e6a1790
--- /dev/null
+++ b/t/inbox.t
@@ -0,0 +1,22 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 3;
+
+SKIP: {
+ skip 'fix this next release', 3;
+ my $x;
+ is(Dump(bless(\$x)), 'foo');
+}
+
+__END__
+03:14 < audreyt> ingy:
+03:14 < audreyt> use YAML; my $x; print Dump bless(\$x);
+03:14 < audreyt> is erroneous
+03:14 < audreyt> then
+03:14 < audreyt> use YAML; my $x = \3; print Dump bless(\$x);
+03:14 < audreyt> is fatal error
+03:15 < audreyt> use YAML; my $x; $x = \$x; print Dump bless(\$x);
+03:15 < audreyt> is scary fatal error
+03:15 < audreyt> (YAML::Syck handles all three ^^;)
+03:16 * audreyt goes back to do $job work
+
diff --git a/t/issue-149.t b/t/issue-149.t
new file mode 100644
index 0000000..016d8f1
--- /dev/null
+++ b/t/issue-149.t
@@ -0,0 +1,10 @@
+use Test::More;
+use YAML;
+
+YAML::Load("a: b");
+YAML::Load("a:\n b: c");
+YAML::Load("a: b\nc: d");
+
+pass "YAML w/o final newlines loads";
+
+done_testing;
diff --git a/t/load-fails.t b/t/load-fails.t
new file mode 100644
index 0000000..645fa4e
--- /dev/null
+++ b/t/load-fails.t
@@ -0,0 +1,54 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+# This simply tests that a given piece of invalid YAML fails to parse
+use TestYAML tests => 4;
+
+filters {
+ msg => 'regexp',
+ yaml => 'yaml_load_or_fail',
+};
+
+run_like yaml => 'msg';
+
+__DATA__
+
+===
++++ SKIP
+This test hangs YAML.pm
++++ msg
+YAML Error: Inconsistent indentation level
++++ yaml
+a: *
+
+
+===
++++ msg
+YAML Error: Inconsistent indentation level
++++ yaml
+--- |\
+foo\zbar
+
+
+===
++++ msg
+YAML Error: Unrecognized implicit value
++++ yaml
+--- @ 42
+
+
+===
++++ msg
+YAML Error: Inconsistent indentation level
++++ yaml
+---
+ - 1
+ -2
+
+
+===
++++ msg
+Unrecognized TAB policy
++++ yaml
+--- #TAB:MOBY
+- foo
+
diff --git a/t/load-passes.t b/t/load-passes.t
new file mode 100644
index 0000000..ce72033
--- /dev/null
+++ b/t/load-passes.t
@@ -0,0 +1,70 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 8;
+
+run_load_passes();
+
+__DATA__
+
+=== Bug reported by Rich Morin
++++ SKIP
++++ yaml
+foo:
+ - >
+ This is a test.
+
+=== Bug reported by audreyt
++++ SKIP
++++ yaml
+--- "\n\
+\r"
+
+===
++++ yaml
+---
+foo:
+ bar:
+ baz:
+ poo: bah
+
+
+===
++++ yaml
+--- 42
+
+
+===
++++ yaml
+# comment
+--- 42
+# comment
+
+
+===
++++ yaml
+--- [1, 2, 3]
+
+
+===
++++ yaml
+--- {foo: bar, bar: 42}
+
+
+===
++++ yaml
+--- !foo.com/bar
+- 2
+
+
+===
++++ yaml
+--- &1 !foo.com/bar
+- 42
+
+
+===
++++ yaml
+---
+ - 40
+ - 41
+ - foof
diff --git a/t/load-slides.t b/t/load-slides.t
new file mode 100644
index 0000000..9a5f83d
--- /dev/null
+++ b/t/load-slides.t
@@ -0,0 +1,360 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+# This tests the slides I used for YAPC 2002
+use TestYAML tests => 28;
+
+run_load_passes();
+
+__DATA__
+===
++++ yaml
+YAML design goals:
+ - YAML documents are very readable by humans.
+ - YAML interacts well with scripting languages.
+ - YAML uses host languages native data structures.
+ - YAML has a consistent information model.
+ - YAML enables stream-based processing.
+ - YAML is expressive and extensible.
+ - YAML is easy to implement.
+
+===
++++ yaml
+---
+scripting languages:
+ - Perl
+ - Python
+ - C
+ - Java
+standards:
+ - RFC0822 (MAIL)
+ - RFC1866 (HTML)
+ - RFC2045 (MIME)
+ - RFC2396 (URI)
+others:
+ - SOAP
+ - XML
+ - SAX
+
+===
++++ yaml
+---
+name: Benjamin
+rank: Private
+serial number: 1234567890
+12:34 PM: My favorite time
+
+===
++++ yaml
+---
+- red
+- white
+- blue
+- pinko
+
+===
++++ yaml
+---
+Fruits:
+ - Apples
+ - Tomatoes
+Veggies:
+ - Spinach
+ - Broccoli
+Meats:
+ - Burgers
+ - Shrimp
+Household:
+ - Candles
+ - Incense
+ - Toilet Duck
+
+===
++++ yaml
+---
+-
+ - 3
+ - 5
+ - 7
+-
+ - 0
+ - 0
+ - 7
+-
+ - 9
+ - 1
+ - 1
+
+===
++++ yaml
+- Intro
+-
+ Part 1:
+ - Up
+ - Down
+ - Side to Side
+- Part 2:
+ - Here
+ - There
+ - Underwear
+- Part 3:
+ - The Good
+ - The Bad
+ - The Ingy
+
+===
++++ yaml
+## comment before document
+#--- #DIRECTIVE # comment
+#foo: bar # inline comment
+#
+#phone: number #555-1234
+# ### Comment
+#fact: fiction
+#---
+#blue: bird
+## Comment
+
+===
++++ yaml
+---
+simple: look ma, no quotes
+quoted:
+ - 'Single quoted. Like Perl, no escapes'
+ - "Double quotes.\nLike Perl, has escapes"
+ - |
+ A YAML block scalar.
+ Much like Perl's
+ here-document.
+
+===
++++ yaml
+#---
+#simple key: simple value
+#this value: can span multiple lines
+# but the key cannot. it would need quotes
+#stuff:
+# - foo
+# - 42
+# - 3.14
+# - 192.168.2.98
+# - m/^(.*)\//
+
+===
++++ yaml
+#---
+#'contains: colon': '$19.99'
+#or: ' value has leading/trailing whitespace '
+#'key spans
+#lines': 'double ticks \ for ''escaping'''
+
+===
++++ yaml
+#---
+#The spec says: "The double quoted style variant adds escaping to the 'single quoted' style variant."
+#
+#like this: "null->\z newline->\n bell->\a
+#smiley->\u263a"
+#
+#self escape: "Brian \"Ingy\" Ingerson"
+
+===
++++ yaml
+---
+what is this: |
+ is it: a YAML mapping
+ or just: a string
+
+chomp me: |-
+ sub foo {
+ print "Love me do!";
+ }
+
+===
++++ yaml
+--- #YAML:1.0
+old doc: |
+ --- #YAML:1.0
+ tools:
+ - XML
+ - XSLT
+new doc: |
+ --- #YAML:1.0
+ tools:
+ - YAML
+ - cYATL
+
+===
++++ yaml
+---
+- >
+ Copyright © 2001 Brian Ingerson, Clark
+ Evans & Oren Ben-Kiki, all rights
+ reserved. This document may be freely
+ copied provided that it is not modified.
+
+ Next paragraph.
+
+- foo
+
+===
++++ yaml
+---
+The YAML Specification starts out by saying: >
+ YAML(tm) (rhymes with "camel") is a straightforward
+ machine parsable data serialization format designed
+ for human readability and interaction with
+ scripting languages such as Perl and Python.
+
+ YAML documents are very readable by humans.
+ YAML interacts well with scripting languages.
+ YAML uses host languages' native data structures.
+
+ Please join us, the mailing list is at SourceForge.
+
+===
++++ yaml
+---
+? >+
+ Even a key can:
+ 1) Be Folded
+ 2) Have Wiki
+
+: cool, eh?
+
+===
++++ yaml
+---
+Hey Jude: &chorus
+ - na, na, na,
+ - &4 na, na, na, na,
+ - *4
+ - Hey Jude.
+ - *chorus
+
+===
++++ yaml
+headerless: first document
+--- #YAML:1.0 #TAB:NONE
+--- >
+folded top level scalar
+--- &1
+recurse: *1
+---
+- simple header
+
+===
++++ yaml
+#---
+#seq: [ 14, 34, 55 ]
+#map: {purple: rain, blue: skies}
+#mixed: {sizes: [9, 11], shapes: [round]}
+#span: {players: [who, what, I don't know],
+# positions: [first, second, third]}
+
+===
++++ yaml
+## Inline sequences make data more compact
+#---
+#- [3, 5, 7]
+#- [0, 0, 7]
+#- [9, 1, 1]
+#
+## Above is equal to below
+#--- [[3, 5, 7], [0, 0, 7], [9, 1, 1]]
+#
+## A 3D Matrix
+#---
+#- [[3, 5, 7], [0, 0, 7], [9, 1, 1]]
+#- [[0, 0, 7], [9, 1, 1], [3, 5, 7]]
+#- [[9, 1, 1], [3, 5, 7], [0, 0, 7]]
+
+===
++++ yaml
+---
+?
+ - Kane
+ - Kudra
+: engaged
+[Damian, Dominus]: engaging
+
+===
++++ yaml
+#same:
+# - 42
+# - !int 42
+# - !yaml.org/int 42
+# - !http://yaml.org/int 42
+#perl:
+# - !perl/Foo::Bar {}
+# - !perl.yaml.org/Foo::Bar {}
+# - !http://perl.yaml.org/Foo::Bar {}
+
+===
++++ yaml
+#---
+#- 42 # integer
+#- -3.14 # floating point
+#- 6.02e+23 # scientific notation
+#- 0xCAFEBABE # hexadecimal int
+#- 2001-09-11 # ISO8601 time
+#- '2001-09-11' # string
+#- + # boolean true
+#- (false) # alternate boolean
+#- ~ # null (undef in Perl)
+#- 123 Main St # string
+
+===
++++ yaml
+#---
+#- !str YAML, YAML, YAML!
+#- !int 42
+#- !float 0.707
+#- !time 2001-12-14T21:59:43.10-05:00
+#- !bool 1
+#- !null 0
+#- !binary MWYNG84BwwEeECcgggoBADs=
+
+===
++++ yaml
+#---
+#- !perl/Foo::Bar {} # hash-based class
+#- !perl/@Foo::Bar [] # array-based class
+#- !perl/$Foo::Bar '' # scalar-based class
+#- !perl/glob: # typeglob
+#- !perl/code: # code reference
+#- !perl/ref: # hard reference
+#- !perl/regexp: # regular expression
+#- !perl/regexp:Foo::Bar # blessed regexp
+
+===
++++ yaml
+--- #YAML:1.0
+NAME: AddressEntry
+HASH:
+ - NAME: Name
+ HASH:
+ - NAME: First
+ - NAME: Last
+ OPTIONAL: yes
+ - NAME: EmailAddresses
+ ARRAY: yes
+ - NAME: Phone
+ ARRAY: yes
+ HASH:
+ - NAME: Type
+ OPTIONAL: yes
+ - NAME: Number
+
+===
++++ yaml
+--- #YAML:1.0
+AddressEntry:
+ Name:
+ First: Brian
+ EmailAddresses:
+ - ingy@CPAN.org
+ - ingy@ttul.org
+ Phone:
+ - Type: Work
+ Number: 604-333-4567
+ - Number: 843-444-5678
diff --git a/t/load-spec.t b/t/load-spec.t
new file mode 100644
index 0000000..92b90b8
--- /dev/null
+++ b/t/load-spec.t
@@ -0,0 +1,711 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 52;
+
+run_load_passes();
+
+__DATA__
+===
++++ yaml
+- Mark McGwire
+- Sammy Sosa
+- Ken Griffey
+
+===
++++ yaml
+hr: 65
+avg: 0.278
+rbi: 147
+
+===
++++ yaml
+american:
+ - Boston Red Sox
+ - Detroit Tigers
+ - New York Yankees
+ - Texas Rangers
+national:
+ - New York Mets
+ - Chicago Cubs
+ - Atlanta Braves
+ - Montreal Expos
+
+===
++++ yaml
+-
+ name: Mark McGwire
+ hr: 65
+ avg: 0.278
+ rbi: 147
+-
+ name: Sammy Sosa
+ hr: 63
+ avg: 0.288
+ rbi: 141
+
+===
++++ yaml
+?
+ - New York Yankees
+ - Atlanta Braves
+:
+ - 2001-07-02
+ - 2001-08-12
+ - 2001-08-14
+?
+ - Detroit Tigers
+ - Chicago Cubs
+:
+ - 2001-07-23
+
+===
++++ yaml
+invoice: 34843
+date : 2001-01-23
+bill-to:
+ given : Chris
+ family : Dumars
+product:
+ - quantity: 4
+ desc : Basketball
+ - quantity: 1
+ desc : Super Hoop
+
+===
++++ yaml
+---
+name: Mark McGwire
+hr: 65
+avg: 0.278
+rbi: 147
+---
+name: Sammy Sosa
+hr: 63
+avg: 0.288
+rbi: 141
+
+===
++++ yaml
+# Ranking of players by
+# season home runs.
+---
+ - Mark McGwire
+ - Sammy Sosa
+ - Ken Griffey
+
+===
++++ yaml
+#hr: # Home runs
+# # 1998 record
+# - Mark McGwire
+# - Sammy Sosa
+#rbi: # Runs batted in
+# - Sammy Sosa
+# - Ken Griffey
+
+===
++++ yaml
+hr:
+ - Mark McGwire
+ # Name "Sammy Sosa" scalar SS
+ - &SS Sammy Sosa
+rbi:
+ # So it can be referenced later.
+ - *SS
+ - Ken Griffey
+
+===
++++ yaml
+--- >
+ Mark McGwire's
+ year was crippled
+ by a knee injury.
+
+===
++++ yaml
+--- |
+ \/|\/|
+ / | |_
+
+===
++++ yaml
+--- >-
+ Sosa completed
+ another fine
+ season.
+
+===
++++ yaml
+#name: Mark McGwire
+#occupation: baseball player
+#comments: Mark set a major
+# league home run
+# record in 1998.
+
+===
++++ yaml
+years: "1998\t1999\t2000\n"
+msg: "Sosa did fine. \u263A"
+
+===
++++ yaml
+- ' \/|\/| '
+- ' / | |_ '
+
+===
++++ yaml
+- [ name , hr , avg ]
+- [ Mark McGwire , 65 , 0.278 ]
+- [ Sammy Sosa , 63 , 0.288 ]
+
+===
++++ yaml
+#Mark McGwire: {hr: 65, avg: 0.278}
+#Sammy Sosa: {hr: 63,
+# avg: 0.288}
+
+===
++++ yaml
+invoice: 34843
+date : 2001-01-23
+buyer:
+ given : Chris
+ family : Dumars
+product:
+ - Basketball: 4
+ - Superhoop: 1
+
+===
++++ yaml
+#invoice: !int|dec 34843
+#date : !time 2001-01-23
+#buyer: !map
+# given : !str Chris
+# family : !str Dumars
+#product: !seq
+# - !str Basketball: !int 4
+# - !str Superhoop: !int 1
+
+===
++++ yaml
+#invoice: !str 34843
+#date : !str 2001-01-23
+
+===
++++ yaml
+#--- !clarkevans.com/schedule/^entry
+#who: Clark C. Evans
+#when: 2001-11-18
+#hours: !^hours 3
+#description: >
+# Wrote up these examples
+# and learned a lot about
+# baseball statistics.
+
+===
++++ yaml
+#--- !clarkevans.com/graph/^shape
+#- !^circle
+# center: &ORIGIN {x: 73, y: 129}
+# radius: 7
+#- !^line [23, 32, 300, 200]
+#- !^text
+# center: *ORIGIN
+# color: 0x02FDBA
+
+===
++++ yaml
+--- !clarkevans.com/^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.
+
+===
++++ yaml
+---
+Date: 2001-11-23
+Time: 15:01:42
+User: ed
+Warning: >
+ This is an error message
+ for the log file
+---
+Date: 2001-11-23
+Time: 15:02:31
+User: ed
+Warning: >
+ A slightly different error
+ message.
+---
+Date: 2001-11-23
+Time: 15:03:17
+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
+
+===
++++ yaml
+###################################
+## These are four throwaway comment
+#
+## lines (the second line is empty).
+#this: | # Comments may trail lines.
+# contains three lines of text.
+# The third one starts with a
+# # character. This isn't a comment.
+#
+## These are four throwaway comment
+## lines (the first line is empty).
+###################################
+
+===
++++ yaml
+--- >
+This YAML stream contains a single text value.
+The next stream is a log file - a sequence of
+log entries. Adding an entry to the log is a
+simple matter of appending it at the end.
+
+===
++++ yaml
+---
+at: 2001-08-12T09:25:00.00
+type: GET
+HTTP: '1.0'
+url: '/index.html'
+---
+at: 2001-08-12T09:25:10.00
+type: GET
+HTTP: '1.0'
+url: '/toc.html'
+
+===
++++ yaml
+## The following is a sequence of three documents.
+## The first contains an empty mapping, the second
+## an empty sequence, and the last an empty string.
+#--- {}
+#--- [ ]
+#--- ''
+
+===
++++ yaml
+## All entries in the sequence
+## have the same type and value.
+#- 10.0
+#- !float 10
+#- !yaml.org/^float '10'
+#- !http://yaml.org/float "\
+# 1\
+# 0"
+
+===
++++ yaml
+## Private types are per-document.
+#---
+#pool: !!ball
+# number: 8
+# color: black
+#---
+#bearing: !!ball
+# material: steel
+
+===
++++ yaml
+## 'http://domain.tld/invoice' is some type family.
+#invoice: !domain.tld/^invoice
+# # 'seq' is shorthand for 'http://yaml.org/seq'.
+# # This does not effect '^customer' below
+# # because it is does not specify a prefix.
+# customers: !seq
+# # '^customer' is shorthand for the full
+# # notation 'http://domain.tld/customer'.
+# - !^customer
+# given : Chris
+# family : Dumars
+
+===
++++ yaml
+## It is possible to use XML namespace URIs as
+## YAML namespaces. Using the ancestor's URI
+## allows specifying it only once. The $ separates
+## between the XML namespace URI and the tag name.
+#doc: !http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd$^html
+# - !^body
+# - !^p This is an HTML paragraph.
+
+===
++++ yaml
+anchor : &A001 This scalar has an anchor.
+override : &A001 >
+ The alias node below is a
+ repeated use of this value.
+alias : *A001
+
+===
++++ yaml
+#empty: []
+#in-line: [ one, two, three # May span lines,
+# , four, # indentation is
+# five ] # mostly ignored.
+#nested:
+# - First item in top sequence
+# -
+# - Subordinate sequence entry
+# - >
+# A multi-line
+# sequence entry
+# - Sixth item in top sequence
+
+===
++++ yaml
+#empty: {}
+#in-line: { one: 1, two: 2 }
+#spanning: { one: 1,
+# two: 2 }
+#nested:
+# first : First entry
+# second:
+# key: Subordinate mapping
+# third:
+# - Subordinate sequence
+# - { }
+# - Previous mapping is empty.
+# - A key: value pair in a sequence.
+# A second: key:value pair.
+# - The previous entry is equal to the following one.
+# -
+# A key: value pair in a sequence.
+# A second: key:value pair.
+# !float 12 : This key is a float.
+# ? >
+# ?
+# : This key had to be protected.
+# "\a" : This key had to be escaped.
+# ? >
+# This is a
+# multi-line
+# folded key
+# : Whose value is
+# also multi-line.
+# ?
+# - This key
+# - is a sequence
+# :
+# - With a sequence value.
+# ?
+# This: key
+# is a: mapping
+# :
+# with a: mapping value.
+
+===
++++ yaml
+empty: |
+detected: |
+ The \ ' " characters may be
+ freely used. Leading white
+ space is significant.
+
+ All line breaks are significant,
+ including the final one. Thus
+ this value contains one empty
+ line and ends with a line break,
+ but does not start with one.
+
+# Comments may follow a nested
+# scalar value. They must be
+# less indented.
+
+# Explicit indentation must
+# be given in all the three
+# following cases.
+leading spaces: |2
+ This value starts with four
+ spaces. It ends with one line
+ break and an empty comment line.
+
+leading line break: |2
+
+ This value starts with
+ a line break and ends
+ with one.
+leading comment indicator: |2
+ # first line starts with a
+ #. This value does not start
+ with a line break but ends
+ with one.
+# Explicit indentation may
+# also be given when it is
+# not required.
+redundant: |2
+ This value is indented 2 spaces.
+stripped: |-
+ This contains no newline.
+
+kept: |+
+ This contains two newlines.
+
+# Comments may follow.
+
+===
++++ yaml
+#empty: >
+#detected: >
+# Line feeds are converted
+# to spaces, so this value
+# contains no line breaks
+# except for the final one.
+#
+#explicit: >2
+#
+# An empty line, either
+# at the start or in
+# the value:
+#
+# Is interpreted as a
+# line break. Thus this
+# value contains three
+# line breaks.
+#
+#stripped: >-1
+# This starts with a space
+# and contains no newline.
+#
+#kept: >1+
+# This starts with a space
+# and contains two newlines.
+#
+#indented: >
+# This is a folded
+# paragraph followed
+# by a list:
+# * first entry
+# * second entry
+# Followed by another
+# folded paragraph,
+# another list:
+#
+# * first entry
+#
+# * second entry
+#
+# And a final folded
+# paragraph.
+#block: | # Equal to above.
+# This is a folded paragraph followed by a list:
+# * first entry
+# * second entry
+# Followed by another folded paragraph and list:
+#
+# * first entry
+#
+# * second entry
+#
+# And a final folded paragraph.
+#
+## Explicit comments may follow
+## but must be less indented.
+
+===
++++ yaml
+#empty: ''
+#second: '! : \ etc. can be used freely.'
+#third: 'a single quote '' must be escaped.'
+#span: 'this contains
+# six spaces
+#
+# and one
+# line break'
+
+===
++++ yaml
+#empty: ""
+#second: "! : etc. can be used freely."
+#third: "a \" or a \\ must be escaped."
+#fourth: "this value ends with an LF.\n"
+#span: "this contains
+# four \
+# spaces"
+
+===
++++ yaml
+#first: There is no unquoted empty string.
+#second: 12 ## This is an integer.
+#third: !str 12 ## This is a string.
+#span: this contains
+# six spaces
+#
+# and one
+# line break
+#indicators: this has no comments.
+# #foo and bar# are
+# all text.
+#in-line: [ can span
+# lines, # comment
+# like
+# this ]
+#note: { one-line keys: but
+# multi-line values }
+
+===
++++ yaml
+## The following are equal seqs
+## with different identities.
+#in-line: [ one, two ]
+#spanning: [ one,
+# two: ]
+#nested:
+# - one
+# - two
+
+===
++++ yaml
+# The following are equal maps
+# with different identities.
+in-line: { one: 1, two: 2 }
+nested:
+ one: 1
+ two: 2
+
+===
++++ yaml
+#- 12 # An integer
+## The following scalars
+## are loaded to the
+## string value '1' '2'.
+#- !str 12
+#- '12'
+#- "12"
+#- "\
+# 1\
+# 2\
+# "
+
+===
++++ yaml
+#canonical: ~
+#verbose: (null)
+#sparse:
+# - ~
+# - Second entry.
+# - (nil)
+# - This sequence has 4 entries, two with values.
+#three: >
+# This mapping has three keys,
+# only two with values.
+
+===
++++ yaml
+#canonical: -
+#logical: (true)
+#informal: (no)
+
+===
++++ yaml
+#canonical: 12345
+#decimal: +12,345
+#octal: 014
+#hexadecimal: 0xC
+
+===
++++ yaml
+#canonical: 1.23015e+3
+#exponential: 12.3015e+02
+#fixed: 1,230.15
+#negative infinity: (-inf)
+#not a number: (NaN)
+
+===
++++ yaml
+canonical: 2001-12-15T02:59:43.1Z
+valid iso8601: 2001-12-14t21:59:43.10-05:00
+space separated: 2001-12-14 21:59:43.10 -05:00
+date (noon UTC): 2002-12-14
+
+===
++++ yaml
+#canonical: !binary "\
+# R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOf\
+# n515eXvPz7Y6OjuDg4J+fn5OTk6enp56enmlpaW\
+# NjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++\
+# f/++f/++f/++f/++f/++f/++f/++SH+Dk1hZGUg\
+# d2l0aCBHSU1QACwAAAAADAAMAAAFLCAgjoEwnuN\
+# AFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84Bww\
+# EeECcgggoBADs="
+#base64: !binary |
+# R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOf
+# n515eXvPz7Y6OjuDg4J+fn5OTk6enp56enmlpaW
+# NjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++
+# f/++f/++f/++f/++f/++f/++f/++SH+Dk1hZGUg
+# d2l0aCBHSU1QACwAAAAADAAMAAAFLCAgjoEwnuN
+# AFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84Bww
+# EeECcgggoBADs=
+#description: >
+# The binary value above is a tiny arrow
+# encoded as a gif image.
+
+===
++++ yaml
+## Old schema
+#---
+#link with:
+# - library1.dll
+# - library2.dll
+#
+## New schema
+#---
+#link with:
+# - = : library1.dll
+# version: 1.2
+# - = : library2.dll
+# version: 2.1
+
+===
++++ yaml
+#"!": These three keys
+#"&": had to be quoted
+#"=": and are normal strings.
+## NOTE: the following encoded node
+## should NOT be serialized this way.
+#encoded node :
+# !special '!' : '!type'
+# !special '&' : 12
+# = : value
+## The proper way to serialize the
+## above structure is as follows:
+#node : !!type &12 value
diff --git a/t/load-tests.t b/t/load-tests.t
new file mode 100644
index 0000000..74ca277
--- /dev/null
+++ b/t/load-tests.t
@@ -0,0 +1,405 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 29;
+
+run {
+ my $block = shift;
+ my @result = eval {
+ Load($block->yaml)
+ };
+ my $error1 = $@ || '';
+ if ( $error1 ) {
+ # $error1 =~ s{line: (\d+)}{"line: $1 ($0:".($1+$test->{lines}{yaml}-1).")"}e;
+ }
+ my @expect = eval $block->perl;
+ my $error2 = $@ || '';
+ if (my $errors = $error1 . $error2) {
+ fail($block->description
+ . $errors);
+ next;
+ }
+ is_deeply(
+ \@result,
+ \@expect,
+ $block->description,
+ ) or do {
+ require Data::Dumper;
+ diag("Wanted: ".Data::Dumper::Dumper(\@expect));
+ diag("Got: ".Data::Dumper::Dumper(\@result));
+ }
+};
+
+__DATA__
+=== a yaml error log
++++ yaml
+---
+date: Sun Oct 28 20:41:17 2001
+error msg: Premature end of script headers
+---
+date: Sun Oct 28 20:41:44 2001
+error msg: malformed header from script. Bad header=</UL>
+---
+date: Sun Oct 28 20:42:19 2001
+error msg: malformed header from script. Bad header=</UL>
++++ perl
+my $a = { map {split /:\s*/, $_, 2} split /\n/, <<END };
+date: Sun Oct 28 20:41:17 2001
+error msg: Premature end of script headers
+END
+my $b = { map {split /:\s*/, $_, 2} split /\n/, <<END };
+date: Sun Oct 28 20:41:44 2001
+error msg: malformed header from script. Bad header=</UL>
+END
+my $c = { map {split /:\s*/, $_, 2} split /\n/, <<END };
+date: Sun Oct 28 20:42:19 2001
+error msg: malformed header from script. Bad header=</UL>
+END
+($a, $b, $c)
+=== comments and some top level documents
++++ yaml
+# Top level documents
+#
+# Note that inline (single line) values
+# are not allowed at the top level. This
+# includes implicit values, quoted values
+# and inline collections.
+---
+a: map
+---
+- a
+- sequence
+--- >
+plain scalar
+--- |
+This
+ is
+ a
+ block.
+ It's
+ kinda
+ like
+ a
+ here
+document.
+--- |-
+A
+ chomped
+ block.
++++ perl
+my $a = {a => 'map'};
+my $b = ['a', 'sequence'];
+my $c = "plain scalar\n";
+my $d = <<END;
+This
+ is
+ a
+ block.
+ It's
+ kinda
+ like
+ a
+ here
+document.
+END
+my $e = <<END;
+A
+ chomped
+ block.
+END
+chomp($e);
+($a, $b, $c, $d, $e)
+=== an array of assorted junk
++++ yaml
+# Inline collections
+#
+# sequence
+---
+- [1,2,3]
+# trailing comma is ignored
+# still 3 elements
+- [1,2,3,]
+# four empty strings
+- [,,,,]
+# a pair of commas
+- [",",","]
+# a map
+- {foo: bar,baz: too}
+# empty sequence
+- []
+# empty map
+- {}
+# times for keys (key/value separator is ': ')
+- {09:00:00: Breakfast, 12:00:00: lunch time,}
+# a private Perl XYZ object
+- !perl/XYZ {small: object}
+# an object containing objects
+- !perl/ABC [!perl/@DEF [a,b,c],!perl/GHI {do: re, mi: fa, so: la,ti: do}]
+# sequences of self referential elements
+# (inline form not working yet) :(
+# - &FOO [*FOO,*FOO,*FOO]
+- &FOO
+ - *FOO
+ - *FOO
+ - *FOO
+#
+# sequence of maps
+- [{name: Ingy},{name: Clark},{name: Oren},]
++++ perl
+my $a = [1,2,3];
+my $b = [1,2,3,];
+my $c = ["","","","",];
+my $d = [",",","];
+my $e = {foo => 'bar', baz => 'too'};
+my $f = [];
+my $g = {};
+my $h = {'09:00:00' => 'Breakfast', '12:00:00' => 'lunch time'};
+my $i = bless {small => 'object'}, 'XYZ';
+my $j = bless [bless([qw(a b c)], 'DEF'),
+ bless({do => 're', mi => 'fa', so => 'la', ti => 'do'}, 'GHI'),
+ ], 'ABC';
+my $k = [];
+push @$k, $k, $k, $k;
+my $l = [{name => 'Ingy'}, {name => 'Clark'}, {name => 'Oren'}, ];
+[$a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k, $l]
+=== a bunch of small top level thingies
++++ yaml
+--- 42
+--- foo
+--- " bar "
+--- []
+--- #YAML:1.0 {}
+--- '#YAML:9.9'
+--- {foo: [1, 2, 3], 12:34:56: bar}
++++ perl
+my $a = 42;
+my $b = "foo";
+my $c = " bar ";
+my $d = [];
+my $e = {};
+my $f = "#YAML:9.9";
+my $g = {foo => [1, 2, 3], '12:34:56' => 'bar'};
+($a, $b, $c, $d, $e, $f, $g)
+=== a headerless sequence and a map
++++ yaml
+- 2
+- 3
+- 4
+--- #YAML:1.0
+foo: bar
++++ perl
+([2,3,4], {foo => 'bar'})
+=== comments in various places
++++ yaml
+ # A pre header comment
+---
+# comment
+ # comment
+ #comment
+- 2
+# comment
+# comment
+- 3
+- 4
+ # comment
+- 5
+# last comment
+--- #YAML:1.0
+boo: far
+ # a comment
+foo : bar
+---
+- >
+ # Not a comment;
+# Is a comment
+ #Not a comment
+--- 42
+ #Final
+ #Comment
++++ perl
+([2,3,4,5],
+ {foo => 'bar', boo => 'far'},
+ ["# Not a comment; #Not a comment\n"],
+ 42)
+=== several docs, some empty
++++ yaml
+---
+- foo
+- bar
+---
+---
+- foo
+- foo
+---
+# comment
+
+---
+- bar
+- bar
++++ perl
+(['foo', 'bar'],undef,['foo', 'foo'],undef,['bar', 'bar'])
+=== a perl reference to a scalar
++++ yaml
+--- !perl/ref:
+ =: 42
++++ perl
+(\42);
+=== date loading
++++ yaml
+---
+- 1964-03-25
+- ! "1975-04-17"
+- !date '2001-09-11'
+- 12:34:00
+- ! "12:00:00"
+- !time '01:23:45'
++++ perl
+['1964-03-25',
+ '1975-04-17',
+ '2001-09-11',
+ '12:34:00',
+ '12:00:00',
+ '01:23:45',
+];
+=== sequence with trailing comment
++++ yaml
+---
+- fee
+- fie
+- foe
+# no num defined
++++ perl
+[qw(fee fie foe)]
+=== a simple literal block
++++ yaml
+---
+- |
+ foo
+ bar
+
++++ perl
+["foo\nbar\n"]
+=== an unchomped literal
++++ yaml -trim
+---
+- |+
+ foo
+ bar
+
++++ perl
+["foo\nbar\n\n"]
+=== a chomped literal
++++ yaml -trim
+---
+- |-
+ foo
+ bar
+
++++ perl
+["foo\nbar"]
+=== assorted numerics
++++ yaml
+---
+#- -
+#- +
+- 44
+- -45
+- 4.6
+- -4.7
+- 3e+2
+- [-4e+3, 5e-4]
+- -6e-10
+- 2001-12-15
+- 2001-12-15T02:59:43.1Z
+- 2001-12-14T21:59:43.25-05:00
++++ perl
+[44, -45, 4.6, -4.7, '3e+2', ['-4e+3', '5e-4'], '-6e-10',
+ '2001-12-15', '2001-12-15T02:59:43.1Z', '2001-12-14T21:59:43.25-05:00',
+]
+=== an empty string top level doc
++++ yaml
+---
++++ perl
+undef
+
+=== an array of various undef
++++ yaml
+---
+-
+-
+- ''
++++ perl
+[undef,undef,'']
+=== !!perl/array
++++ yaml
+--- !!perl/array
+- 1
++++ perl
+[ 1 ]
+=== !!perl/array:
++++ yaml
+--- !!perl/array:
+- 1
++++ perl
+[ 1 ]
+=== !!perl/array:moose
++++ yaml
+--- !!perl/array:moose
+- 1
++++ perl
+bless([ 1 ], "moose")
+=== foo
++++ yaml
+--- !!perl/hash
+foo: bar
++++ perl
+{ foo => "bar" }
+=== foo
++++ yaml
+--- !!perl/hash:
+foo: bar
++++ perl
+{ foo => "bar" }
+=== foo
++++ yaml
+--- !!perl/array:moose
+foo: bar
++++ perl
+bless({ foo => "bar" }, "moose")
+=== foo
++++ yaml
+--- !!perl/ref
+=: 1
++++ perl
+\1
+=== foo
++++ yaml
+--- !!perl/ref:
+=: 1
++++ perl
+\1
+=== foo
++++ yaml
+--- !!perl/ref:moose
+=: 1
++++ perl
+bless(do { my $x = 1; \$x}, "moose")
+=== foo
++++ yaml
+--- !!perl/scalar 1
++++ perl
+1
+=== foo
++++ yaml
+--- !!perl/scalar: 1
++++ perl
+1
+=== foo
++++ yaml
+--- !!perl/scalar:moose 1
++++ perl
+bless(do { my $x = 1; \$x}, "moose")
+=== ^ can start implicit
++++ yaml
+- ^foo
++++ perl
+['^foo']
diff --git a/t/load-works.t b/t/load-works.t
new file mode 100644
index 0000000..dc3afbf
--- /dev/null
+++ b/t/load-works.t
@@ -0,0 +1,18 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML;
+
+filters {
+ perl => 'eval',
+ yaml => 'yaml_load',
+};
+
+run_is_deeply;
+
+__DATA__
+=== A one key hash
++++ perl
++{foo => 'bar'}
++++ yaml
+---
+foo: bar
diff --git a/t/long-quoted-value.yaml b/t/long-quoted-value.yaml
new file mode 100644
index 0000000..e3f007e
--- /dev/null
+++ b/t/long-quoted-value.yaml
@@ -0,0 +1,2 @@
+---
+hello: "A stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA stringA string"
diff --git a/t/marshall.t b/t/marshall.t
new file mode 100644
index 0000000..d64258d
--- /dev/null
+++ b/t/marshall.t
@@ -0,0 +1,120 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 10;
+
+use strict;
+use warnings;
+
+#-------------------------------------------------------------------------------
+package Foo::Bar;
+BEGIN {
+ require TestYAMLBase;
+ @Foo::Bar::ISA = 'TestYAMLBase';
+}
+use YAML::Marshall;
+
+sub yaml_dump {
+ my $self = shift;
+ my $array = [];
+ for my $k (sort keys %$self) {
+ push @$array, $k, $self->{$k};
+ }
+ $self->yaml_node($array, 'perl/Foo::Bar');
+}
+
+sub yaml_load {
+ my $class = shift;
+ my $node = shift;
+ my $self = $class->new;
+ %$self = @$node;
+ return $self;
+}
+
+#-------------------------------------------------------------------------------
+package Bar::Baz;
+BEGIN {
+ require TestYAMLBase;
+ @Bar::Baz::ISA = 'TestYAMLBase';
+}
+use YAML::Marshall 'random/object:bar.baz';
+
+#-------------------------------------------------------------------------------
+package Baz::Foo;
+BEGIN {
+ require TestYAMLBase;
+ @Bar::Foo::ISA = 'TestYAMLBase';
+}
+use YAML::Marshall;
+
+sub yaml_dump {
+ my $self = shift;
+ my $node = $self->SUPER::yaml_dump(@_);
+ $node->{comment} = "Hi, Mom";
+ return $node;
+}
+
+sub yaml_load {
+ my $class = shift;
+ my $node = $class->SUPER::yaml_load(@_);
+ delete $node->{comment};
+ return $node;
+}
+
+#-------------------------------------------------------------------------------
+package main;
+no_diff;
+run_roundtrip_nyn;
+
+is $main::BazFoo->{11}, 12,
+ 'first key exists';
+
+is $main::BazFoo->{13}, 14,
+ 'second key exists';
+
+ok not($main::BazFoo->{comment}),
+ 'extra key not added';
+
+__DATA__
+
+=== Serialize a hash object as a sequence
++++ perl
+my $fb = Foo::Bar->new;
+$fb->{x} = 5;
+$fb->{y} = 'che';
+[$fb];
++++ yaml
+---
+- !perl/Foo::Bar
+ - x
+ - 5
+ - y
+ - che
+
+
+=== Use a non-standard tag
++++ perl: bless {11 .. 14}, 'Bar::Baz';
++++ yaml
+--- !random/object:bar.baz
+11: 12
+13: 14
+
+
+=== super calls to mixins work
++++ perl: bless {11 .. 14}, 'Baz::Foo';
++++ yaml
+--- !perl/Baz::Foo
+11: 12
+13: 14
+comment: 'Hi, Mom'
+
+
+=== yaml_dump doesn't mutate original hash
++++ no_round_trip
++++ perl: $main::BazFoo = bless {11 .. 14}, 'Baz::Foo';
++++ yaml
+--- !perl/Baz::Foo
+11: 12
+13: 14
+comment: 'Hi, Mom'
+
+
diff --git a/t/node-info.t b/t/node-info.t
new file mode 100644
index 0000000..ab66d32
--- /dev/null
+++ b/t/node-info.t
@@ -0,0 +1,166 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 16;
+use YAML::Dumper;
+
+package StrIngy;
+use overload '""', sub { 'A Stringy String' };
+sub new {bless {}, shift}
+
+package main;
+my $object = bless {}, 'StrIngy';
+
+# $\ = "\n";
+# print ref($object);
+# print "$object";
+# print overload::StrVal($object);
+# print overload::StrVal(bless {}, 'foo');
+# exit;
+
+filters {
+ node => ['eval_perl' => 'get_info'],
+ info => ['lines' => 'make_regexp'],
+};
+
+run_like node => 'info';
+
+sub eval_perl {
+ my $perl = shift;
+ my $stringify = 0;
+ $stringify = 1 if $perl =~ s/^#\s*//;
+ my $node = eval $perl;
+ die "Perl code failed to eval:\n$perl\n$@" if $@;
+ return ($node, $stringify);
+}
+
+sub get_info {
+ my $dumper = YAML::Dumper->new;
+ join ';', map {
+ defined($_) ? $_ : 'undef'
+ } $dumper->node_info(@_);
+}
+
+sub make_regexp {
+ my $string = join ';', map {
+ chomp;
+ s/^~$/undef/;
+ s/^0x\d+/0x[0-9a-fA-F]+/;
+ $_;
+ } @_;
+ qr/^${string}$/;
+}
+
+__DATA__
+=== Hash Ref
++++ node: +{1..4};
++++ info
+~
+HASH
+0x12345678
+
+=== Array Ref
++++ node: [1..5]
++++ info
+~
+ARRAY
+0x12345678
+
+=== Scalar
++++ node: 'hello';
++++ info
+~
+~
+0x12345678-S
+
+=== Scalar Ref
++++ node: \ 'hello';
++++ info
+~
+SCALAR
+0x12345678
+
+=== Scalar Ref Ref
++++ node: \\ 'hello';
++++ info
+~
+REF
+0x12345678
+
+=== Code Ref
++++ node: sub { 42; }
++++ info
+~
+CODE
+0x12345678
+
+=== Code Ref Ref
++++ node: \ sub { 42; }
++++ info
+~
+REF
+0x12345678
+
+=== Glob
++++ node: $::x = 5; \ *x;
++++ info
+~
+GLOB
+0x12345678
+
+=== Regular Expression
++++ node: qr{xxx};
++++ info
+~
+REGEXP
+0x12345678
+
+=== Blessed Hash Ref
++++ node: bless {}, 'ARRAY';
++++ info
+ARRAY
+HASH
+0x12345678
+
+=== Blessed Array Ref
++++ node: bless [], 'Foo::Bar';
++++ info
+Foo::Bar
+ARRAY
+0x12345678
+
+=== Blessed Scalar Ref
++++ node: my $b = 'boomboom'; bless ((\ $b), 'Foo::Barge');
++++ info
+Foo::Barge
+SCALAR
+0x12345678
+
+=== Blessed Code Ref
++++ node: bless sub { 43 }, 'Foo::Barbie';
++++ info
+Foo::Barbie
+CODE
+0x12345678
+
+=== Blessed Glob
++++ node: $::x = 5; bless \ *x, 'Che';
++++ info
+Che
+GLOB
+0x12345678
+
+=== Not Stringified Hash Object
++++ node: bless {}, 'StrIngy';
++++ info
+StrIngy
+HASH
+0x12345678
+
+=== Stringified Hash Object
++++ node: # bless {}, 'StrIngy';
++++ info
+~
+~
+0x12345678-S
+
+
diff --git a/t/pugs-objects.t b/t/pugs-objects.t
new file mode 100644
index 0000000..e850b34
--- /dev/null
+++ b/t/pugs-objects.t
@@ -0,0 +1,20 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 2;
+
+{
+ no warnings 'once';
+ $Foo::Bar::ClassTag = '!pugs/object:Foo::Bar';
+ $YAML::TagClass->{'!pugs/object:Foo::Bar'} = 'Foo::Bar';
+}
+
+no_diff;
+run_roundtrip_nyn('dumper');
+
+__DATA__
+=== Turn Perl object to Pugs object
++++ perl: bless { 'a'..'d' }, 'Foo::Bar';
++++ yaml
+--- !!pugs/object:Foo::Bar
+a: b
+c: d
diff --git a/t/references.t b/t/references.t
new file mode 100644
index 0000000..13af48c
--- /dev/null
+++ b/t/references.t
@@ -0,0 +1,48 @@
+use lib 'inc';
+use Test::YAML tests => 10;
+
+no_diff;
+
+run_yaml_tests;
+
+__DATA__
+=== A scalar ref
++++ perl: \ 42
++++ yaml
+--- !!perl/ref
+=: 42
+
+=== A ref to a scalar ref
++++ perl: \\ "yellow"
++++ yaml
+--- !!perl/ref
+=: !!perl/ref
+ =: yellow
+
+=== A ref to a ref to a scalar ref
++++ perl: \\\ 123
++++ yaml
+--- !!perl/ref
+=: !!perl/ref
+ =: !!perl/ref
+ =: 123
+
+=== A blessed container reference
++++ perl
+my $array_ref = [ 1, 3, 5];
+my $container_ref = \ $array_ref;
+bless $container_ref, 'Wax';
++++ yaml
+--- !!perl/ref:Wax
+=:
+ - 1
+ - 3
+ - 5
+
+=== A blessed scalar reference
++++ perl
+my $scalar = "omg";
+my $scalar_ref = \ $scalar;
+bless $scalar_ref, 'Wax';
++++ yaml
+--- !!perl/scalar:Wax omg
diff --git a/t/regexp.t b/t/regexp.t
new file mode 100644
index 0000000..366321a
--- /dev/null
+++ b/t/regexp.t
@@ -0,0 +1,94 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 11;
+use YAML();
+no warnings 'once';
+
+my $m_xis = "m-xis";
+my $_xism = "-xism";
+if (qr/x/ =~ /\(\?\^/){
+ $m_xis = "^m";
+ $_xism = "^";
+}
+my @blocks = blocks;
+
+my $block = $blocks[0];
+
+$YAML::UseCode = 1;
+my $hash = YAML::Load($block->yaml);
+is $hash->{key}, "(?$m_xis:foo\$)", 'Regexps load';
+is YAML::Dump(eval $block->perl), <<"...", 'Regexps dump';
+---
+key: !!perl/regexp (?$m_xis:foo\$)
+...
+
+my $re = $hash->{key};
+
+is ref($re), 'Regexp', 'The regexp is a Regexp';
+
+like "Hello\nBarfoo", $re, 'The regexp works';
+
+#-------------------------------------------------------------------------------
+
+$block = $blocks[1];
+
+$hash = YAML::Load($block->yaml);
+is $hash->{key}, "(?$m_xis:foo\$)", 'Regexps load';
+
+# XXX Dumper can't detect a blessed regexp
+
+# is YAML::Dump(eval $block->perl), <<"...", 'Regexps dump';
+# ---
+# key: !!perl/regexp (?$m_xis:foo\$)
+# ...
+
+$re = $hash->{key};
+
+is ref($re), 'Classy', 'The regexp is a Classy :(';
+
+# XXX Test more doesn't think a blessed regexp is a regexp (for like)
+
+# like "Hello\nBarfoo", $re, 'The regexp works';
+ok(("Hello\nBarfoo" =~ $re), 'The regexp works');
+
+#-------------------------------------------------------------------------------
+
+$block = $blocks[2];
+
+$hash = YAML::Load($block->yaml);
+is $hash->{key}, "(?$_xism:foo\$)", 'Regexps load';
+
+is YAML::Dump(eval $block->perl), <<"...", 'Regexps dump';
+---
+key: !!perl/regexp (?$_xism:foo\$)
+...
+
+$re = $hash->{key};
+
+is ref($re), 'Regexp', 'The regexp is a Regexp';
+
+like "Barfoo", $re, 'The regexp works';
+
+
+__END__
+=== A regexp with flag
++++ yaml
+---
+key: !!perl/regexp (?m-xis:foo$)
++++ perl
++{key => qr/foo$/m}
+
+=== A blessed rexexp
++++ yaml
+---
+key: !!perl/regexp:Classy (?m-xis:foo$)
++++ perl
++{key => bless(qr/foo$/m, 'Classy')}
+
+=== A regexp with no flag
++++ yaml
+---
+key: !!perl/regexp (?-xism:foo$)
++++ perl
++{key => qr/foo$/}
+
diff --git a/t/release-pod-syntax.t b/t/release-pod-syntax.t
new file mode 100644
index 0000000..cdd6a6c
--- /dev/null
+++ b/t/release-pod-syntax.t
@@ -0,0 +1,14 @@
+#!perl
+
+BEGIN {
+ unless ($ENV{RELEASE_TESTING}) {
+ require Test::More;
+ Test::More::plan(skip_all => 'these tests are for release candidate testing');
+ }
+}
+
+# This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests.
+use Test::More;
+use Test::Pod 1.41;
+
+all_pod_files_ok();
diff --git a/t/rt-90593.t b/t/rt-90593.t
new file mode 100644
index 0000000..b030678
--- /dev/null
+++ b/t/rt-90593.t
@@ -0,0 +1,21 @@
+# https://rt.cpan.org/Public/Bug/Display.html?id=90593
+use Test::More;
+
+if ($] < 5.010000) {
+ plan skip_all => "Skip old perls";
+}
+else {
+ plan tests => 2;
+}
+
+use YAML;
+use constant LENGTH => 1000000;
+
+$SIG{__WARN__} = sub { die @_ };
+
+my $yaml = 'x: "' . ('x' x LENGTH) . '"' . "\n";
+
+my $hash = Load $yaml;
+
+is ref($hash), 'HASH', 'Loaded a hash';
+is length($hash->{x}), LENGTH, 'Long scalar loaded';
diff --git a/t/svk-config.yaml b/t/svk-config.yaml
new file mode 100644
index 0000000..dd35a5c
--- /dev/null
+++ b/t/svk-config.yaml
@@ -0,0 +1,320 @@
+---
+checkout: !perl/Data::Hierarchy
+ hash:
+ /home/jesse/README:
+ depotpath: //local/rt-3.4/README
+ encoding: ascii
+ revision: 17371
+ /home/jesse/foo:
+ depotpath: //local/foo
+ encoding: ascii
+ revision: 19501
+ /home/jesse/svk/1.0-releng:
+ depotpath: //mirror/svk/branches/1.0-releng/
+ encoding: ascii
+ revision: 20905
+ /home/jesse/svk/Acme-Net-OdiousPlan:
+ depotpath: //mirror//bps-public/Acme-Net-OdiousPlan/
+ encoding: ascii
+ revision: 13820
+ /home/jesse/svk/Business-Hours:
+ depotpath: //local/Business-Hours
+ encoding: iso-8859-1
+ revision: 17426
+ /home/jesse/svk/DBIx-DBSchema:
+ depotpath: //local/DBIx-DBSchema
+ encoding: utf-8-strict
+ revision: 19508
+ /home/jesse/svk/DBIx-SearchBuilder:
+ depotpath: //local/DBIx-SearchBuilder/
+ encoding: iso-8859-1
+ revision: 21870
+ /home/jesse/svk/Data-ICal:
+ depotpath: //local/Data-ICal
+ encoding: iso-8859-1
+ revision: 17222
+ /home/jesse/svk/Devel-ebug:
+ depotpath: //local/Devel-ebug/
+ encoding: ascii
+ revision: 15097
+ /home/jesse/svk/Devel-ebug-HTTP:
+ depotpath: //local/Devel-ebug-HTTP/
+ encoding: ascii
+ revision: 15099
+ /home/jesse/svk/HTTP-Server-Simple:
+ depotpath: //local/HTTP-Server-Simple/
+ encoding: iso-8859-1
+ revision: 18459
+ /home/jesse/svk/HTTP-Server-Simple-Mason:
+ depotpath: //local/HTTP-Server-Simple-Mason/
+ encoding: ascii
+ revision: 13726
+ /home/jesse/svk/HTTP-Server-Simple-Recorder:
+ depotpath: //local/HTTP-Server-Simple-Recorder
+ encoding: ascii
+ revision: 13245
+ /home/jesse/svk/Module-Install-RTx:
+ depotpath: //local/Module-Install-RTx/
+ encoding: ascii
+ revision: 19842
+ /home/jesse/svk/Module-Refresh:
+ depotpath: //local/Module-Refresh
+ encoding: iso-8859-1
+ revision: 20956
+ /home/jesse/svk/RT-Extension-ActivityReports:
+ depotpath: //local/RT-Extension-ActivityReports/
+ encoding: ascii
+ revision: 22084
+ /home/jesse/svk/RT-Extension-MergeUsers:
+ depotpath: //local/RT-Extension-MergeUsers/
+ encoding: ascii
+ revision: 18043
+ /home/jesse/svk/RT-Extension-Redacted:
+ depotpath: //local/RT-Extension-Redacted/
+ encoding: ascii
+ revision: 20453
+ /home/jesse/svk/RT-Integration-SVN:
+ depotpath: //local/RT-Integration-SVN/
+ encoding: iso-8859-1
+ revision: 4915
+ /home/jesse/svk/RT-KeyBindings:
+ depotpath: //local/RT-KeyBindings
+ encoding: ascii
+ revision: 15495
+ /home/jesse/svk/RT-OnlineDocs:
+ depotpath: //local/RT-OnlineDocs/
+ encoding: ascii
+ revision: 20473
+ /home/jesse/svk/RT-TicketWhiteboard:
+ depotpath: //local/RT-TicketWhiteboard/
+ encoding: utf-8-strict
+ revision: 20454
+ /home/jesse/svk/RT-Todo:
+ depotpath: //local/RT-Todo
+ encoding: iso-8859-1
+ revision: 7320
+ /home/jesse/svk/RT-View-Directory:
+ depotpath: //local/RT-View-Directory/
+ encoding: ascii
+ revision: 20455
+ /home/jesse/svk/RT-View-Tree:
+ depotpath: //local/RT-View-Tree/
+ encoding: iso-8859-1
+ revision: 4918
+ /home/jesse/svk/Test-HTTP-Server-Simple:
+ depotpath: //mirror/bps-public/Test-HTTP-Server-Simple/
+ encoding: ascii
+ revision: 7358
+ /home/jesse/svk/WWW-Mechanize-FromRecording:
+ depotpath: //mirror/bps-public/WWW-Mechanize-FromRecording/
+ encoding: ascii
+ revision: 15347
+ /home/jesse/svk/chaldea:
+ depotpath: //local/chaldea
+ encoding: ascii
+ revision: 19696
+ /home/jesse/svk/chaldea/html/Ticket/ModifyAll.html:
+ revision: 19797
+ /home/jesse/svk/clkao:
+ depotpath: //local/clkao
+ encoding: ascii
+ revision: 15496
+ /home/jesse/svk/customers:
+ depotpath: //local/customers
+ encoding: ascii
+ revision: 20447
+ /home/jesse/svk/hiveminder-trunk:
+ depotpath: //local/hiveminder-trunk/
+ encoding: ascii
+ revision: 21802
+ /home/jesse/svk/jifty.org:
+ depotpath: //local/jifty.org
+ encoding: ascii
+ revision: 22079
+ /home/jesse/svk/logo:
+ depotpath: //mirror/bps-private/docs/logo
+ encoding: ascii
+ revision: 7032
+ /home/jesse/svk/modinstal:
+ depotpath: //local/modinstal
+ encoding: ascii
+ revision: 20926
+ /home/jesse/svk/people:
+ depotpath: //local/people
+ encoding: ascii
+ revision: 7029
+ /home/jesse/svk/people/kevinr:
+ revision: 7633
+ /home/jesse/svk/perl6-doc:
+ depotpath: //local/perl6-doc/
+ encoding: iso-8859-1
+ revision: 17030
+ /home/jesse/svk/personal:
+ depotpath: //local/personal
+ encoding: ascii
+ revision: 13817
+ /home/jesse/svk/planetsix:
+ depotpath: //local/planetsix
+ encoding: ascii
+ revision: 21020
+ /home/jesse/svk/private-docs:
+ depotpath: //local/private-docs
+ encoding: ascii
+ revision: 18093
+ /home/jesse/svk/quebec:
+ depotpath: //local/quebec
+ encoding: ascii
+ revision: 19693
+ /home/jesse/svk/rt-3.0:
+ depotpath: //local/rt-3.0
+ encoding: iso-8859-1
+ revision: 18019
+ /home/jesse/svk/rt-3.2:
+ depotpath: //local/rt-3.2
+ encoding: iso-8859-1
+ revision: 17458
+ /home/jesse/svk/rt-3.4:
+ depotpath: //local/rt-3.4
+ encoding: iso-8859-1
+ revision: 20436
+ /home/jesse/svk/rt-3.5:
+ depotpath: //local/rt-3.5
+ encoding: iso-8859-1
+ revision: 20493
+ /home/jesse/svk/rt-book:
+ depotpath: //local/rt-book/
+ encoding: ascii
+ revision: 4893
+ /home/jesse/svk/rt.cpan.org:
+ depotpath: //local/rt.cpan.org
+ encoding: ascii
+ revision: 17911
+ /home/jesse/svk/rtfm-2.0:
+ depotpath: //local/rtfm-2.0
+ encoding: ascii
+ revision: 16160
+ /home/jesse/svk/rtfm-2.1:
+ depotpath: //local/rtfm-2.1
+ encoding: ascii
+ revision: 19705
+ /home/jesse/svk/rtir-1.0:
+ depotpath: //local/rtir-1.0
+ encoding: iso-8859-1
+ revision: 17456
+ /home/jesse/svk/svk-trunk:
+ depotpath: //local/svk-trunk
+ encoding: ascii
+ revision: 21697
+ /home/jesse/svk/svkbook:
+ depotpath: //local/svkbook-trunk
+ encoding: ascii
+ revision: 18587
+ /home/jesse/svk/training:
+ depotpath: //local/training
+ encoding: ascii
+ revision: 22081
+ /home/jesse/svk/trunk:
+ depotpath: //local/svk/trunk
+ encoding: ascii
+ revision: 0
+ /tmp/3.5-TESTING:
+ depotpath: //mirror/bps-public/rt/branches/3.5-TESTING/
+ encoding: ascii
+ revision: 19687
+ /tmp/gtd:
+ depotpath: //local/gtd
+ encoding: ascii
+ revision: 0
+ /tmp/hm/hiveminder-trunk:
+ depotpath: //local/hiveminder-trunk
+ encoding: ascii
+ revision: 15375
+ /tmp/svl-checkous/Acme-Colour:
+ depotpath: //_default_/acme/Acme-Colour
+ encoding: ascii
+ revision: 7268
+ /tmp/svlco/Acme-Colour:
+ depotpath: //_default_/acme/Acme-Colour
+ encoding: ascii
+ revision: 7268
+ /tmp/trunk:
+ depotpath: //mirror/bps-private/hiveminder/trunk
+ encoding: utf-8-strict
+ revision: 19754
+ sep: /
+ sticky:
+ /home/jesse/svk/1.0-releng/lib/SVK/Target.pm:
+ .newprop: {}
+ /home/jesse/svk/hiveminder-trunk/Jifty:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/Makefile:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/Makefile.old:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/blib:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/doc:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/doc/session:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/inc:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/jifty:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/lib:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/lib/Jifty:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/lib/Jifty/DefaultApp:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/lib/Jifty/Manual:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/lib/Jifty/Manual/ObjectModel.pod:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/pm_to_blib:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/t:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/t/Continuations:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/t/Continuations/Makefile.old:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/t/Continuations/continuations:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/t/Continuations/continuationstest:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/t/Continuations/inc:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/t/Mapper:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/t/Mapper/mapper:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/t/Mapper/mappertest:
+ .conflict: 1
+ /home/jesse/svk/hiveminder-trunk/Jifty/t/utils.pl:
+ .conflict: 1
+ /home/jesse/svk/jifty.org:
+ .newprop:
+ svk:merge: e84bef0a-9b06-0410-84ba-c4c9edb13aeb:/:428
+ .schedule: prop
+ /home/jesse/svk/rt.cpan.org/rt2-existing/local/WebRT/html/NoAuth/bugs.tsv:
+ .newprop:
+ svn:executable: '*'
+ .schedule: add
+ /home/jesse/svk/training:
+ .newprop:
+ svk:merge: |-
+ 6641d27c-1bcc-0310-8a77-bef5c512aa61:/training:1585
+ a51291e0-c2ea-0310-847b-fbb8d8170edb:/local/training:5752
+ .schedule: prop
+ /home/jesse/svk/training/developer_training:
+ .newprop:
+ svk:merge: |-
+ 5f29b386-91d9-0310-ba9f-d3bca794479a:/rttraining/local:1354
+ 5f29b386-91d9-0310-ba9f-d3bca794479a:/rttraining/local-merge-9322:1032
+ 5f88e03f-dcfa-0310-a525-a1f853655784:/rt-developer-training:1586
+ 8d5e1d6e-e2eb-0310-9379-fb19c180b7be:/dev_training-local:1241
+ .schedule: prop
+depotmap:
+ '': /home/jesse/.svk/local
+ parrot: /home/jesse/.svk/parrot
diff --git a/t/svk.t b/t/svk.t
new file mode 100644
index 0000000..d859ebc
--- /dev/null
+++ b/t/svk.t
@@ -0,0 +1,20 @@
+use strict;
+my $t; use lib ($t = -e 't' ? 't' : 'test');
+use TestYAML tests => 3;
+
+my $test_file = "$t/svk-config.yaml";
+my $node = LoadFile($test_file);
+
+is ref($node), 'HASH',
+ "loaded svk file is a hash";
+
+open IN, $test_file or die "Can't open $test_file for input: $!";
+my $yaml_from_file = do {local $/; <IN>};
+
+like $yaml_from_file, qr{^---\ncheckout: !perl/Data::Hierarchy\n},
+ "at least first two lines of file are right";
+
+my $yaml_from_node = Dump($node);
+
+is Dump(Load($yaml_from_node)), Dump(Load($yaml_from_file)),
+ "svk data roundtrips!";;
diff --git a/t/test.t b/t/test.t
new file mode 100644
index 0000000..7c33fb2
--- /dev/null
+++ b/t/test.t
@@ -0,0 +1,5 @@
+use strict;
+use lib -e 't' ? 't' : 'test';
+use TestYAML tests => 1;
+
+pass('TestYAML framework loads');