-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
import Template::Patch 0.02 from CPAN
git-cpan-module: Template::Patch git-cpan-version: 0.02
- Loading branch information
1 parent
9a0ad8e
commit c78bb72
Showing
4 changed files
with
64 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
Revision history for Template-Patch | ||
|
||
0.02 2006-03-23 | ||
* If the IN template fails to match, don't clobber the output with | ||
a measly version of the OUT template and nothing else. Instead, | ||
passthrough the input cleanly. | ||
* `metapatch --version`. | ||
|
||
0.01 2006-03-20 | ||
First version, released on an unsuspecting world. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,60 @@ | ||
#!perl -T | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use File::Spec; | ||
use Test::Exception; | ||
|
||
use Test::More tests => 7; | ||
use Test::More tests => 9; | ||
|
||
our $FS = "File::Spec"; | ||
|
||
BEGIN { | ||
use_ok( 'Template::Patch' ); | ||
} | ||
|
||
diag( "Testing Template::Patch $Template::Patch::VERSION, Perl $], $^X" ); | ||
|
||
dies_ok { Template::Patch->new_from_file("no_such_file") } | ||
"can't read from metapatch file that doesn't exist"; | ||
|
||
my $tp; | ||
{ | ||
my $tp; | ||
|
||
lives_ok { $tp = Template::Patch->new_from_file($FS->catfile(qw/t basic1.mp/)); } | ||
"construct patch object with .mp file"; | ||
lives_ok { $tp = Template::Patch->new_from_file($FS->catfile(qw/t basic1.mp/)); } | ||
"construct patch object with .mp file"; | ||
|
||
isa_ok $tp, "Template::Patch", "has correct type"; | ||
isa_ok $tp, "Template::Patch", "has correct type"; | ||
|
||
my $doc = <<'.'; | ||
my $doc = <<'.'; | ||
I went to the doctor and guess what he told me. | ||
Say AAAHHH! | ||
. | ||
|
||
lives_ok { $tp->extract($doc) } "patch extraction lives"; | ||
lives_ok { $tp->extract($doc) } "patch extraction lives"; | ||
lives_ok { $tp->patch($doc) } "patch application lives"; | ||
|
||
(my $expected = $doc) =~ s/AAA/BBB/; | ||
|
||
is ${$tp->routput}, $expected, "patch applied correctly"; | ||
} | ||
|
||
|
||
lives_ok { $tp->patch($doc) } "patch application lives"; | ||
{ | ||
my $tp = Template::Patch->new_from_file($FS->catfile(qw/t basic1.mp/)); | ||
isa_ok $tp, "Template::Patch", "has correct type - 2"; | ||
|
||
(my $expected = $doc) =~ s/AAA/BBB/; | ||
my $doc = my $expected = <<'.'; | ||
This document contains no triple As. | ||
The patch application should not change anything in it. | ||
. | ||
|
||
$tp->extract($doc); | ||
$tp->patch($doc); | ||
|
||
is ${$tp->routput}, $expected, "patch applied correctly (did not ruin original)"; | ||
} | ||
|
||
is $tp->output, $expected, "patch applied correctly"; | ||
|
||
# vim: ts=4 et : | ||
# vim: ts=4 et ft=perl : |