summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-05-07 23:23:53 -0500
committerJesse Luehrs <doy@tozt.net>2009-05-07 23:23:53 -0500
commit02de7898f135026608eb566fb0114cb6bbf76803 (patch)
treeea8a2a25a6b135c9a911018770eed87abcab11dd /t
parent4fc4b9385dc28ad99559bc3b938594eedd4f3a21 (diff)
downloadmoosex-nonmoose-02de7898f135026608eb566fb0114cb6bbf76803.tar.gz
moosex-nonmoose-02de7898f135026608eb566fb0114cb6bbf76803.zip
expand the mx-globref test a bit more
Diffstat (limited to 't')
-rw-r--r--t/033-moosex-globref.t52
1 files changed, 51 insertions, 1 deletions
diff --git a/t/033-moosex-globref.t b/t/033-moosex-globref.t
index 9c20893..6a8b4f6 100644
--- a/t/033-moosex-globref.t
+++ b/t/033-moosex-globref.t
@@ -5,8 +5,12 @@ use Test::More;
BEGIN {
eval "use MooseX::GlobRef ()";
plan skip_all => "MooseX::GlobRef is required for this test" if $@;
- plan tests => 2;
+ plan tests => 10;
}
+# XXX: the way the IO modules are loaded means we can't just rely on cmop to
+# load these properly/:
+use IO::Handle;
+use IO::File;
BEGIN {
require Moose;
@@ -42,8 +46,54 @@ has bar => (
sub FOREIGNBUILDARGS { return }
+package IO::File::Moose;
+BEGIN { Foo::Exporter->import }
+extends 'IO::File';
+
+has baz => (
+ is => 'rw',
+ isa => 'Str',
+);
+
+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", 4;
+ 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", 4;
+ 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");
+}