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

#!/usr/bin/perl -w use Test; BEGIN {plan tests=>3} ; use Test::Data qw(Array); @arr=qw(roop ras dar ); $a=dar; array_any_ok( $a, @arr, [ NAME] ); array_empty_ok(@arr ,[ME] );
gives me an output as
1..3
# Running under perl version 5.006 for linux
# Current time local: Tue Jun 22 16:51:24 2004
# Current time GMT:   Tue Jun 22 11:21:24 2004
# Using Test.pm version 1.25
ok firstYou tried to run a test without a plan!  Gotta have a plan. at /usr/lib
perl5/site_perl/5.6.0/Test/Data/Array.pm line 47
# Looks like your test died before it could output anything.
Can u help.i m runng ths prog on Linux 5.6 version.Test-Data0.92 version.

Edit by castaway, retitle from 'Help', added pre tags

Replies are listed 'Best First'.
Re: Problem using Test::Data
by adrianh (Chancellor) on Jun 22, 2004 at 13:39 UTC

    The problem is that Test::Data is built on top of Test::Builder, rather than the older Test module. The plan emitted by Test isn't picked up by Test::Builder hence the error.

    I'd recommend dumping Test and using Test::Simple and Test::More instead.

    Also you've forgot to quote some of your barewords, and the [ NAME ] syntax is just a notation used in the Test::Data::Array documentation to indicate an optional third argument.

    Putting all of this together gives us:

    #!/usr/bin/perl -w use strict; use Test::Simple tests => 2; use Test::Data qw(Array); my @arr = qw( roop  ras dar ); my $a = 'dar'; array_any_ok( $a, @arr, '$a is in @arr' ); array_empty_ok( @arr, '@arr is empty' );
Re: Problem using Test::Data
by EvdB (Deacon) on Jun 22, 2004 at 11:51 UTC
    Try perldoc Test and then read the page, with special care taken over 'plan()'.

    --tidiness is the memory loss of environmental mnemonics