Problem in synopsis of Test::Data?
Anonymous Monk
created: 2004-07-01 08:03:17
The following example given in the Test::Data modules t directory
#!/usr/bin/perl
use Test::More tests => 2;
use Test::Data qw(Function);
 
sub fooey($$) { 1 }
 
prototype_ok( &fooey, '$$', 'Double scalar fooey' );
prototype_ok(  &fooey, '$$' );
 
gives an error as 1..2 Type of arg 1 to Test::Data::Function::prototype_ok must be sub (not subroutine entry) at func.pl line 10, near "'Double scalar fooey' )" Type of arg 1 to Test::Data::Function::prototype_ok must be sub (not subroutine entry) at func.pl line 11, near "'$$' )" Execution of func.pl aborted due to compilation errors.

Edit by [BazB]: change title from "Query"

Re: Problem in synopsis of Test::Data?
created: 2004-07-01 08:37:45

You need to backslash the subs so as to pass a reference to them, not call them.

prototype_ok( \&fooey, '$$', 'Double scalar fooey' );
prototype_ok( \&fooey, '$$' );

And yes, the t\function.t has it wrong, as is the POD description for prototype_ok().


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - [Abigail-II|Abigail]
"Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - [tachyon]

perlmonks.org content © perlmonks.org and Anonymous Monk, BrowserUk

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03