Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

use_ok with version number

by Narveson (Chaplain)
on Nov 25, 2009 at 22:19 UTC ( [id://809447]=perlquestion: print w/replies, xml ) Need Help??

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

I like starting a test script with

use_ok 'Acme::Stuff';

What if I want to make sure I'm testing a newer version? The client code will say

use Acme::Stuff '1.1.2';

but I can't seem to say

use_ok 'Acme::Stuff' '1.1.2';

I can write a second test, something like

cmp_ok $Acme::Stuff::VERSION, '>=', '1.1.2';

Anybody have better advice?

Update (Thanksgiving Day in U.S.A.):

Thanks for the replies, all of which are helpful.

Replies are listed 'Best First'.
Re: use_ok with version number
by moritz (Cardinal) on Nov 25, 2009 at 22:59 UTC
Re: use_ok with version number
by almut (Canon) on Nov 25, 2009 at 22:38 UTC

    I think you just need to put a comma between module name and version:

    use_ok 'Acme::Stuff', '1.1.2';

    (Unlike the regular use statement, use_ok is a subroutine call with arguments)

      regardless of comma, use_ok has a regex in code, that allows max one dot in version string. Also vstring is not supported by use_ok.

        Wow, this is good to know.

        I just tested your assertion, and it looks like you're right. When the actual version is '1.1.2', specifying version '2' fails as it should, but specifying version '1.1.3' succeeds.

        I suppose I ought to report this as a bug in Test::More.

Re: use_ok with version number
by zwon (Abbot) on Nov 26, 2009 at 22:55 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://809447]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-23 22:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found