Skip to content

Commit

Permalink
Item11783: document the current (and long standing) results of INCLUD…
Browse files Browse the repository at this point in the history
…E in preparation to change the meaning of commas to a list of topics

git-svn-id: http://svn.foswiki.org/trunk@14648 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Apr 23, 2012
1 parent d3910dd commit 86f4983
Showing 1 changed file with 139 additions and 0 deletions.
139 changes: 139 additions & 0 deletions UnitTestContrib/test/unit/Fn_INCLUDE.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,145 @@ sub tear_down {
$this->SUPER::tear_down();
}

sub test_simple {
my $this = shift;
my $includeTopic = shift || $this->{test_web}.'.FirstTopic';
my $includeError = shift;

Foswiki::Func::saveTopic($this->{test_web}, 'FirstTopic', undef, '1');
$this->assert_str_equals($includeError?"A $includeError B":'A 1 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'"}% B', 'WebHome', $this->{other_web}));

$this->assert_str_equals($includeError?"A B":'A 1 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'" warn="off"}% B', 'WebHome', $this->{other_web}));


Foswiki::Func::saveTopic($this->{test_web}, 'FirstTopic', undef, '1 %STARTINCLUDE%2%STOPINCLUDE% 3');
$this->assert_str_equals($includeError?"A $includeError B":'A 2 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'"}% B', 'WebHome', $this->{other_web}));

Foswiki::Func::saveTopic($this->{test_web}, 'FirstTopic', undef, '1 %STARTSECTION{type="include"}%2%ENDSECTION{type="include"}% 3');
$this->assert_str_equals($includeError?"A $includeError B":'A 2 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'"}% B', 'WebHome', $this->{other_web}));

Foswiki::Func::saveTopic($this->{test_web}, 'FirstTopic', undef, '1 %STARTSECTION{type="include"}%2%ENDSECTION{type="include"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5');
$this->assert_str_equals($includeError?"A $includeError B":'A 24 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'"}% B', 'WebHome', $this->{other_web}));

Foswiki::Func::saveTopic($this->{test_web}, 'FirstTopic', undef, '1 %STARTSECTION%2%ENDSECTION% 3');
$this->assert_str_equals($includeError?"A $includeError B":'A 1 2 3 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'"}% B', 'WebHome', $this->{other_web}));

Foswiki::Func::saveTopic($this->{test_web}, 'FirstTopic', undef, '1 %STARTSECTION{"_default"}%2%ENDSECTION{"_default"}% 3');
$this->assert_str_equals($includeError?"A $includeError B":'A 1 2 3 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'"}% B', 'WebHome', $this->{other_web}));

Foswiki::Func::saveTopic($this->{test_web}, 'FirstTopic', undef, '1 %STARTSECTION{"_default"}%2%ENDSECTION{"_default"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5');
$this->assert_str_equals($includeError?"A $includeError B":'A 2 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'" section="_default"}% B', 'WebHome', $this->{other_web}));

}

sub test_simple_not_there {
my $this = shift;
$this->test_simple('NotThere', "<span class='foswikiAlert'>
Warning: Can't find topic <nop>TemporaryINCLUDETestWebINCLUDEother.<nop>NotThere
</span>");
}

sub test_not_there_commas {
my $this = shift;
$this->test_simple('NotThere, System.NoTopic', "<span class='foswikiAlert'>
Warning: Can\'t find topic <nop>NotThere, System.<nop>NoTopic
</span>");
}

sub test_not_there_spaces {
my $this = shift;
$this->test_simple('NotThere System.NoTopic', "<span class='foswikiAlert'>
Warning: Can't find topic <nop>NotThere System.<nop>NoTopic
</span>");
}

sub test_not_there_newlines {
my $this = shift;
$this->test_simple('NotThere
System.NoTopic', "<span class='foswikiAlert'>
Warning: Can't INCLUDE '<nop>NotThere
System.NoTopic', path is empty or contains illegal characters.
</span>");
}

sub test_first_not_there_commas {
my $this = shift;
$this->test_simple('NotThere, '.$this->{test_web}.'.FirstTopic', "<span class='foswikiAlert'>
Warning: Can\'t find topic <nop>NotThere, TemporaryINCLUDETestWebINCLUDE.<nop>FirstTopic
</span>");
}

sub test_first_not_there_spaces {
my $this = shift;
$this->test_simple('NotThere '.$this->{test_web}.'.FirstTopic', "<span class='foswikiAlert'>
Warning: Can't find topic <nop>NotThere TemporaryINCLUDETestWebINCLUDE.<nop>FirstTopic
</span>");
}

sub test_first_not_there_newlines {
my $this = shift;
$this->test_simple('NotThere
'.$this->{test_web}.'.FirstTopic', "<span class='foswikiAlert'>
Warning: Can't INCLUDE '<nop>NotThere
TemporaryINCLUDETestWebINCLUDE.FirstTopic', path is empty or contains illegal characters.
</span>");
}

sub test_simple_section {
my $this = shift;
my $includeSection = shift || '';
my $includeTopic = shift || $this->{test_web}.'.FirstTopic';
my $includeError = shift;

Foswiki::Func::saveTopic($this->{test_web}, 'FirstTopic', undef, '1');
$this->assert_str_equals($includeError?"A $includeError B":'A 1 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'" section="'.$includeSection.'"}% B', 'WebHome', $this->{other_web}));

$this->assert_str_equals($includeError?"A B":'A 1 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'" section="'.$includeSection.'" warn="off"}% B', 'WebHome', $this->{other_web}));


Foswiki::Func::saveTopic($this->{test_web}, 'FirstTopic', undef, '1 %STARTINCLUDE%2%STOPINCLUDE% 3');
$this->assert_str_equals($includeError?"A $includeError B":'A 2 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'" section="'.$includeSection.'"}% B', 'WebHome', $this->{other_web}));

Foswiki::Func::saveTopic($this->{test_web}, 'FirstTopic', undef, '1 %STARTSECTION{type="include"}%2%ENDSECTION{type="include"}% 3');
$this->assert_str_equals($includeError?"A $includeError B":'A 2 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'" section="'.$includeSection.'"}% B', 'WebHome', $this->{other_web}));

Foswiki::Func::saveTopic($this->{test_web}, 'FirstTopic', undef, '1 %STARTSECTION{type="include"}%2%ENDSECTION{type="include"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5');
$this->assert_str_equals($includeError?"A $includeError B":'A 24 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'" section="'.$includeSection.'"}% B', 'WebHome', $this->{other_web}));

Foswiki::Func::saveTopic($this->{test_web}, 'FirstTopic', undef, '1 %STARTSECTION%2%ENDSECTION% 3');
$this->assert_str_equals($includeError?"A $includeError B":'A 1 2 3 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'" section="'.$includeSection.'"}% B', 'WebHome', $this->{other_web}));

Foswiki::Func::saveTopic($this->{test_web}, 'FirstTopic', undef, '1 %STARTSECTION{"_default"}%2%ENDSECTION{"_default"}% 3');
$this->assert_str_equals($includeError?"A $includeError B":'A 1 2 3 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'" section="'.$includeSection.'"}% B', 'WebHome', $this->{other_web}));

Foswiki::Func::saveTopic($this->{test_web}, 'FirstTopic', undef, '1 %STARTSECTION{"_default"}%2%ENDSECTION{"_default"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5');
$this->assert_str_equals($includeError?"A $includeError B":'A 2 B', Foswiki::Func::expandCommonVariables( 'A %INCLUDE{"'.$includeTopic.'" section="'.$includeSection.'" section="_default"}% B', 'WebHome', $this->{other_web}));

}


sub test_select_first_that_defines_section {
my $this = shift;
$this->test_simple_section('section_name',
join(', ', ('NoSuchTopic', $this->{test_web}.'.FirstTopic')),
"<span class='foswikiAlert'>
Warning: Can\'t find topic <nop>NoSuchTopic, TemporaryINCLUDETestWebINCLUDE.<nop>FirstTopic
</span>"
);

Foswiki::Func::saveTopic($this->{test_web}, 'NoSection', undef, '1 %STARTSECTION{"_default"}%2%ENDSECTION{"_default"}% 3 %STARTSECTION{type="include"}%4%ENDSECTION{type="include"}% 5');
$this->test_simple_section('section_name',
join(', ', ('NoSuchTopic', $this->{test_web}.'.NoSection', $this->{test_web}.'.FirstTopic')),
"<span class='foswikiAlert'>
Warning: Can\'t find topic <nop>NoSuchTopic, TemporaryINCLUDETestWebINCLUDE/NoSection, TemporaryINCLUDETestWebINCLUDE.<nop>FirstTopic
</span>"
);


}



# Test that web references are correctly expanded when a topic is included
# from another web. Verifies that verbatim, literal and noautolink zones
# are correctly honoured.
Expand Down

0 comments on commit 86f4983

Please sign in to comment.