| 1 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | package File::TreeBuilder_T; | ||
| 4 | 1 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | $File::TreeBuilder_T::VERSION = '0.02'; | |
| 6 | } | ||
| 7 | # ABSTRACT: Test the File::TreeBuilder module. | ||
| 8 | |||
| 9 | # -------------------------------------------------------------------- | ||
| 10 | 1 | ▶ | use Test::Usage; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 1 | ▶ | use File::TreeBuilder qw(build_tree); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 1 | ▶ | use File::Temp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | # -------------------------------------------------------------------- | ||
| 15 | 3 | ▶ | sub exp_file { |
|
Subroutine
exp_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 16 | 3 | my ($file) = @_; | |
| 17 | 3 | ok( | |
| 18 | -f $file, | ||
| 19 | "Expected file '$file' to exist,", | ||
| 20 | "But it didn't." | ||
| 21 | ); | ||
| 22 | } | ||
| 23 | |||
| 24 | # -------------------------------------------------------------------- | ||
| 25 | 6 | ▶ | sub exp_dir { |
|
Subroutine
exp_dir: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 26 | 6 | my ($dir) = @_; | |
| 27 | 6 | ok( | |
| 28 | -d $dir, | ||
| 29 | "Expected directory '$dir' to exist,", | ||
| 30 | "But it didn't." | ||
| 31 | ); | ||
| 32 | } | ||
| 33 | |||
| 34 | # -------------------------------------------------------------------- | ||
| 35 | 5 | ▶ | sub exp_result { |
|
Subroutine
exp_result: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 36 | 5 | my ($exp_result, $got_result) = @_; | |
| 37 | 5 | ok( | |
| 38 | scalar($got_result =~ /\Q$exp_result/), | ||
| 39 | "Expected result '$exp_result',", | ||
| 40 | "But got '$got_result'." | ||
| 41 | ); | ||
| 42 | } | ||
| 43 | |||
| 44 | # -------------------------------------------------------------------- | ||
| 45 | 1 | ▶ | example('e1', sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 46 | 1 | exp_result("Directory not defined", build_tree()); | |
| 47 | 1 | }); | |
| 48 | |||
| 49 | # -------------------------------------------------------------------- | ||
| 50 | 1 | ▶ | example('a1', sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 51 | 1 | my $dir = File::Temp->newdir(); | |
| 52 | 1 | exp_dir($dir); | |
| 53 | # An empty template should succeed, doing nothing. | ||
| 54 | 1 | exp_result("", build_tree($dir)); | |
| 55 | 1 | }); | |
| 56 | |||
| 57 | # -------------------------------------------------------------------- | ||
| 58 | 1 | ▶ | example('a2', sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 59 | 1 | my $dir = File::Temp->newdir(); | |
| 60 | 1 | exp_result("", build_tree($dir, << "EOT")); | |
| 61 | / 'foo' | ||
| 62 | . 'bar' | ||
| 63 | EOT | ||
| 64 | 1 | exp_dir($dir); | |
| 65 | 1 | exp_dir("$dir/foo"); | |
| 66 | 1 | exp_file("$dir/foo/bar"); | |
| 67 | 1 | }); | |
| 68 | |||
| 69 | # -------------------------------------------------------------------- | ||
| 70 | 1 | ▶ | example('a3', sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 71 | 1 | my $dir = File::Temp->newdir(); | |
| 72 | 1 | exp_result("", build_tree($dir, << 'EOT')); | |
| 73 | / "foo qux" | ||
| 74 | . "bar baz" | ||
| 75 | / "foo ' qux" | ||
| 76 | . "bar' baz", "moo" | ||
| 77 | EOT | ||
| 78 | 1 | exp_dir($dir); | |
| 79 | 1 | exp_dir("$dir/foo qux"); | |
| 80 | 1 | exp_file("$dir/foo qux/bar baz"); | |
| 81 | 1 | exp_dir(qq{$dir/foo ' qux}); | |
| 82 | 1 | exp_file(qq{$dir/foo ' qux/bar' baz}); | |
| 83 | 1 | }); | |
| 84 | |||
| 85 | # -------------------------------------------------------------------- | ||
| 86 | 1 | ▶ | example('a4', sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 87 | 1 | my $dir = File::Temp->newdir(); | |
| 88 | 1 | our $bad_filename = 'moo' x 100; | |
| 89 | 1 | exp_result("Couldn't open", build_tree($dir, << 'EOT')); | |
| 90 | . $bad_filename | ||
| 91 | EOT | ||
| 92 | 1 | }); | |
| 93 | |||
| 94 | # -------------------------------------------------------------------- | ||
| 95 | 1 | 1; | |
| 96 | |||
| 97 | __END__ | ||