1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
use FindBin '$Bin';
use lib $Bin;
use TestYAMLTests tests => 11;
run {
my $block = shift;
my @values = eval $block->perl;
is Dump(@values), $block->yaml, "Dump - " . $block->name
unless $block->SKIP_DUMP;
is_deeply [Load($block->yaml)], \@values, "Load - " . $block->name;
};
my @warn;
$SIG{__WARN__} = sub { push(@warn, shift) };
my $z = YAML::XS::Load(<<EOY);
---
foo:
- url: &1
scheme: http
EOY
pop @{$z->{foo}};
is_deeply \@warn, [], "No free of unref warnings";
__DATA__
=== Simple scalar ref
+++ perl
\ 42;
+++ yaml
--- !!perl/ref
=: 42
=== Ref to scalar ref
+++ perl
\\ "foo bar";
+++ yaml
--- !!perl/ref
=: !!perl/ref
=: foo bar
=== Scalar refs an aliases
+++ perl
my $x = \\ 3.1415;
[$x, $$x];
+++ yaml
---
- !!perl/ref
=: &1 !!perl/ref
=: 3.1415
- *1
=== Ref to undef
+++ perl
my $x = {foo => \undef};
+++ yaml
---
foo: !!perl/ref
=: ~
=== Circular ref to scalar
+++ perl
my $x;
$x = \$x;
+++ yaml
--- &1 !!perl/ref
=: *1
|