Revision history for Perl extension MooseX-Getopt
+NEXT
+ * The test suite now uses Test::Fatal instead of Test::Exception. (Karen
+ Etheridge)
+
0.33 Thu 26 Aug 2010
* Remove Test::Most from newly added test (RT#60766)
use warnings;
use Test::More tests => 9;
-use Test::Exception 0.21;
+use Test::Fatal;
BEGIN {
use_ok('MooseX::Getopt');
{
local @ARGV = (qw/--private_stuff 317/);
- throws_ok { App->new_with_options } qr/Unknown option: private_stuff/;
+ like exception { App->new_with_options }, qr/Unknown option: private_stuff/;
}
use warnings;
use Test::More tests => 10;
-use Test::Exception;
+use Test::Fatal;
BEGIN {
use_ok('MooseX::Getopt');
{
local @ARGV = (qw/--private_stuff 317/);
- throws_ok { App->new_with_options } qr/Unknown option: private_stuff/;
+ like exception { App->new_with_options }, qr/Unknown option: private_stuff/;
}
{
local @ARGV = (qw/--length 100/);
- throws_ok { App->new_with_options } qr/Unknown option: length/;
+ like exception { App->new_with_options }, qr/Unknown option: length/;
}
use warnings;
use Test::More tests => 9;
-use Test::Exception;
+use Test::Fatal;
BEGIN {
use_ok('MooseX::Getopt');
{
local @ARGV = (qw/--private_stuff 317/);
- throws_ok { App->new_with_options } qr/Unknown option: private_stuff/;
+ like exception { App->new_with_options }, qr/Unknown option: private_stuff/;
}
use warnings;
use Test::More tests => 37;
-use Test::Exception;
+use Test::Fatal;
use File::Spec;
use Test::Requires 0.05 {
{
local @ARGV = qw( --required_from_argv 1 );
- throws_ok { App->new_with_options } qr/Required option missing: required_from_config/;
+ like exception { App->new_with_options }, qr/Required option missing: required_from_config/;
{
my $app = App::DefaultConfigFile->new_with_options;
# Required arg not supplied from cmdline
{
local @ARGV = qw( --configfile /notused );
- throws_ok { App->new_with_options } qr/Required option missing: required_from_argv/;
+ like exception { App->new_with_options }, qr/Required option missing: required_from_argv/;
}
# Config file value overriden from cmdline
# With DerivedApp, the Getopt role was applied at a different level
# than the ConfigFromFile role
{
- lives_ok { DerivedApp::Getopt->new_with_options } 'Can create DerivedApp';
+ ok ! exception { DerivedApp::Getopt->new_with_options }, 'Can create DerivedApp';
}
sub app_ok {
use warnings;
use Test::More tests => 5;
-use Test::Exception;
+use Test::Fatal;
use Test::Requires {
'Getopt::Long::Descriptive' => 0.01, # skip all if not installed
@ARGV = qw(--bar 10);
my $foo;
-lives_ok {
+ok ! exception {
$foo = Testing::Foo->new_with_options(baz => 100);
-} '... this should work';
+}, '... this should work';
isa_ok($foo, 'Testing::Foo');
is($foo->bar, 10, '... got the right values');
use strict;
use warnings;
-use Test::More tests => 5;
-
-use Test::Exception;
+use Test::More tests => 7;
+use Test::Fatal;
BEGIN {
{
local @ARGV = (qw/--some-thingy bar/);
- lives_and { is( App->new_with_options->some_thingy, 'bar') } 'Dash in option name';
+ ok ! exception { is( App->new_with_options->some_thingy, 'bar') }, 'Dash in option name';
}
{
local @ARGV = (qw/--some_thingy bar/);
- throws_ok { App->new_with_options } qr/Unknown option: some_thingy/;
+ like exception { App->new_with_options }, qr/Unknown option: some_thingy/;
}
{
local @ARGV = (qw/--another_thingy bar/);
- lives_and { is( App->new_with_options->another_thingy, 'bar' ) } 'Underscore in option name';
+ ok ! exception { is( App->new_with_options->another_thingy, 'bar' ) }, 'Underscore in option name';
}
{
local @ARGV = (qw/--another-thingy bar/);
- throws_ok { App->new_with_options } qr/Unknown option: another-thingy/;
+ like exception { App->new_with_options }, qr/Unknown option: another-thingy/;
}
use warnings;
use Test::More tests => 5;
-use Test::Exception;
use Test::Requires {
'Getopt::Long::Descriptive' => 0.01, # skip all if not installed
use strict;
use warnings;
use Test::More 0.88;
-use Test::Exception;
+use Test::Fatal;
{
package MyScript;
{
local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception;
local @ARGV = ('--help');
- throws_ok { MyScript->new_with_options } qr/A foo/;
+ like exception { MyScript->new_with_options }, qr/A foo/;
is $MyScript::usage, 1;
}
{
local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception;
local @ARGV = ('-q'); # Does not exist
- throws_ok { MyScript->new_with_options } qr/A foo/;
+ like exception { MyScript->new_with_options }, qr/A foo/;
is_deeply \@MyScript::warnings, [
'Unknown option: q
'
}
use Test::Warn 0.21;
-use Test::Exception;
+use Test::Fatal;
END {
ok(!$fail_on_exit, 'getoptions() lives');
@ARGV = ('--help');
warning_like {
- throws_ok { Class->new_with_options }
+ like exception { Class->new_with_options },
#usage: 107_no_auto_help.t [-?] [long options...]
qr/^usage: [\d\w]+\Q.t [-?] [long options...]\E.\s+\Q-? --usage --help Prints this usage information.\E.\s+--configfile/ms,
'usage information looks good';
use strict; use warnings;
use Test::More tests => 6;
-use Test::Exception;
+use Test::Fatal;
{
package MyClass;
{
local @ARGV = @$args;
- throws_ok { MyClass->new_with_options() }
+ like exception { MyClass->new_with_options() },
qr/^usage: (?:[\d\w]+)\Q.t [-?] [long options...]\E.^\t\Q-? --usage --help Prints this usage information.\E$/ms,
'Help request detected; usage information properly printed';
}
use strict; use warnings;
use Test::More tests => 1;
-use Test::Exception;
{
package MyClass;