Skip to content

Commit

Permalink
Item10346: optimizing
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/branches/Release01x01@10751 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
ArthurClemens authored and ArthurClemens committed Feb 20, 2011
1 parent bd1a1bc commit d20364a
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions UnitTestContrib/test/unit/Fn_MAKETEXT.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ use Error qw( :try );

my $topicObject;

BEGIN {
delete $INC{'Foswiki/I18N.pm'};
}

sub new {
my $self = shift()->SUPER::new( 'MAKETEXT', @_ );
return $self;
Expand All @@ -33,26 +37,25 @@ sub loadExtraConfig {
}

sub setLocalSite {
delete $INC{'Foswiki/I18N.pm'};
$Foswiki::cfg{WebMasterEmail} = 'a.b@c.org';
$Foswiki::cfg{UserInterfaceInternationalisation} = 1;
}

sub test_MAKETEXT_simple {
sub test_simple {
my $this = shift;

my $result = $topicObject->expandMacros('%MAKETEXT{"edit"}%');
$this->assert_str_equals( 'edit', $result );
}

sub test_MAKETEXT_doc_example_1 {
sub test_doc_example_1 {
my $this = shift;

my $result = $topicObject->expandMacros('%MAKETEXT{string="Notes:"}%');
$this->assert_str_equals( 'Notes:', $result );
}

sub test_MAKETEXT_doc_example_2 {
sub test_doc_example_2 {
my $this = shift;

my $result = $topicObject->expandMacros(
Expand All @@ -65,7 +68,7 @@ args="%WIKIWEBMASTER%"
'If you have any questions, please contact a.b@c.org.', $result );
}

sub test_MAKETEXT_doc_example_3 {
sub test_doc_example_3 {
my $this = shift;

my $result = $topicObject->expandMacros(
Expand All @@ -78,47 +81,47 @@ sub test_MAKETEXT_doc_example_3 {
);
}

sub test_MAKETEXT_single_arg {
sub test_single_arg {
my $this = shift;

my $result =
$topicObject->expandMacros('%MAKETEXT{"edit [_1]" args="WebHome"}%');
$this->assert_str_equals( 'edit WebHome', $result );
}

sub test_MAKETEXT_expand_variables_in_args {
sub test_expand_variables_in_args {
my $this = shift;

my $result =
$topicObject->expandMacros('%MAKETEXT{"edit [_1]" args="%HOMETOPIC%"}%');
$this->assert_str_equals( 'edit WebHome', $result );
}

sub test_MAKETEXT_multiple_args {
sub test_multiple_args {
my $this = shift;

my $result = $topicObject->expandMacros(
'%MAKETEXT{"edit [_1] [_2]" args="WebHome, now"}%');
$this->assert_str_equals( 'edit WebHome now', $result );
}

sub test_MAKETEXT_multiple_args_one_empty {
sub test_multiple_args_one_empty {
my $this = shift;

my $result =
$topicObject->expandMacros('%MAKETEXT{"edit [_1][_2]" args="WebHome"}%');
$this->assert_str_equals( 'edit WebHome', $result );
}

sub test_MAKETEXT_multiple_args_forgot_to_reference_one {
sub test_multiple_args_forgot_to_reference_one {
my $this = shift;

my $result =
$topicObject->expandMacros('%MAKETEXT{"edit [_1]" args="WebHome, now"}%');
$this->assert_str_equals( 'edit WebHome', $result );
}

sub test_MAKETEXT_underscore {
sub test_underscore {
my $this = shift;

# name starts with underscore: error
Expand All @@ -129,7 +132,7 @@ sub test_MAKETEXT_underscore {
);
}

sub test_MAKETEXT_access_key {
sub test_access_key {
my $this = shift;

my $result = $topicObject->expandMacros('%MAKETEXT{"ed&it"}%');
Expand Down

0 comments on commit d20364a

Please sign in to comment.