Skip to content

Commit

Permalink
Item11356: More [[link]] tests; behviour w/spaces
Browse files Browse the repository at this point in the history
sanity_link_tests pass if the following is commented out:

--- a/lib/Foswiki/Render.pm
+++ b/lib/Foswiki/Render.pm
@@ -1224,7 +1224,7 @@ sub getRenderedVersion {
      # other entities
     $text =~ s/&(\w+);/$REMARKER$1;/g;              # "&abc;"
     $text =~ s/&(#x?[0-9a-f]+);/$REMARKER$1;/gi;    # "{"
-    $text =~ s/&/&/g;                           # escape standalone "&"
+    #$text =~ s/&/&/g;                           # escape standalone "&"
     $text =~ s/$REMARKER(#x?[0-9a-f]+;)/&$1/goi;
     $text =~ s/$REMARKER(\w+;)/&$1/go;

git-svn-id: http://svn.foswiki.org/trunk@13454 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
PaulHarvey authored and PaulHarvey committed Dec 18, 2011
1 parent ec33fda commit 0663c2b
Showing 1 changed file with 35 additions and 21 deletions.
56 changes: 35 additions & 21 deletions UnitTestContrib/test/unit/FormattingTests.pm
Expand Up @@ -58,24 +58,36 @@ my %link_tests = (
query => 'q=r&s=t',
fragment => 'f'
},

# Extra spacey
' a a ' =>
{ topic => 'Aa', autolink => 0, relative => 'web', normal => undef },
{ topic => 'AA', autolink => 0, relative => 'web', normal => undef },
' a a / b b ' =>
{ address => 'Aa.Bb', autolink => 0, relative => 0, normal => undef },
{ address => 'AA.BB', autolink => 0, relative => 0, normal => undef },
' a a . b b ' =>
{ address => 'Aa.Bb', autolink => 0, relative => 0, normal => undef },
{ address => 'AA.BB', autolink => 0, relative => 0, normal => undef },
' a a . b b / cc ' =>

# Legacy behaviour is wrong! Should be Aa.Bb/Cc
{ address => 'Aa/bb.Cc', autolink => 0, relative => 0, normal => undef },
{ address => 'AA/BB.Cc', autolink => 0, relative => 0, normal => undef },
' a a / b b . cc ' =>

# Legacy behaviour is wrong! Should be Aa/Bb.Cc
{ address => 'Aa/bb.Cc', autolink => 0, relative => 0, normal => undef },
{ address => 'AA/BB.Cc', autolink => 0, relative => 0, normal => undef },
' a a . b b . cc ' =>
{ address => 'AA.BB.Cc', autolink => 0, relative => 0, normal => undef },

# Legacy behaviour is wrong! Should be Aa.Bb.Cc
{ address => 'Aa.bb.Cc', autolink => 0, relative => 0, normal => undef },
# Spacey
' aa ' =>
{ topic => 'Aa', autolink => 0, relative => 'web', normal => undef },
' aa / bb ' =>
{ address => 'Aa.Bb', autolink => 0, relative => 0, normal => undef },
' aa . bb ' =>
{ address => 'Aa.Bb', autolink => 0, relative => 0, normal => undef },
' aa . bb / cc ' =>
{ address => 'Aa/Bb.Cc', autolink => 0, relative => 0, normal => undef },
' aa / bb . cc ' =>
{ address => 'Aa/Bb.Cc', autolink => 0, relative => 0, normal => undef },
' aa . bb . cc ' =>
{ address => 'Aa.Bb.Cc', autolink => 0, relative => 0, normal => undef },

# Normalish
'Aa' => { topic => 'Aa', autolink => 0, relative => 'web', normal => 1 },
'Aa.Bb' =>
{ address => 'Aa.Bb', autolink => 1, relative => 0, normal => 1 },
Expand Down Expand Up @@ -1595,12 +1607,12 @@ sub _uri_unescape {
}

sub _check_rendered_linktext {
my ($this, $linktext, $expected) = @_;
my ( $this, $linktext, $expected ) = @_;
my $editpath = Foswiki::Func::getScriptUrlPath( undef, undef, 'edit' );
my $editpathregex = qr/^.*\Q$editpath\E\/([^"]*)/;
my $viewpath = Foswiki::Func::getScriptUrlPath( undef, undef, 'view' );
my $viewpathregex = qr/^.*\Q$viewpath\E\/([^"]*)/;
my $html = $this->{test_topicObject}->renderTML("[[$linktext]]");
my $html = $this->{test_topicObject}->renderTML("[[$linktext]]");
my $expectedAddress;
my $expectedAddrObj;
my $addrObj;
Expand Down Expand Up @@ -1648,8 +1660,7 @@ sub _check_rendered_linktext {
. ( defined $address ? $address : 'undef' ) . "\n"
if TRACE;
$this->assert_str_equals( $expectedAddrObj->stringify(),
$addrObj->stringify(),
"address mismatch checking [[$linktext]]" );
$addrObj->stringify(), "address mismatch checking [[$linktext]]" );
$this->assert_deep_equals( $expected->{query}, $query,
"query mismatch checking [[$linktext]]" );
$this->assert_deep_equals( $expected->{fragment}, $fragment,
Expand All @@ -1662,13 +1673,13 @@ sub _check_rendered_linktext {
# These tests were expected to be pass prior to re-working Foswiki link handling
# See Item11356 Foswiki:Development.ImplementingLinkProposals
sub test_sanity_link_tests {
my $this = shift;
my $this = shift;

$this->_create_link_test_fixtures();
while ( my ( $linktext, $expected ) = each %link_tests ) {

if ($linktext) {
$this->_check_rendered_linktext($linktext, $expected);
$this->_check_rendered_linktext( $linktext, $expected );
}
}
$this->_remove_link_test_fixtures();
Expand All @@ -1679,10 +1690,13 @@ sub test_sanity_link_tests {
sub test_ampersand_querystring {
my ($this) = shift;

$this->_check_rendered_linktext("$this->{test_topic}?q=r&s=t", {
address => "$this->{test_topic}",
query => 'q=r&s=t'
});
$this->_check_rendered_linktext(
"$this->{test_topic}?q=r&s=t",
{
address => "$this->{test_topic}",
query => 'q=r&s=t'
}
);

return;
}
Expand Down

0 comments on commit 0663c2b

Please sign in to comment.