From b68490edda877bcda983c96f728d1e04a583eb4f Mon Sep 17 00:00:00 2001 From: doy Date: Mon, 20 Apr 2009 02:58:09 -0500 Subject: clean up tests a bit --- t/000-load.t | 3 ++- t/001-basic.t | 19 ++++++++++--------- t/002-methods.t | 6 +++--- t/003-attrs.t | 8 ++++---- t/004-multi-level.t | 16 ++++++++-------- t/005-moose.t | 16 ++++++++-------- t/010-immutable.t | 12 ++++++------ t/020-BUILD.t | 10 +++++----- 8 files changed, 46 insertions(+), 44 deletions(-) (limited to 't') diff --git a/t/000-load.t b/t/000-load.t index 10c10d1..e64c67f 100644 --- a/t/000-load.t +++ b/t/000-load.t @@ -4,4 +4,5 @@ use warnings; use Test::More tests => 1; package Foo; -::use_ok 'MooseX::NonMoose' or ::BAIL_OUT "couldn't load MooseX::NonMoose"; +::use_ok('MooseX::NonMoose') + or ::BAIL_OUT("couldn't load MooseX::NonMoose"); diff --git a/t/001-basic.t b/t/001-basic.t index e905531..483ac75 100644 --- a/t/001-basic.t +++ b/t/001-basic.t @@ -18,13 +18,14 @@ extends 'Foo'; package main; my $foo = Foo->new; my $foo_moose = Foo::Moose->new; -isa_ok $foo, 'Foo'; -is $foo->{_class}, 'Foo', 'Foo gets the correct class'; -isa_ok $foo_moose, 'Foo::Moose'; -isa_ok $foo_moose, 'Foo'; -is $foo_moose->{_class}, 'Foo::Moose', 'Foo::Moose gets the correct class'; +isa_ok($foo, 'Foo'); +is($foo->{_class}, 'Foo', 'Foo gets the correct class'); +isa_ok($foo_moose, 'Foo::Moose'); +isa_ok($foo_moose, 'Foo'); +is($foo_moose->{_class}, 'Foo::Moose', 'Foo::Moose gets the correct class'); my $meta = Foo::Moose->meta; -ok $meta->has_method('new'), 'Foo::Moose has its own constructor'; -isa_ok $meta->constructor_class->meta, 'Moose::Meta::Class'; -ok $meta->constructor_class->meta->does_role('MooseX::NonMoose::Meta::Role::Constructor'), - 'Foo::Moose gets its constructor from MooseX::NonMoose'; +ok($meta->has_method('new'), 'Foo::Moose has its own constructor'); +my $cc_meta = $meta->constructor_class->meta; +isa_ok($cc_meta, 'Moose::Meta::Class'); +ok($cc_meta->does_role('MooseX::NonMoose::Meta::Role::Constructor'), + 'Foo::Moose gets its constructor from MooseX::NonMoose'); diff --git a/t/002-methods.t b/t/002-methods.t index 4ca06dc..03b8101 100644 --- a/t/002-methods.t +++ b/t/002-methods.t @@ -20,6 +20,6 @@ sub bar { 'Foo::Moose' } package main; my $foo_moose = Foo::Moose->new; -is $foo_moose->foo, 'Foo', 'Foo::Moose->foo'; -is $foo_moose->bar, 'Foo::Moose', 'Foo::Moose->bar'; -is $foo_moose->baz, 'Foo::Moose', 'Foo::Moose->baz'; +is($foo_moose->foo, 'Foo', 'Foo::Moose->foo'); +is($foo_moose->bar, 'Foo::Moose', 'Foo::Moose->bar'); +is($foo_moose->baz, 'Foo::Moose', 'Foo::Moose->baz'); diff --git a/t/003-attrs.t b/t/003-attrs.t index 2a92ab0..6b25849 100644 --- a/t/003-attrs.t +++ b/t/003-attrs.t @@ -28,9 +28,9 @@ has bar => ( package main; my $foo_moose = Foo::Moose->new(foo => 'FOO', bar => 'BAR'); -is $foo_moose->foo, 'FOO', 'foo set in constructor'; -is $foo_moose->bar, 'BAR', 'bar set in constructor'; +is($foo_moose->foo, 'FOO', 'foo set in constructor'); +is($foo_moose->bar, 'BAR', 'bar set in constructor'); $foo_moose->foo('BAZ'); $foo_moose->bar('QUUX'); -is $foo_moose->foo, 'BAZ', 'foo set by accessor'; -is $foo_moose->bar, 'QUUX', 'bar set by accessor'; +is($foo_moose->foo, 'BAZ', 'foo set by accessor'); +is($foo_moose->bar, 'QUUX', 'bar set by accessor'); diff --git a/t/004-multi-level.t b/t/004-multi-level.t index 5a2b141..8a249ea 100644 --- a/t/004-multi-level.t +++ b/t/004-multi-level.t @@ -34,22 +34,22 @@ has baz => ( package main; my $foo_moose = Foo::Moose->new; -is $foo_moose->foo, 'FOO', 'Foo::Moose::foo'; -is $foo_moose->bar, 'BAR', 'Foo::Moose::bar'; +is($foo_moose->foo, 'FOO', 'Foo::Moose::foo'); +is($foo_moose->bar, 'BAR', 'Foo::Moose::bar'); isnt(Foo::Moose->meta->get_method('new'), undef, 'Foo::Moose gets its own constructor'); my $foo_moose_sub = Foo::Moose::Sub->new; -is $foo_moose_sub->foo, 'FOO', 'Foo::Moose::Sub::foo'; -is $foo_moose_sub->bar, 'BAR', 'Foo::Moose::Sub::bar'; -is $foo_moose_sub->baz, 'BAZ', 'Foo::Moose::Sub::baz'; +is($foo_moose_sub->foo, 'FOO', 'Foo::Moose::Sub::foo'); +is($foo_moose_sub->bar, 'BAR', 'Foo::Moose::Sub::bar'); +is($foo_moose_sub->baz, 'BAZ', 'Foo::Moose::Sub::baz'); is(Foo::Moose::Sub->meta->get_method('new'), undef, 'Foo::Moose::Sub just uses the constructor for Foo::Moose'); Foo::Moose::Sub->meta->make_immutable; $foo_moose_sub = Foo::Moose::Sub->new; -is $foo_moose_sub->foo, 'FOO', 'Foo::Moose::Sub::foo (immutable)'; -is $foo_moose_sub->bar, 'BAR', 'Foo::Moose::Sub::bar (immutable)'; -is $foo_moose_sub->baz, 'BAZ', 'Foo::Moose::Sub::baz (immutable)'; +is($foo_moose_sub->foo, 'FOO', 'Foo::Moose::Sub::foo (immutable)'); +is($foo_moose_sub->bar, 'BAR', 'Foo::Moose::Sub::bar (immutable)'); +is($foo_moose_sub->baz, 'BAZ', 'Foo::Moose::Sub::baz (immutable)'); isnt(Foo::Moose::Sub->meta->get_method('new'), undef, 'Foo::Moose::Sub has an inlined constructor'); diff --git a/t/005-moose.t b/t/005-moose.t index 75f9f78..33a14b1 100644 --- a/t/005-moose.t +++ b/t/005-moose.t @@ -18,16 +18,16 @@ extends 'Foo'; package main; my $foo_sub = Foo::Sub->new; -isa_ok $foo_sub, 'Foo'; -is $foo_sub->foo, 'FOO', 'inheritance works'; +isa_ok($foo_sub, 'Foo'); +is($foo_sub->foo, 'FOO', 'inheritance works'); ok(!Foo::Sub->meta->has_method('new'), 'Foo::Sub doesn\'t have its own new method'); $_->meta->make_immutable for qw(Foo Foo::Sub); $foo_sub = Foo::Sub->new; -isa_ok $foo_sub, 'Foo'; -is $foo_sub->foo, 'FOO', 'inheritance works (immutable)'; +isa_ok($foo_sub, 'Foo'); +is($foo_sub->foo, 'FOO', 'inheritance works (immutable)'); ok(Foo::Sub->meta->has_method('new'), 'Foo::Sub has its own new method (immutable)'); @@ -38,14 +38,14 @@ extends 'Foo'; package main; my $foo_othersub = Foo::OtherSub->new; -isa_ok $foo_othersub, 'Foo'; -is $foo_othersub->foo, 'FOO', 'inheritance works (immutable when extending)'; +isa_ok($foo_othersub, 'Foo'); +is($foo_othersub->foo, 'FOO', 'inheritance works (immutable when extending)'); ok(!Foo::OtherSub->meta->has_method('new'), 'Foo::OtherSub doesn\'t have its own new method (immutable when extending)'); Foo::OtherSub->meta->make_immutable; $foo_othersub = Foo::OtherSub->new; -isa_ok $foo_othersub, 'Foo'; -is $foo_othersub->foo, 'FOO', 'inheritance works (all immutable)'; +isa_ok($foo_othersub, 'Foo'); +is($foo_othersub->foo, 'FOO', 'inheritance works (all immutable)'); ok(Foo::OtherSub->meta->has_method('new'), 'Foo::OtherSub has its own new method (all immutable)'); diff --git a/t/010-immutable.t b/t/010-immutable.t index 5ceb251..36430eb 100644 --- a/t/010-immutable.t +++ b/t/010-immutable.t @@ -33,11 +33,11 @@ __PACKAGE__->meta->make_immutable; package main; my $foo_moose = Foo::Moose->new(foo => 'FOO', bar => 'BAR'); -is $foo_moose->foo, 'FOO', 'foo set in constructor'; -is $foo_moose->bar, 'BAR', 'bar set in constructor'; +is($foo_moose->foo, 'FOO', 'foo set in constructor'); +is($foo_moose->bar, 'BAR', 'bar set in constructor'); $foo_moose->foo('BAZ'); $foo_moose->bar('QUUX'); -is $foo_moose->foo, 'BAZ', 'foo set by accessor'; -is $foo_moose->bar, 'QUUX', 'bar set by accessor'; -is $foo_moose->baz, 'Foo', 'baz method'; -is $foo_moose->quux, 'Foo::Moose', 'quux method'; +is($foo_moose->foo, 'BAZ', 'foo set by accessor'); +is($foo_moose->bar, 'QUUX', 'bar set by accessor'); +is($foo_moose->baz, 'Foo', 'baz method'); +is($foo_moose->quux, 'Foo::Moose', 'quux method'); diff --git a/t/020-BUILD.t b/t/020-BUILD.t index 8473dd3..aceff03 100644 --- a/t/020-BUILD.t +++ b/t/020-BUILD.t @@ -48,10 +48,10 @@ sub BUILD { package main; my $foo_moose = Foo::Moose->new; -is $foo_moose->class, 'Foo::Moose', 'BUILD method called properly'; -is $foo_moose->accum, 'a', 'BUILD method called properly'; +is($foo_moose->class, 'Foo::Moose', 'BUILD method called properly'); +is($foo_moose->accum, 'a', 'BUILD method called properly'); my $foo_moose_sub = Foo::Moose::Sub->new; -is $foo_moose_sub->class, 'Foo::Moose::Sub', 'parent BUILD method called'; -is $foo_moose_sub->bar, 'BAR', 'child BUILD method called'; -is $foo_moose_sub->accum, 'ab', 'BUILD methods called in the correct order'; +is($foo_moose_sub->class, 'Foo::Moose::Sub', 'parent BUILD method called'); +is($foo_moose_sub->bar, 'BAR', 'child BUILD method called'); +is($foo_moose_sub->accum, 'ab', 'BUILD methods called in the correct order'); -- cgit v1.2.3-54-g00ecf