versions
[Data-Peek.git] / t / 11_DDumper.t
blobd47a6aef9379ed50e1e60e987c7bd00a26ac460c
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");
49 unlink "perltidy.LOG", "perltidy.ERR";
53 __END__
54 -- Basic values
55 undef undef
56 1 1
57 "" ''
58 "\xa8" '¨'
59 1.24 '1.24'
60 \undef \undef
61 \1 \1
62 \"" \''
63 \"\xa8" \'¨'
64 (0, 1) 1
65 \(0, 1) \1
66 -- Structures
67 [0] \A\[\s*0\s*]\s*\Z tidy array 1
68 [0, 1] \A\[\s*0\s*,\s*1\s*]\s*\Z tidy array 2
69 [0,1,2] \A\[\s*0\s*,\s*1\s*,\s*2\s*]\s*\Z tidy array 3
70 [[0],{foo=>1}] \A\[\s*\[\s*0\s*]\s*,\s*\{\s*'foo'\s*=>\s*1\s*}\s*]\s*\Z structure