Algorithm-Diff-HTMLTable

 view release on metacpan or  search on metacpan

t/01_base.t  view on Meta::CPAN

use Test::LongString;
use File::Basename;
use File::Spec;
use Algorithm::Diff::HTMLTable;

my @files = map{ File::Spec->catfile( dirname( __FILE__ ), 'files', "01_$_.txt" ) }qw/a b/;

my $diff = Algorithm::Diff::HTMLTable->new;
my $html = $diff->diff( @files );

my $check = do{ local $/; <DATA> };
chomp $check;

$check =~ s{__files0__}{$files[0]};
$check =~ s{__files1__}{$files[1]};

$check =~ s{\\}{\\\\}g;

like_string( $html, qr/$check/ );

#diag $html;

done_testing();

__DATA__

        <table  style="border: 1px solid;">
            <thead>
                <tr>
                    <th colspan="2"><span id="diff_old_info">__files0__<br />.{24}</span></th>
                    <th colspan="2"><span id="diff_new_info">__files1__<br />.{24}</span></th>
                </tr>
            </thead>
            <tbody>
    

t/02_id.t  view on Meta::CPAN

use Test::LongString;
use File::Basename;
use File::Spec;
use Algorithm::Diff::HTMLTable;

my @files = map{ File::Spec->catfile( dirname( __FILE__ ), 'files', "01_$_.txt" ) }qw/a b/;

my $diff = Algorithm::Diff::HTMLTable->new( id => 'test_id' );
my $html = $diff->diff( @files );

my $check = do{ local $/; <DATA> };
chomp $check;

$check =~ s{__files0__}{$files[0]};
$check =~ s{__files1__}{$files[1]};

$check =~ s{\\}{\\\\}g;

like_string( $html, qr/$check/ );

#diag $html;

done_testing();

__DATA__

        <table id="test_id" style="border: 1px solid;">
            <thead>
                <tr>
                    <th colspan="2"><span id="diff_old_info">__files0__<br />.{24}</span></th>
                    <th colspan="2"><span id="diff_new_info">__files1__<br />.{24}</span></th>
                </tr>
            </thead>
            <tbody>
    

t/03_encoding.t  view on Meta::CPAN

use Test::LongString;
use File::Basename;
use File::Spec;
use Algorithm::Diff::HTMLTable;

my @files = map{ File::Spec->catfile( dirname( __FILE__ ), 'files', "03_iso8859_1_$_.txt" ) }qw/a b/;

my $diff = Algorithm::Diff::HTMLTable->new( id => 'test_id', encoding => 'iso-8859-1' );
my $html = $diff->diff( @files );

my $check = do{ local $/; <DATA> };
chomp $check;

$check =~ s{__files0__}{$files[0]};
$check =~ s{__files1__}{$files[1]};

$check =~ s{\\}{\\\\}g;

like_string( $html, qr/$check/ );
#is_string( $html, $check );

#diag $html;

done_testing();

__DATA__

        <table id="test_id" style="border: 1px solid;">
            <thead>
                <tr>
                    <th colspan="2"><span id="diff_old_info">__files0__<br />.{24}</span></th>
                    <th colspan="2"><span id="diff_new_info">__files1__<br />.{24}</span></th>
                </tr>
            </thead>
            <tbody>
    

t/04_eol.t  view on Meta::CPAN

use Test::LongString;
use File::Basename;
use File::Spec;
use Algorithm::Diff::HTMLTable;

my @files = map{ File::Spec->catfile( dirname( __FILE__ ), 'files', "04_$_.txt" ) }qw/a b/;

my $diff = Algorithm::Diff::HTMLTable->new( id => 'test_id', eol => "---\n" );
my $html = $diff->diff( @files );

my $check = do{ local $/; <DATA> };
chomp $check;

$check =~ s{__files0__}{$files[0]};
$check =~ s{__files1__}{$files[1]};

$check =~ s{\\}{\\\\}g;

like_string( $html, qr/$check/ );

#diag $html;

done_testing();

__DATA__

        <table id="test_id" style="border: 1px solid;">
            <thead>
                <tr>
                    <th colspan="2"><span id="diff_old_info">__files0__<br />.{24}</span></th>
                    <th colspan="2"><span id="diff_new_info">__files1__<br />.{24}</span></th>
                </tr>
            </thead>
            <tbody>
    

t/05_arrayrefs.t  view on Meta::CPAN

use Test::LongString;
use File::Basename;
use File::Spec;
use Algorithm::Diff::HTMLTable;

my @files = map{ [ read_file( File::Spec->catfile( dirname( __FILE__ ), 'files', "01_$_.txt" ) ) ] }qw/a b/;

my $diff = Algorithm::Diff::HTMLTable->new();
my $html = $diff->diff( @files );

my $check = do{ local $/; <DATA> };
chomp $check;

#like_string( $html, qr/$check/ );
is_string( $html, $check );

#diag $html;

done_testing();

sub read_file {
    my ($file) = @_;

    my @lines;
    if ( open my $fh, '<', $file ) {
        @lines = <$fh>;
    }

    @lines;
}

__DATA__

        <table  style="border: 1px solid;">
            <thead>
                <tr>
                    <th colspan="2"><span id="diff_old_info"></span></th>
                    <th colspan="2"><span id="diff_new_info"></span></th>
                </tr>
            </thead>
            <tbody>
    

t/06_title.t  view on Meta::CPAN

use Test::LongString;
use File::Basename;
use File::Spec;
use Algorithm::Diff::HTMLTable;

my @files = map{ [ read_file( File::Spec->catfile( dirname( __FILE__ ), 'files', "01_$_.txt" ) ) ] }qw/a b/;

my $diff = Algorithm::Diff::HTMLTable->new( title_old => '01_a.txt', title_new => '01_b.txt' );
my $html = $diff->diff( @files );

my $check = do{ local $/; <DATA> };
chomp $check;

#like_string( $html, qr/$check/ );
is_string( $html, $check );

#diag $html;

done_testing();

sub read_file {
    my ($file) = @_;

    my @lines;
    if ( open my $fh, '<', $file ) {
        @lines = <$fh>;
    }

    @lines;
}

__DATA__

        <table  style="border: 1px solid;">
            <thead>
                <tr>
                    <th colspan="2"><span id="diff_old_info">01_a.txt</span></th>
                    <th colspan="2"><span id="diff_new_info">01_b.txt</span></th>
                </tr>
            </thead>
            <tbody>
    

t/07_html.t  view on Meta::CPAN

use Test::LongString;
use File::Basename;
use File::Spec;
use Algorithm::Diff::HTMLTable;

my @files = map{ File::Spec->catfile( dirname( __FILE__ ), 'files', "07_$_.txt" ) }qw/a b/;

my $diff = Algorithm::Diff::HTMLTable->new;
my $html = $diff->diff( @files );

my $check = do{ local $/; <DATA> };
chomp $check;

$check =~ s{__files0__}{$files[0]};
$check =~ s{__files1__}{$files[1]};

$check =~ s{\\}{\\\\}g;

like_string( $html, qr/$check/ );

#diag $html;

done_testing();

__DATA__

        <table  style="border: 1px solid;">
            <thead>
                <tr>
                    <th colspan="2"><span id="diff_old_info">__files0__<br />.{24}</span></th>
                    <th colspan="2"><span id="diff_new_info">__files1__<br />.{24}</span></th>
                </tr>
            </thead>
            <tbody>
    



( run in 0.674 second using v1.01-cache-2.11-cpan-140bd7fdf52 )