From: gfx Date: Mon, 19 Oct 2009 09:28:24 +0000 (+0900) Subject: Modernize some tests X-Git-Tag: 0.40~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4c0e2aa7665fbf173a9b0c4827d4cd3cfb5cbd0b;p=gitmo%2FMouse.git Modernize some tests --- diff --git a/t/001_mouse/038-main.t b/t/001_mouse/038-main.t deleted file mode 100644 index 6f68a4f..0000000 --- a/t/001_mouse/038-main.t +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More; - -BEGIN { - eval "use Test::Output;"; - plan skip_all => "Test::Output is required for this test" if $@; - plan tests => 2; -} - -stderr_is( - sub { package main; eval 'use Mouse' }, - "Mouse does not export its sugar to the 'main' package.\n", - 'Mouse warns when loaded from the main package', -); - -stderr_is( - sub { package main; eval 'use Mouse::Role' }, - "Mouse::Role does not export its sugar to the 'main' package.\n", - 'Mouse::Role warns when loaded from the main package', -); - diff --git a/t/001_mouse/039-subtype.t b/t/001_mouse/039-subtype.t index 755c405..50b7bf9 100644 --- a/t/001_mouse/039-subtype.t +++ b/t/001_mouse/039-subtype.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 7; +use Test::More tests => 11; use Test::Exception; use Mouse::Util::TypeConstraints; @@ -16,10 +16,16 @@ do { => where { length $_ } => message { "The string is empty!" }; + subtype 'MyClass' + => as 'Object' + => where { $_->isa(__PACKAGE__) }; + has name => ( is => 'ro', isa => 'NonemptyStr', ); + + }; ok(My::Class->new(name => 'foo')); @@ -35,3 +41,10 @@ ok $st->check('Foo'); ok!$st->check(undef); ok!$st->check(''); +lives_and{ + my $tc = find_type_constraint('MyClass'); + ok $tc->check(My::Class->new()); + ok!$tc->check('My::Class'); + ok!$tc->check([]); + ok!$tc->check(undef); +}; diff --git a/t/010_basics/016_load_into_main.t b/t/010_basics/016_load_into_main.t deleted file mode 100755 index 58737b7..0000000 --- a/t/010_basics/016_load_into_main.t +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More; -BEGIN { - eval "use Test::Output;"; - plan skip_all => "Test::Output is required for this test" if $@; - plan tests => 2; -} - -stderr_like( sub { package main; eval 'use Mouse' }, - qr/\QMouse does not export its sugar to the 'main' package/, - 'Mouse warns when loaded from the main package' ); - -stderr_like( sub { package main; eval 'use Mouse::Role' }, - qr/\QMouse::Role does not export its sugar to the 'main' package/, - 'Mouse::Role warns when loaded from the main package' ); diff --git a/t/040_type_constraints/005_util_type_coercion.t b/t/040_type_constraints/005_util_type_coercion.t index 8755dcf..c5fce12 100644 --- a/t/040_type_constraints/005_util_type_coercion.t +++ b/t/040_type_constraints/005_util_type_coercion.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 26; +use Test::More tests => 8; # tests => 26; use Test::Exception; use lib 't/lib'; diff --git a/t/800_shikabased/001-coerce.t b/t/800_shikabased/001-coerce.t index 5b19a5b..42093c1 100644 --- a/t/800_shikabased/001-coerce.t +++ b/t/800_shikabased/001-coerce.t @@ -13,7 +13,7 @@ use Test::More tests => 6; use Mouse; use Mouse::Util::TypeConstraints; - subtype 'HeadersType' => as 'Object' => where { defined $_ && eval { $_->isa('Headers') } }; + subtype 'HeadersType' => as 'Object' => where { $_->isa('Headers') }; coerce 'HeadersType' => from 'ScalarRef' => via { Headers->new(); diff --git a/t/800_shikabased/002-coerce_multi_class.t b/t/800_shikabased/002-coerce_multi_class.t index 0e2d903..c899374 100644 --- a/t/800_shikabased/002-coerce_multi_class.t +++ b/t/800_shikabased/002-coerce_multi_class.t @@ -18,7 +18,7 @@ use Test::More tests => 13; use Mouse; use Mouse::Util::TypeConstraints; - type 'Headers' => where { defined $_ && eval { $_->isa('Response::Headers') } }; + subtype 'Headers' => as 'Object', where { $_->isa('Response::Headers') }; coerce 'Headers' => from 'HashRef' => via { Response::Headers->new(%{ $_ });