From dfc2ff5f2709f198d9fdb21d84a2534acc9f3670 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 15 Jun 2010 03:39:08 -0500 Subject: make more tests use with_immutable --- t/33-moosex-globref.t | 62 ++++++++++++++++++++------------------------------- 1 file changed, 24 insertions(+), 38 deletions(-) (limited to 't/33-moosex-globref.t') diff --git a/t/33-moosex-globref.t b/t/33-moosex-globref.t index be8c26b..3f59e39 100644 --- a/t/33-moosex-globref.t +++ b/t/33-moosex-globref.t @@ -2,6 +2,7 @@ use strict; use warnings; use Test::More; +use Test::Moose; BEGIN { eval "use MooseX::GlobRef ()"; plan skip_all => "MooseX::GlobRef is required for this test" if $@; @@ -58,42 +59,27 @@ has baz => ( sub FOREIGNBUILDARGS { return } package main; -my $handle = IO::Handle::Moose->new(bar => 'BAR'); -is($handle->bar, 'BAR', 'moose accessor works properly'); -$handle->bar('RAB'); -is($handle->bar, 'RAB', 'moose accessor works properly (setting)'); -IO::Handle::Moose->meta->make_immutable; -$handle = IO::Handle::Moose->new(bar => 'BAR'); -is($handle->bar, 'BAR', 'moose accessor works properly'); -$handle->bar('RAB'); -is($handle->bar, 'RAB', 'moose accessor works properly (setting)'); -SKIP: { - my $fh = IO::File::Moose->new(baz => 'BAZ'); - open $fh, "+>", undef - or skip "couldn't open a temporary file", 3; - is($fh->baz, 'BAZ', "accessor works"); - $fh->baz('ZAB'); - is($fh->baz, 'ZAB', "accessor works (writing)"); - $fh->print("foo\n"); - print $fh "bar\n"; - $fh->seek(0, 0); - my $buf; - $fh->read($buf, 8); - is($buf, "foo\nbar\n", "filehandle still works as normal"); -} -IO::File::Moose->meta->make_immutable; -SKIP: { - my $fh = IO::File::Moose->new(baz => 'BAZ'); - open $fh, "+>", undef - or skip "couldn't open a temporary file", 3; - is($fh->baz, 'BAZ', "accessor works"); - $fh->baz('ZAB'); - is($fh->baz, 'ZAB', "accessor works (writing)"); - $fh->print("foo\n"); - print $fh "bar\n"; - $fh->seek(0, 0); - my $buf; - $fh->read($buf, 8); - is($buf, "foo\nbar\n", "filehandle still works as normal"); -} +with_immutable { + my $handle = IO::Handle::Moose->new(bar => 'BAR'); + is($handle->bar, 'BAR', 'moose accessor works properly'); + $handle->bar('RAB'); + is($handle->bar, 'RAB', 'moose accessor works properly (setting)'); +} 'IO::Handle::Moose'; + +with_immutable { + SKIP: { + my $fh = IO::File::Moose->new(baz => 'BAZ'); + open $fh, "+>", undef + or skip "couldn't open a temporary file", 3; + is($fh->baz, 'BAZ', "accessor works"); + $fh->baz('ZAB'); + is($fh->baz, 'ZAB', "accessor works (writing)"); + $fh->print("foo\n"); + print $fh "bar\n"; + $fh->seek(0, 0); + my $buf; + $fh->read($buf, 8); + is($buf, "foo\nbar\n", "filehandle still works as normal"); + } +} 'IO::File::Moose'; -- cgit v1.2.3-54-g00ecf