Update META checker
[Data-Peek.git] / t / 11_DDumper.t
blob9110f6b2b692e7cc0a4f01242fc5271203db96cd
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 my $ntests;
7 BEGIN { $ntests = 33 };
9 use Test::More tests => $ntests;
10 #se Test::NoWarnings;
12 BEGIN {
13 eval q{use Perl::Tidy};
14 if ($@) {
15 diag "Perl::Tidy not available";
16 ok (1) for 1..$ntests;
17 exit 0;
19 use_ok ("Data::Peek", ":tidy");
20 die "Cannot load Data::Peek\n" if $@;
23 my ($dump, $var) = ("", "");
24 while (<DATA>) {
25 chomp;
26 my ($v, $exp, $re) = split m/\t+ */;
28 if ($v eq "--") {
29 ok (1, "** $exp");
30 next;
33 $v =~ s/^S:([^:]*):// and DDsort ($1), $v =~ m/^()/; # And reset $1 for below
35 unless ($v eq "") {
36 eval "\$var = $v";
37 ok ($dump = DDumper ($var), "DDumper ($v)");
38 $dump =~ s/\A\$VAR1 = //;
39 $dump =~ s/;?\n\Z//;
41 if ($re) {
42 like ($dump, qr{$exp}ms, ".. content $re");
43 $1 and diag "# '$1' (", length ($1), ")\n";
45 else {
46 is ($dump, $exp, ".. content");
52 __END__
53 -- Basic values
54 undef undef
55 1 1
56 "" ''
57 "\xa8" '¨'
58 1.24 '1.24'
59 \undef \undef
60 \1 \1
61 \"" \''
62 \"\xa8" \'¨'
63 (0, 1) 1
64 \(0, 1) \1
65 -- Structures
66 [0] \A\[\s*0\s*]\s*\Z tidy array 1
67 [0, 1] \A\[\s*0\s*,\s*1\s*]\s*\Z tidy array 2
68 [0,1,2] \A\[\s*0\s*,\s*1\s*,\s*2\s*]\s*\Z tidy array 3
69 [[0],{foo=>1}] \A\[\s*\[\s*0\s*]\s*,\s*\{\s*'foo'\s*=>\s*1\s*}\s*]\s*\Z structure