X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F15-failures.t;h=a25d334d25e7d875fbd2d400f83a0df98a0d4ddf;hb=059db7acc549028de142c82c375a46a5ad03a026;hp=52332672c5da3d15f50f03f4488c37470b5d3fa0;hpb=d2c0f4071b90c3b50696c5b7f9cc4ae341628f33;p=perl%2Fmodules%2Frgit.git diff --git a/t/15-failures.t b/t/15-failures.t index 5233267..a25d334 100644 --- a/t/15-failures.t +++ b/t/15-failures.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 20; +use Test::More tests => 34; use App::Rgit; @@ -56,3 +56,32 @@ like($@, qr!Command\s+dongs\s+should\s+be\s+executed\s+as\s+a\s+App::Rgit::Comma $res = eval { App::Rgit::Test::Foo->App::Rgit::Command::new(cmd => 'version') }; is($@, '', 'App::Rgit::Test::Foo->App::Rgit::Command::new(cmd => "version"): does not croak'); isa_ok($res, 'App::Rgit::Test::Foo', 'App::Rgit::Test::Foo->App::Rgit::Command::new(cmd => "version"): returns valid object'); + +$res = eval { App::Rgit::Command->action('version') }; +is($@, '', 'App::Rgit::Command->action("version"): does not croak'); +is($res, 'App::Rgit::Command::Once', 'App::Rgit::Command->action("version"): returns valid answer'); + +$res = eval { App::Rgit::Command->new(cmd => 'version')->action() }; +is($@, '', 'App::Rgit::Command->action(): does not croak'); +is($res, 'App::Rgit::Command::Once', 'App::Rgit::Command->action(): returns valid answer'); + +$res = eval { App::Rgit::Command->action() }; +is($@, '', 'App::Rgit::Command->action(): no cmd: does not croak'); +is($res, undef, 'App::Rgit::Command->action(); no cmd: returns undef'); + +$res = eval { App::Rgit::Command::action() }; +is($@, '', 'undef->App::Rgit::Command::action(): no cmd: does not croak'); +is($res, undef, 'undef->App::Rgit::Command::action(); no cmd: returns undef'); + +$res = bless { }, 'App::Rgit::Test::Monkey'; +$res = eval { $res->App::Rgit::Command::action() }; +is($@, '', 'App::Rgit::Test::Monkey->App::Rgit::Command::action(): no cmd: does not croak'); +is($res, undef, 'App::Rgit::Test::Monkey->App::Rgit::Command::action(); no cmd: returns undef'); + +$res = eval { App::Rgit::Command->action('beer' => 'App::Rgit::Test::Pub') }; +is($@, '', 'App::Rgit::Command->action("beer" => "App::Rgit::Test::Pub"): does not croak'); +is($res, 'App::Rgit::Test::Pub', 'App::Rgit::Command->action("beer" => "App::Rgit::Test::Pub"): returns valid answer'); + +$res = eval { App::Rgit::Command->action('beer') }; +is($@, '', 'App::Rgit::Command->action("beer"): does not croak'); +is($res, 'App::Rgit::Test::Pub', 'App::Rgit::Command->action("beer"): returns valid answer');