< this is an unkown html tag />
Anne Condon, University of Wisconsin
Faith Fich, University of Toronto
Greg N. Frederickson, Purdue University
Andrew V. Goldberg, NEC Research Institute
David S. Johnson, AT&T Bell Laboratories
Michael C. Loui, University of Illinois at Urbana-Champaign
Steven Mahaney, DIMACS
Prabhakar Raghavan, IBM Almaden Research Center
John Savage, Brown University
Alan Selman, SUNY at Buffalo
David B. Shmoys, Cornell University
Abstract. This report focuses on two core areas of theory of computing: discrete algorithms and computational complexity theory. The report reviews the purposes and goals of theoretical research, summarizes selected past and recent achievements, explains the importance of sustaining core research, and identifies promising opportunities for future research. Some research opportunities build bridges between theory of computing and other areas of computer science, and other science and engineering disciplines.
'; my $test_html_b = '
Anne Condon, University of Wisconsin
Faith Fich, University of Toronto
Greg N. Frederickson, Purdue University
Andrew V. Goldberg, NEC Research Institute
David S. Johnson, AT&T Bell Laboratories
Michael C. Loui, University of Illinois at Urbana-Champaign
Steven Mahaney, DIMACS
Prabhakar Raghavan, IBM Almaden Research Center
John Savage, Brown University
Alan Selman, SUNY at Buffalo
David B. Shmoys, Cornell University
Abstract. This report focuses on two core areas of theory of computing: discrete algorithms and computational complexity theory. The report reviews the purposes and goals of theoretical research, summarizes selected past and recent achievements, explains the importance of sustaining core research, and identifies promising opportunities for future research. Some research opportunities build bridges between theory of computing and other areas of computer science, and other science and engineering disciplines.
';
sub print_diff {
my $ch;
my ($chunks) = @_;
foreach $ch (@$chunks) {
my ($flag, $m, $o) = @$ch;
unless ($flag eq 'u') {
print "<< old\n";
print "$o";
print ">> new\n";
print "$m";
print "==\n";
# TBD: make some kind of warning about lacking a newline at the end
} else {
print "$m";
}
}
}
sub test_diff_continuity {
my ($a, $b, $diffalgo, $ignore_whitespace) = @_;
my $chunks = &$diffalgo($a, $b);
my ($runningb, $runninga);
$runninga = $runningb = "";
my $ch;
foreach $ch (@$chunks)
{
my ($flag, $ach, $bch) = @$ch;
$runninga .= $ach || '';
$runningb .= $bch || '';
}
if ($ignore_whitespace) {
$a =~ s/\s\s+/ /g;
$b =~ s/\s\s+/ /g;
$runninga =~ s/\s\s+/ /g;
$runningb =~ s/\s\s+/ /g;
}
return ($a eq $runninga) && ($b eq $runningb);
}
sub expect_diff {
my ($a, $b, $algo, $expectation) = @_;
}
if ($verbose) {
my $chunks = HTML::Diff::line_diff($test_text_a, $test_text_b);
print_diff($chunks);
$chunks = HTML::Diff::word_diff($test_text_c, $test_text_d);
print "\n";
print_diff($chunks);
}
ok(deep_compare(html_word_diff('', ''), [['', undef, undef]]));
ok(deep_compare(html_word_diff('0', ''), [['-', '0', '']]));
ok(deep_compare(html_word_diff('', '0'), [['+', '', '0']]));
ok(deep_compare(html_word_diff('0', '0'), [['u', '0', '0']]));
ok(deep_compare(html_word_diff('a b b', 'b b c'),
[['-', 'a ', ''],
['u', 'b ', 'b '],
['c', 'b', 'b c']]));
print "Testing line_diff on test_text_a and test_text_b\n" if $verbose;
ok(test_diff_continuity($test_text_a, $test_text_b,
\&HTML::Diff::line_diff));
print "Testing html_word_diff on test_text_a and test_text_b\n"
if $verbose;
ok(test_diff_continuity($test_text_a, $test_text_b,
\&HTML::Diff::html_word_diff));
print "Testing html_word_diff on test_html_a and test_html_b\n"
if $verbose;
ok(test_diff_continuity($test_html_a, $test_html_b,
\&HTML::Diff::html_word_diff, 1));
my $result = HTML::Diff::html_word_diff($test_html_a, $test_html_b);
# Use the following lines to capture a "correct" result (when you
# think you've got one) which can be used to validate future tests
# open OUT, ">expect";
# print OUT Dumper($result);
# close OUT;
# This value is the result we expect from HTML::Diff::html_word_diff()
# If the actual result differs by one byte, it's a failure.
# When the diff code is changed, you'll need to calculate a new expected
# value using the lines above, and paste the resulting value below.
my $expect = [
[
'-',
'
', 'September 23, 1996
'
],
[
'-',
'< this is an unkown html tag />
',
''
],
[
'u',
'Anne Condon, University of Wisconsin
Faith Fich, University of Toronto
Greg N. Frederickson, Purdue University
Andrew V. Goldberg, NEC Research Institute
David S. Johnson, AT&T Bell Laboratories
Michael C. Loui, University of Illinois at Urbana-Champaign
Steven Mahaney, DIMACS ',
'Anne Condon, University of Wisconsin
Faith Fich, University of Toronto
Greg N. Frederickson, Purdue University
Andrew V. Goldberg, NEC Research Institute
David S. Johnson, AT&T Bell Laboratories
Michael C. Loui, University of Illinois at Urbana-Champaign
Steven Mahaney, DIMACS '
],
[
'c',
'
',
'
'
],
[
'u',
'Prabhakar Raghavan, IBM Almaden Research Center
John Savage, Brown University
Alan Selman, SUNY at Buffalo
David B. Shmoys, Cornell University
Abstract.
This report focuses on two core areas of theory of computing:
discrete algorithms and computational complexity theory.
The report
reviews the purposes and goals of theoretical research,
summarizes selected past and recent achievements,
',
'Prabhakar Raghavan, IBM Almaden Research Center
John Savage, Brown University
Alan Selman, SUNY at Buffalo
David B. Shmoys, Cornell University
Abstract. This report focuses on two core areas of theory of computing: discrete algorithms and computational complexity theory. The report reviews the purposes and goals of theoretical research, summarizes selected past and recent achievements, ' ], [ 'c', 'explains the importance of ', 'explains the importance of ' ], [ 'u', 'sustaining core research, and identifies promising opportunities for future research. Some research opportunities build bridges between theory of computing and other areas of computer science, and other science and engineering disciplines.
', 'sustaining core research, and identifies promising opportunities for future research. Some research opportunities build bridges between theory of computing and other areas of computer science, and other science and engineering disciplines.
' ], ]; ok(deep_compare($result, $expect)); # Given two array refs of array refs, of array refs... return true if # the two structures are isomorphic and all the corresponding scalars # are equal # TBD: make it more efficient; builds up call stack too much. # TBD: Take a binary test as an arg, to replace eq sub deep_compare { my ($a, $b) = @_; my ($x, $y); if (!ref($a) && !ref($b)) { return $a eq $b; } else { return 0 unless ((ref($a) eq 'ARRAY') && (ref($b) eq 'ARRAY')); while ($x = shift @$a) { $y = shift @$b; return 0 unless deep_compare($x, $y); } } return 1; } my $diffchunks = HTML::Diff::html_word_diff($test_html_a, $test_html_b); if ($verbose) { print "Result of diff:\n"; print "[$_]\n" foreach (map {join "||", @$_} @$diffchunks); } sub check_diff_integrity { my $failure = 0; foreach my $chunk (@{$_[0]}) { my ($mark, $left, $right) = @$chunk; if ($mark ne 'u' && $left eq $right) { print "[$left] is [$right] but HTML::Diff thinks they're different!\n"; $failure = 1; } } return !$failure; } my $A = "
Search
"; my $B = "Search
"; $result = html_word_diff($A, $B); ok(check_diff_integrity($result)); sub diff_file { my ($left, $right) = @_; open LEFT, $left; open RIGHT, $right; $/ = undef; my $Left =