09_foreign.t 948 Bytes
Newer Older
1
use strict;
2
use lib ".";
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
use Test::More;
use File::Spec;
use Class::InsideOut ();

$|++; # keep stdout and stderr in order on Win32

eval { require IO::File };
if ( $@ ) {
    plan skip_all => "IO::File not installed";
}

eval { require File::Spec };
if ( $@ ) {
    plan skip_all => "File::Spec not installed";
}

plan tests => 5; 

#--------------------------------------------------------------------------#

my $class = "t::Object::Foreign";
my $filename = File::Spec->catfile( qw( t data testdata.txt ) ); 
my $o;

#--------------------------------------------------------------------------#

require_ok( $class );

ok( ($o = $class->new( $filename )) && $o->isa($class),
    "Creating a $class object"
);

ok( $o->isa( "IO::File" ),
    "Object isa IO::File"
);

my $line = <$o>;
chomp $line;
is( $line, "one",
    "Read a line from the $class object"
);

$o->name( "Larry" );
is( $o->name(), "Larry",
    "Setting a name for the object"
);