From: gfx Date: Mon, 11 Jan 2010 06:47:27 +0000 (+0900) Subject: Merge default-code.t to default.t X-Git-Tag: 0.47~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cc368f690a94e2bae71df46f5e956ef86702be55;p=gitmo%2FMouse.git Merge default-code.t to default.t --- diff --git a/t/001_mouse/008-default.t b/t/001_mouse/008-default.t index f77d01b..900fc69 100644 --- a/t/001_mouse/008-default.t +++ b/t/001_mouse/008-default.t @@ -2,6 +2,7 @@ use strict; use warnings; use Test::More tests => 36; +use Test::Mouse; do { package Class; @@ -14,7 +15,7 @@ do { has 'y' => ( is => 'rw', - default => 20, + default => sub{ 20 }, ); has 'z' => ( @@ -22,7 +23,7 @@ do { ); }; -for(1 .. 2){ +with_immutable(sub{ my $object = Class->new; is($object->x, 10, "attribute has a default of 10"); is($object->y, 20, "attribute has a default of 20"); @@ -49,5 +50,4 @@ for(1 .. 2){ is($object2->y, 25, "setting a new value does not trigger default"); is($object2->z, 125, "setting a new value does not trigger default"); - Class->meta->make_immutable; -} +}, qw(Class)); diff --git a/t/001_mouse/009-default-code.t b/t/001_mouse/009-default-code.t deleted file mode 100644 index 9693afb..0000000 --- a/t/001_mouse/009-default-code.t +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More tests => 9; - -do { - package Class; - use Mouse; - - has 'x' => ( - is => 'rw', - default => sub { 10 }, - ); - - has 'y' => ( - is => 'rw', - default => sub { 20 }, - ); - - has 'z' => ( - is => 'rw', - ); -}; - -my $object = Class->new; -is($object->x, 10, "attribute has a default of 10"); -is($object->y, 20, "attribute has a default of 20"); -is($object->z, undef, "attribute has no default"); - -is($object->x(5), 5, "setting a new value"); -is($object->y(25), 25, "setting a new value"); -is($object->z(125), 125, "setting a new value"); - -is($object->x, 5, "setting a new value does not trigger default"); -is($object->y, 25, "setting a new value does not trigger default"); -is($object->z, 125, "setting a new value does not trigger default"); -