in reply to Re^2: Test::MockObject::Extends and FileHandle
in thread Test::MockObject::Extends and FileHandle

I tried this. Look in the home directory afterwards for "K":
#!/usr/bin/perl use strict; use warnings; use FileHandle; use File::Tee qw(tee); use Test::MockObject::Extends; tee('STDOUT', '>>', 'stdout.txt'); my $mock= Test::MockObject::Extends->new(FileHandle->new); $mock->set_false( 'print' ); $mock->mock('FileHandle'); my $a = FileHandle->new; die "could not open" unless $a->open('>K'); die "I expect to die here" unless print {$a;} "hello"; die "I expect to be dead before we get to this point" unless $a->print("hello"); print $a;

Replies are listed 'Best First'.
Re^4: Test::MockObject::Extends and FileHandle
by SilasTheMonk (Chaplain) on Jan 23, 2010 at 14:10 UTC

    Khen1950fx,

    I downloaded your code scrap and it was definitely a completely unfaked FileHandle. Also what is the point of the File::Tee stuff? Surely that just complicates things.