TStanley has asked for the wisdom of the Perl Monks concerning the following question:

The Module: Config::Yacp

The test:
eval{ $CY1->set_value("INI","lf2"); }; ok( $@ eq "Can't Change Internal Parameter" , "Catch attempted changin +g of internal parameter");

The subroutine that is being tested:
sub set_value{ my ($self,$section,$para,$value)=@_; croak"Can't Change Internal Parameter" if $section~=/^INI|CM$/i; croak"Missing arguments" if scalar @_ < 4; croak"Non-Existent section" if !exists $self->{$section}; croak"Non-Existent parameter" if !exists $self->{$section}->{$para}; $self->{$section}->{$para}->[0]=$value; }
The problem:
When the above test runs, the error that is being returned inside $@ is "Missing arguments". However, the error that I am expecting is "Can't Change Internal Parameter" (the INI parameter stores the name of the configuration file). The behavior is correct, as you shouldn't be able to change the INI file, but I would like it to send back the correct error message.

TStanley
--------
The only thing necessary for the triumph of evil is for good men to do nothing -- Edmund Burke

Replies are listed 'Best First'.
Re: Module test problem
by jdporter (Paladin) on Nov 26, 2003 at 13:52 UTC
    Bug:
    $section~=/^INI|CM$/i
    should be
    $section=~/^INI|CM$/i

    jdporter
    The 6th Rule of Perl Club is -- There is no Rule #6.

      Typo :-)

      TStanley
      --------
      The only thing necessary for the triumph of evil is for good men to do nothing -- Edmund Burke
Re: Module test problem
by TStanley (Canon) on Nov 27, 2003 at 03:32 UTC
    After taking a second look at the overall code, as well as the position of the INI parameter within the object hash, I realized that the test is a moot point, since it is asking for 4 variables, including the object itself to be passed in, and the INI parameter would have to be passed in as the section variable. Thanks to Limbic~Region and the others in the chatterbox, who helped me with this problem this morning.

    TStanley
    --------
    The only thing necessary for the triumph of evil is for good men to do nothing -- Edmund Burke