diff options
author | Tony Cook <tony@develop-help.com> | 2021-10-20 15:31:44 +1100 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2021-11-15 11:35:42 +1100 |
commit | 1e2387b573582736d884e8693e39e7ab70e6d822 (patch) | |
tree | bd7edaca33ce9e2e73ce44ae009ae64406e3361e /lib | |
parent | a85e04e2281234a61c051f8f3ff63bed7381902c (diff) | |
download | perl-1e2387b573582736d884e8693e39e7ab70e6d822.tar.gz |
allow DebugWrap to take the test code as an argument
This increases the locality of the code being tested to the test and
avoids littering the tree with little test files.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/perl5db.t | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/perl5db.t b/lib/perl5db.t index 632ff087d3..5870e06fc9 100644 --- a/lib/perl5db.t +++ b/lib/perl5db.t @@ -219,6 +219,19 @@ sub _contents return $self->{_contents}; } +# object for prog temporary file +sub _tempprog +{ + my $self = shift; + + if (@_) + { + $self->{_tempprog} = shift; + } + + return $self->{_tempprog}; +} + sub _init { my ($self, $args) = @_; @@ -233,7 +246,14 @@ sub _init my $prog = $args->{prog}; - if (ref($prog) ne '' or !defined($prog)) { + if (ref($prog) eq 'SCALAR') { + use File::Temp; + my $fh = File::Temp->new; + $self->_tempprog($fh); + print $fh $$prog; + $prog = $fh->filename; + } + elsif (ref($prog) ne '' or !defined($prog)) { die "prog should be a path to a program file."; } |