From: Fuji, Goro Date: Sat, 25 Sep 2010 04:39:57 +0000 (+0900) Subject: Reorganize t/100_bugs/ X-Git-Tag: 0.72~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ee5e6a034b6aeaed7819138193288eb249d9380b;p=gitmo%2FMouse.git Reorganize t/100_bugs/ --- diff --git a/t/100_bugs/001_subtype_quote_bug.t b/t/100_bugs/001_subtype_quote_bug.t index 406cafa..a6827ab 100644 --- a/t/100_bugs/001_subtype_quote_bug.t +++ b/t/100_bugs/001_subtype_quote_bug.t @@ -1,9 +1,12 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 1; +use Test::More; =pod @@ -28,5 +31,9 @@ be well from now on. { package Object::Test; } -package Foo; -::use_ok('Mouse'); +{ + package Foo; + ::use_ok('Mouse'); +} + +done_testing; diff --git a/t/100_bugs/002_subtype_conflict_bug.t b/t/100_bugs/002_subtype_conflict_bug.t index 7ae2de3..21787c9 100644 --- a/t/100_bugs/002_subtype_conflict_bug.t +++ b/t/100_bugs/002_subtype_conflict_bug.t @@ -1,13 +1,16 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; use lib 't/lib', 'lib'; -use Test::More tests => 2; - - +use Test::More; use_ok('MyMouseA'); -use_ok('MyMouseB'); \ No newline at end of file +use_ok('MyMouseB'); + +done_testing; diff --git a/t/100_bugs/003_Mouse_Object_error.t b/t/100_bugs/003_Mouse_Object_error.t new file mode 100644 index 0000000..b96a5d4 --- /dev/null +++ b/t/100_bugs/003_Mouse_Object_error.t @@ -0,0 +1,15 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use lib 't/lib', 'lib'; + +use Test::More; + +use_ok('MyMouseObject'); + +done_testing; diff --git a/t/100_bugs/004_subclass_use_base_bug.t b/t/100_bugs/004_subclass_use_base_bug.t index 3ced9a4..43986f1 100644 --- a/t/100_bugs/004_subclass_use_base_bug.t +++ b/t/100_bugs/004_subclass_use_base_bug.t @@ -1,11 +1,12 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 2; - - +use Test::More; =pod @@ -28,3 +29,5 @@ a metaclass initialized for it correctly. my $bar = Bar->new; isa_ok($bar, 'Bar'); isa_ok($bar, 'Foo'); + +done_testing; diff --git a/t/100_bugs/005_inline_reader_bug.t b/t/100_bugs/005_inline_reader_bug.t index 021c3ad..e5a34d7 100644 --- a/t/100_bugs/005_inline_reader_bug.t +++ b/t/100_bugs/005_inline_reader_bug.t @@ -1,13 +1,15 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 1; +use Test::More; use Test::Exception; - =pod This was a bug, but it is fixed now. This @@ -29,3 +31,4 @@ test makes sure it does not creep back in. } '... this didnt die'; } +done_testing; diff --git a/t/100_bugs/007_reader_precedence_bug.t b/t/100_bugs/007_reader_precedence_bug.t index 0f6d608..d64c208 100644 --- a/t/100_bugs/007_reader_precedence_bug.t +++ b/t/100_bugs/007_reader_precedence_bug.t @@ -1,9 +1,12 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 3; +use Test::More; { package Foo; @@ -20,6 +23,4 @@ use Test::More tests => 3; is($foo->$reader, 10, "Reader works as expected"); } - - - +done_testing; diff --git a/t/100_bugs/009_augment_recursion_bug.t b/t/100_bugs/009_augment_recursion_bug.t index cd401d9..0633b8e 100644 --- a/t/100_bugs/009_augment_recursion_bug.t +++ b/t/100_bugs/009_augment_recursion_bug.t @@ -1,10 +1,12 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 3; - +use Test::More; { @@ -47,3 +49,4 @@ is($baz->foo, 'Foo::foo(Baz::foo and Foo::foo())', '... got the right value for 1 augmented subclass calling non-augmented subclass'); +done_testing; diff --git a/t/100_bugs/010_immutable_n_default_x2.t b/t/100_bugs/010_immutable_n_default_x2.t index 72f6493..fb9bd35 100644 --- a/t/100_bugs/010_immutable_n_default_x2.t +++ b/t/100_bugs/010_immutable_n_default_x2.t @@ -1,10 +1,12 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 2; - +use Test::More; { @@ -38,3 +40,5 @@ is($Foo::foo_default_called, 1, "foo default was only called once during constru $foo->bar(); is($Foo::bar_default_called, 1, "bar default was only called once when lazy attribute is accessed"); + +done_testing; diff --git a/t/100_bugs/011_DEMOLISH_eats_exceptions.t b/t/100_bugs/011_DEMOLISH_eats_exceptions.t index c83a2ce..3c6aefe 100644 --- a/t/100_bugs/011_DEMOLISH_eats_exceptions.t +++ b/t/100_bugs/011_DEMOLISH_eats_exceptions.t @@ -1,10 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; use FindBin; -use Test::More tests => 144; +use Test::More; use Test::Exception; use Mouse::Util::TypeConstraints; @@ -149,5 +152,4 @@ sub check_em { } } -1; - +done_testing; diff --git a/t/100_bugs/012_DEMOLISH_eats_mini.t b/t/100_bugs/012_DEMOLISH_eats_mini.t index 976275e..c8465a6 100644 --- a/t/100_bugs/012_DEMOLISH_eats_mini.t +++ b/t/100_bugs/012_DEMOLISH_eats_mini.t @@ -1,4 +1,7 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; @@ -78,30 +81,4 @@ use Test::Exception; if Baz->meta->is_mutable } -# The following tests will fail on 5.13.0, so skipt them :( -if($] >= 5.013) { - done_testing; - exit; -} - -{ - package Quux; - use Mouse; - - sub DEMOLISH { - die "foo\n"; - } -} - -{ - local $@ = 42; - - eval { my $obj = Quux->new }; - - like( $@, qr/foo/, '$@ contains error from demolish when demolish dies' ); - - Quux->meta->make_immutable, redo - if Quux->meta->is_mutable -} - done_testing; diff --git a/t/100_bugs/013_lazybuild_required_undef.t b/t/100_bugs/013_lazybuild_required_undef.t index a5377cb..d4cba48 100644 --- a/t/100_bugs/013_lazybuild_required_undef.t +++ b/t/100_bugs/013_lazybuild_required_undef.t @@ -1,7 +1,7 @@ -use strict; -use Test::More tests => 4; - package Foo; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use Mouse; ## Problem: @@ -14,12 +14,13 @@ use Mouse; #### or, make required accept undef and use a predicate test -has 'foo' => ( isa => 'Int | Undef', is => 'rw', coerce => 1, lazy_build => 1 ); -has 'bar' => ( isa => 'Int | Undef', is => 'rw', coerce => 1 ); +has 'foo' => ( isa => 'Int | Undef', is => 'rw', lazy_build => 1 ); +has 'bar' => ( isa => 'Int | Undef', is => 'rw' ); sub _build_foo { undef } package main; +use Test::More; ok ( !defined(Foo->new->bar), 'NonLazyBuild: Undef default' ); ok ( !defined(Foo->new->bar(undef)), 'NonLazyBuild: Undef explicit' ); @@ -28,3 +29,5 @@ ok ( !defined(Foo->new->foo), 'LazyBuild: Undef default/lazy_build' ); ## This test fails at the time of creation. ok ( !defined(Foo->new->foo(undef)), 'LazyBuild: Undef explicit' ); + +done_testing; diff --git a/t/100_bugs/016_inheriting_from_roles.t b/t/100_bugs/016_inheriting_from_roles.t index 269efcb..cbfde1b 100644 --- a/t/100_bugs/016_inheriting_from_roles.t +++ b/t/100_bugs/016_inheriting_from_roles.t @@ -1,13 +1,15 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 1; +use Test::More; use Test::Exception; - { package My::Role; use Mouse::Role; @@ -21,3 +23,5 @@ use Test::Exception; } qr/You cannot inherit from a Mouse Role \(My\:\:Role\)/, '... this croaks correctly'; } + +done_testing; diff --git a/t/100_bugs/017_type_constraint_messages.t b/t/100_bugs/017_type_constraint_messages.t index 4965eda..1f5776b 100644 --- a/t/100_bugs/017_type_constraint_messages.t +++ b/t/100_bugs/017_type_constraint_messages.t @@ -1,13 +1,15 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 3; +use Test::More; use Test::Exception; - # RT #37569 { @@ -71,3 +73,4 @@ throws_ok { qr/Attribute \(nt\) does not pass the type constraint because: blessed/, '... got the right error message'; +done_testing; diff --git a/t/100_bugs/019_moose_octal_defaults.t b/t/100_bugs/019_moose_octal_defaults.t index 1766946..01293fb 100644 --- a/t/100_bugs/019_moose_octal_defaults.t +++ b/t/100_bugs/019_moose_octal_defaults.t @@ -1,5 +1,8 @@ #!/usr/bin/env perl -use Test::More tests => 10; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; +use Test::More; { my $package = qq{ @@ -115,3 +118,5 @@ __PACKAGE__->meta->make_immutable; my $obj = Test::Mouse::Go::Boom5->new; ::is( $obj->id, '0 but true', 'value is still the same' ); } + +done_testing; diff --git a/t/100_bugs/020_super_recursion.t b/t/100_bugs/020_super_recursion.t index ff691f9..9b5f7d3 100644 --- a/t/100_bugs/020_super_recursion.t +++ b/t/100_bugs/020_super_recursion.t @@ -1,7 +1,10 @@ use strict; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use warnings; -use Test::More tests => 3; +use Test::More; { package A; @@ -65,3 +68,5 @@ use Test::More tests => 3; is( C->new->foo, 'c' ); is( C->new->bar, 'cb' ); is( C->new->baz, 'cba' ); + +done_testing; diff --git a/t/100_bugs/022_role_caller.t b/t/100_bugs/022_role_caller.t index 7c339f6..fc2cd94 100644 --- a/t/100_bugs/022_role_caller.t +++ b/t/100_bugs/022_role_caller.t @@ -1,6 +1,7 @@ -use Test::More tests => 4; - package MyRole; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use Mouse::Role; @@ -13,6 +14,8 @@ package MyClass2; use Mouse; with 'MyRole'; no Mouse; package main; +use Test::More; + { local $TODO = 'Role composition does not clone methods yet'; is(MyClass1->foo, 'MyClass1::foo', @@ -23,3 +26,5 @@ package main; isnt(MyClass1->foo, "MyClass2::foo", "role method is not confused with other class" ); isnt(MyClass2->foo, "MyClass1::foo", "role method is not confused with other class" ); + +done_testing; diff --git a/t/100_bugs/025_universal_methods_wrappable.t b/t/100_bugs/025_universal_methods_wrappable.t index c995172..a7507db 100644 --- a/t/100_bugs/025_universal_methods_wrappable.t +++ b/t/100_bugs/025_universal_methods_wrappable.t @@ -1,8 +1,11 @@ use strict; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use warnings; use Test::Exception; -use Test::More tests => 2; +use Test::More; { @@ -27,3 +30,5 @@ use Test::More tests => 2; my $foo = Foo->new; ::isa_ok $foo, 'Bar'; } + +done_testing; diff --git a/t/100_bugs/026_create_anon_recursion.t b/t/100_bugs/026_create_anon_recursion.t index c1f9159..c5f4562 100644 --- a/t/100_bugs/026_create_anon_recursion.t +++ b/t/100_bugs/026_create_anon_recursion.t @@ -1,7 +1,10 @@ use strict; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use warnings; -use Test::More tests => 1; +use Test::More; use Test::Exception; use Mouse::Meta::Class; @@ -10,8 +13,8 @@ $SIG{__WARN__} = sub { die if shift =~ /recurs/ }; TODO: { -# local $TODO -# = 'Loading Mouse::Meta::Class without loading Mouse.pm causes weird problems'; + local $TODO + = 'Loading Mouse::Meta::Class without loading Mouse.pm causes weird problems'; my $meta; lives_ok { @@ -21,3 +24,5 @@ TODO: } 'Class is created successfully'; } + +done_testing; diff --git a/t/100_bugs/027_constructor_object_overload.t b/t/100_bugs/027_constructor_object_overload.t index 0dfba1c..7a9a6e7 100644 --- a/t/100_bugs/027_constructor_object_overload.t +++ b/t/100_bugs/027_constructor_object_overload.t @@ -1,7 +1,10 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 1; +use Test::More; { package Foo; @@ -17,3 +20,4 @@ use Test::More tests => 1; ok(Foo->new()->bug(), 'call constructor on object reference with overloading'); +done_testing; diff --git a/t/100_bugs/029_instance_application_role_args.t b/t/100_bugs/029_instance_application_role_args.t new file mode 100644 index 0000000..c1f431b --- /dev/null +++ b/t/100_bugs/029_instance_application_role_args.t @@ -0,0 +1,55 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; +use strict; +use warnings; +use Test::More; +use Test::Exception; + +{ + package Point; + use Mouse; + + with qw/DoesNegated DoesTranspose/; + + has x => ( isa => 'Int', is => 'rw' ); + has y => ( isa => 'Int', is => 'rw' ); + + sub inspect { [$_[0]->x, $_[0]->y] } + + no Mouse; +} + +{ + package DoesNegated; + use Mouse::Role; + + sub negated { + my $self = shift; + $self->new( x => -$self->x, y => -$self->y ); + } + + no Mouse::Role; +} + +{ + package DoesTranspose; + use Mouse::Role; + + sub transpose { + my $self = shift; + $self->new( x => $self->y, y => $self->x ); + } + + no Mouse::Role; +} + +my $p = Point->new( x => 4, y => 3 ); + +DoesTranspose->meta->apply( $p, -alias => { transpose => 'negated' } ); + +is_deeply($p->negated->inspect, [3, 4]); +is_deeply($p->transpose->inspect, [3, 4]); + +done_testing; diff --git a/t/100_bugs/030_coerce_without_coercion.t b/t/100_bugs/030_coerce_without_coercion.t new file mode 100644 index 0000000..eec4424 --- /dev/null +++ b/t/100_bugs/030_coerce_without_coercion.t @@ -0,0 +1,41 @@ +use strict; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; +use warnings; + +use Test::More; +use Test::Exception; +use Test::Mouse; + +{ + package Foo; + + use Mouse::Deprecated -api_version => '1.07'; + use Mouse; + + has x => ( + is => 'rw', + isa => 'HashRef', + coerce => 1, + ); +} + +with_immutable { + lives_ok { Foo->new( x => {} ) } + 'Setting coerce => 1 without a coercion on the type does not cause an error in the constructor'; + + lives_ok { Foo->new->x( {} ) } + 'Setting coerce => 1 without a coercion on the type does not cause an error when setting the attribut'; + + throws_ok { Foo->new( x => 42 ) } + qr/\QAttribute (x) does not pass the type constraint because/, + 'Attempting to provide an invalid value to the constructor for this attr still fails'; + + throws_ok { Foo->new->x(42) } + qr/\QAttribute (x) does not pass the type constraint because/, + 'Attempting to provide an invalid value to the accessor for this attr still fails'; +} +'Foo'; + +done_testing;