in reply to Re^3: Testing Perl Package
in thread Testing Perl Package

Hi,

Thanks for the comments.

i am testing the package with the Test::more module, see the below code,

#!/usr/bin/perl -w use strict; use SptTgtCfg; use Test::More; BEGIN { use_ok('SptTgtCfg'); } $SptTgtCfg = SptTgtCfg::Max_Num_Of_Interest_Mask->new(CAN11 => 4,C +AN29 => 4); ok( defined $SptTgtCfg, 'new() returened something' ); ok( $SptTgtCfg->isa('SptTgtCfg'), " and it's the right class" ); is( $SptTgtCfg->CAN11, 7, ' CAN11()' ); is( $SptTgtCfg->CAN29, 2, ' CAN29)' );

whether i am doing correct or not, please suggest. If i run this code, i am getting error as

1. ok 1 - use SptTgtCfg;

2. Gllobal symbol requires explicit package name

Replies are listed 'Best First'.
Re^5: Testing Perl Package
by choroba (Cardinal) on May 10, 2013 at 09:20 UTC
    Your script starts with strict. You cannot assing to the undeclared variable $SptTgtCfg under strict.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^5: Testing Perl Package
by Corion (Patriarch) on May 10, 2013 at 09:19 UTC

    I highly doubt that your package SptTgtCfg is valid Perl and compiles as is. Thus I really doubt that you ever see

    ok 1 use SptTgtCfg;

    Your code cannot progress that far, because the line

    use SptTgtCfg;

    already fails.

    Consider reading the error message and looking at the line number that it indicates. Then consider what variables are on that line and where they are declared.

    Update: My diagnosis is somewhat wrong. My mistake here was to assume that SptTgtCfg.pm contains the errors as shown in the root node. But obviously, the ok 1 message can appear with a correct module SptTgtCfg.pm and then later the program hits the (strict induced) error of $SptTgtCfg not being declared.

Re^5: Testing Perl Package
by Anonymous Monk on May 10, 2013 at 09:35 UTC
    Well, the code you posted in Testing Perl Package contains only a bunch of global hashes, it contains no methods/functions/subs, especially none called new/CAN11...

      Hi,

      May be my understanding wrong, could you please provide some examples other than mentioned in the CPAN Module.

      How to use "Test::more" module to our package which is local