App-Followme
view release on metacpan or search on metacpan
t/Initialize.t view on Meta::CPAN
do {
my $line = "#>>> copy text common followme.cfg";
my $is = App::Followme::Initialize::is_command($line);
is($is, " copy text common followme.cfg", "is command line"); # test 1
$line = "run_before = App::Followme::FormatPage";
$is = App::Followme::Initialize::is_command($line);
is($is, undef, "is not command line"); # test 2
};
#----------------------------------------------------------------------
# Test write_file
do {
my $text = <<EOQ;
Copyright 2015 by Bernie Simon
This file is licensed under thesame terms as Perl itself.
EOQ
my @ok_lines = map {"$_\n"} split("\n", $text);
my $type = 'text';
my $file = catfile($test_dir, 'license.txt');
App::Followme::Initialize::write_file(\@ok_lines, $type, $file);
my $page = fio_read_page($file);
my @lines = map {"$_\n"} split("\n", $text);
is_deeply(\@lines, \@ok_lines, "write text file"); # test 3
$text = <<'EOQ';
# modules
run_before:
- App::Followme::FormatPage
- App::Followme::ConvertPage
# test data
one: 1
two: 2
three: 3
four: 4
EOQ
@ok_lines = map {"$_\n"} split("\n", $text);
$type = 'configuration';
$file = catfile($test_dir, 'followme.cfg');
App::Followme::Initialize::write_file(\@ok_lines, $type, $file);
my $page = fio_read_page($file);
@lines = map {"$_\n"} split("\n", $text);
is_deeply(\@lines, \@ok_lines, "write configuration file"); # test 4
App::Followme::Initialize::write_file(\@ok_lines, $type, $file);
$page = fio_read_page($file);
@lines = map {"$_\n"} split("\n", $text);
is_deeply(\@lines, \@ok_lines, "rewrite configuration file"); # test 5
$text = <<'EOQ';
R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
EOQ
my @lines = map {"$_\n"} split("\n", $text);
$type = 'binary';
$file = catfile($test_dir, 'transparent.gif');
App::Followme::Initialize::write_file(\@lines, $type, $file);
ok(-e $file, 'write binary file'); # test 6
};
( run in 1.924 second using v1.01-cache-2.11-cpan-39bf76dae61 )