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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
use strict;
use warnings;
use lib 't/lib';
use Test::More;
use Parent;
use Child;
use Grandchild;
use I::Parent;
use I::Child;
use I::Grandchild;
use NoData;
use NoName;
use Relaxed;
use Header;
use End;
use WindowsNewlines;
my @want = (
Parent => { a => \"1\n", b => \"2\n", c => \"3\n" },
Child => { b => \"22\n", c => \"33\n", d => \"44\n" },
Grandchild => { a => \"111\n", d => \q{} },
);
for (my $i = 0; $i < @want; $i += 2) {
my $inv = $want[ $i ];
for my $prefix ('', 'I::') {
my $inv = "$prefix$inv";
is_deeply(
$inv->local_section_data,
$want[ $i + 1 ],
"$inv->local_section_data",
);
}
is_deeply(
$inv->merged_section_data,
$want[ $i + 1 ],
"$inv->merged_section_data",
);
}
# The classes that do not begin with I:: are non-inheriting, so we do not
# expect to see (for example) the parent's "b" section propagated to the
# grandchild. -- rjbs, 2010-01-27
is_deeply(Parent ->section_data('a'), \"1\n", "Parent's a");
is_deeply(Parent ->section_data('b'), \"2\n", "Parent's b");
is_deeply(Grandchild->section_data('a'), \"111\n", "Grandchild's a");
is_deeply(Grandchild->section_data('b'), undef, "Grandchild's b (none)");
is_deeply(
[ sort Parent->section_data_names ],
[ qw(a b c) ],
"Parent section data names",
);
is_deeply(
[ sort Parent->local_section_data_names ],
[ qw(a b c) ],
"Parent local section data names",
);
is_deeply(
[ sort Parent->merged_section_data_names ],
[ qw(a b c) ],
"Parent merged section data names",
);
is_deeply(
[ sort Child->section_data_names ],
[ qw(b c d) ],
"Child section data names",
);
is_deeply(
[ sort Child->local_section_data_names ],
[ qw(b c d) ],
"Child local section data names",
);
is_deeply(
[ sort Child->merged_section_data_names ],
[ qw(b c d) ],
"Child merged section data names",
);
is_deeply(I::Parent ->section_data('a'), \"1\n", "I::Parent's a");
is_deeply(I::Parent ->section_data('b'), \"2\n", "I::Parent's b");
is_deeply(I::Grandchild->section_data('a'), \"111\n", "I::Grandchild's a");
is_deeply(I::Grandchild->section_data('b'), \"22\n", "I::Grandchild's b (via Child)");
is_deeply(
[ sort I::Parent->section_data_names ],
[ qw(a b c) ],
"I::Parent section data names",
);
is_deeply(
[ sort I::Parent->local_section_data_names ],
[ qw(a b c) ],
"I::Parent local section data names",
);
is_deeply(
[ sort I::Parent->merged_section_data_names ],
[ qw(a b c) ],
"I::Parent merged section data names",
);
is_deeply(
[ sort I::Child->section_data_names ],
[ qw(a b c d) ],
"I::Child merged section data names",
);
is_deeply(
[ sort I::Child->local_section_data_names ],
[ qw(b c d) ],
"I::Child local section data names",
);
is_deeply(
[ sort I::Child->merged_section_data_names ],
[ qw(a b c d) ],
"I::Child merged section data names",
);
is_deeply(
I::Grandchild->merged_section_data,
{ a => \"111\n", b => \"22\n", c => \"33\n", d => \q{}, },
"I::Grandchild->merged_section_data",
);
is_deeply(NoData->local_section_data, {}, "nothing found in NoData");
is_deeply(
NoName->local_section_data,
{ a => \"1\n", b => \"2\n" },
"default name in NoName",
);
is_deeply(
Relaxed->local_section_data,
{ a => \"1\n", b => \"2\n" },
"allows empty lines before the first section.",
);
is_deeply(
Header->local_section_data,
{ a => \"1\n", b => \"2\n" },
"test header_re",
);
is_deeply(
End->local_section_data,
{ a => \"1\n", b => \"2\n" },
"ignore __END__",
);
my $crlf = $^O eq 'MSWin32' ? "\n" : "\r\n";
is_deeply(
WindowsNewlines->local_section_data,
{ n => \"foo$crlf" },
"windows newlines work",
);
done_testing;
|