+ my @changes = IkiWiki::rcs_recentchanges(3);
+ is_total_number_of_changes(\@changes, 0);
+
+ my $message = "add a UTF-8 and an ASCII file in different dirs";
+ my $file1 = "rcsdiff1/utf8.mdwn";
+ my $file2 = "rcsdiff2/ascii.mdwn";
+ my $contents2 = ''; $contents2 .= "$_. foo\n" for (1..11);
+ can_mkdir($_) for (qw(rcsdiff1 rcsdiff2));
+ writefile($file1, $config{srcdir}, readfile('t/test2.mdwn'));
+ writefile($file2, $config{srcdir}, $contents2);
+ IkiWiki::rcs_add($_) for ($file1, $file2);
+ IkiWiki::rcs_commit_staged(message => $message);
+
+ # XXX we rely on rcs_recentchanges() to be called first!
+ # XXX or else for no cvsps cache to exist yet...
+ # XXX because rcs_diff() doesn't pass -x (as an optimization)
+ @changes = IkiWiki::rcs_recentchanges(3);
+ is_total_number_of_changes(\@changes, 1);
+
+ my $changeset = 1;
+
+ my $maxlines = undef;
+ my $scalar_diffs = IkiWiki::rcs_diff($changeset, $maxlines);
+ like(
+ $scalar_diffs,
+ qr/^\+11\. foo$/m,
+ q{unbounded scalar diffs go all the way to 11},
+ );
+ my @array_diffs = IkiWiki::rcs_diff($changeset, $maxlines);
+ is(
+ $array_diffs[$#array_diffs],
+ "+11. foo\n",
+ q{unbounded array diffs go all the way to 11},
+ );
+
+ $maxlines = 8;
+ $scalar_diffs = IkiWiki::rcs_diff($changeset, $maxlines);
+ unlike(
+ $scalar_diffs,
+ qr/^\+11\. foo$/m,
+ q{bounded scalar diffs don't go all the way to 11},
+ );
+ @array_diffs = IkiWiki::rcs_diff($changeset, $maxlines);
+ isnt(
+ $array_diffs[$#array_diffs],
+ "+11. foo\n",
+ q{bounded array diffs don't go all the way to 11},
+ );
+ is(
+ scalar @array_diffs,
+ $maxlines,
+ q{bounded array diffs contain expected maximum number of lines},
+ );
+