Split on newline done in module
[Data-Peek.git] / t / 10_DDumper.t
blobc7d36d25d8c8fe2af32e8f862d32dbdf09addccd
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 use Test::More tests => 42;
8 BEGIN {
9 use_ok "Data::Peek";
10 die "Cannot load Data::Peek\n" if $@; # BAIL_OUT not avail in old Test::More
13 my ($dump, $var) = ("", "");
14 while (<DATA>) {
15 chomp;
16 my ($v, $exp, $re) = split m/\t+ */;
18 if ($v eq "--") {
19 ok (1, "** $exp");
20 next;
23 unless ($v eq "") {
24 eval "\$var = $v";
25 ok ($dump = DDumper ($var), "DDumper ($v)");
26 $dump =~ s/\A\$VAR1 = //;
27 $dump =~ s/;\n\Z//;
29 if ($re) {
30 like ($dump, qr{$exp}m, ".. content $re");
31 $1 and print STDERR "# '$1' (", length ($1), ")\n";
33 else {
34 is ($dump, $exp, ".. content");
40 __END__
41 -- Basic values
42 undef undef
43 1 1
44 "" ''
45 "\xa8" '¨'
46 1.24 '1.24'
47 \undef \undef
48 \1 \1
49 \"" \''
50 \"\xa8" \'¨'
51 (0, 1) 1
52 \(0, 1) \1
53 -- Structures
54 [0, 1] ^\[\n line 1
55 ^ 0,\n line 2
56 ^ 1\n line 3
57 ^ ]\Z line 4
58 [0,1,2] \A\[\n\s+0,\n\s+1,\n\s+2\n\s+]\Z line splitting
59 -- Indentation
60 [0] \A\[\n 0\n ]\Z single indent
61 [[0],{foo=>1}] ^\[\n outer list
62 ^ {4}\[\n {8}0\n {8}],\n {4} inner list
63 ^ {4}\{\n {8}foo {14}=> 1\n {8}}\n inner hash
64 ^ {4}]\Z outer list end
65 [[0],{foo=>1}] \A\[\n {4}\[\n {8}0\n {8}],\n {4}\{\n {8}foo {14}=> 1\n {8}}\n {4}]\Z full struct