Skip Menu |

This queue is for tickets about the Test-use-ok CPAN distribution.

Report information
The Basics
Id: 78757
Status: resolved
Priority: 0/
Queue: Test-use-ok

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.02
Fixed in: (no value)



Subject: Allow "use ok;"
Currently, "use ok" dies if given no arguments. While this makes it work like the use_ok() interface, it makes it difficult to work with because something you just want to innocently load a module. This particularly becomes a problem with "use ok 'ok'". ok.pm has code to try and detect if it's being called inside use_ok(), but that code will no longer work next release. use_ok() got smarter and sets the line and file of the eval to the caller's location. No longer will caller() report /eval/ but an actual line and file. The "use ok" tests will fail next Test::More release. ok.pm could maybe try to figure out if it's called inside use_ok() by looking up the stack, but that furthers an arms race that's unnecessary. "use ok;" is pretty obviously trying to load ok.pm and not accidentally testing nothing. "use ok $module" is unlikely to happen, being the whole point is doing use_ok() at BEGIN time conveniently, and you can check for being passed undef if so. This patch ends that arms race and simply makes "use ok" work. I'd be happy to make a release of this module if you're done with it.
Subject: ok.patch
diff --git a/lib/ok.pm b/lib/ok.pm index 663a944..85952ea 100644 --- a/lib/ok.pm +++ b/lib/ok.pm @@ -6,10 +6,6 @@ use Test::More (); sub import { shift; goto &Test::More::use_ok if @_; - - # No argument list - croak as if we are prototyped like use_ok() - my (undef, $file, $line) = caller(); - ($file =~ /^\(eval/) or die "Not enough arguments for 'use ok' at $file line $line\n"; } diff --git a/t/01-basic.t b/t/01-basic.t index 12997d5..2e84f2c 100644 --- a/t/01-basic.t +++ b/t/01-basic.t @@ -1,5 +1,8 @@ use strict; use Test::More tests => 3; + +use ok; # the module can be loaded without tripping an error + use ok 'strict'; use ok 'Test::More'; use ok 'ok';
use ok 'ok'; currently works. use ok; dies saying it needs an additional argument. I *think* this is reasonable behavior. If not please re-open this ticket in the Test-Simple github issues.