Permalink
Browse files

DRY demo code a little by adding to CmdProcessor::Mock

  • Loading branch information...
1 parent 53d827e commit 3317edb9f855fa7515dbcd26b5dbe43b495ba586 Rocky Bernstein committed Dec 26, 2012
@@ -101,20 +101,10 @@ sub run($$)
}
unless (caller) {
- require Devel::Trepan::CmdProcessor;
+ require Devel::Trepan::CmdProcessor::Mock;
my $proc = Devel::Trepan::CmdProcessor->new(undef, 'bogus');
my $cmd = __PACKAGE__->new($proc);
- sub create_frame() {
- my ($pkg, $file, $line, $fn) = caller(0);
- return [
- {
- file => $file,
- fn => $fn,
- line => $line,
- pkg => $pkg,
- }];
- }
- my $frame_ary = create_frame();
+ my $frame_ary = Devel::Trepan::CmdProcessor::Mock::create_frame();
$proc->frame_setup($frame_ary);
$cmd->run([$NAME]);
@@ -326,26 +326,13 @@ sub run($$)
}
unless (caller) {
- require Devel::Trepan::CmdProcessor;
+ require Devel::Trepan::CmdProcessor::Mock;
my $proc = Devel::Trepan::CmdProcessor->new(undef, 'bogus');
my $cmd = __PACKAGE__->new($proc);
require Devel::Trepan::DB::Sub;
require Devel::Trepan::DB::LineCache;
- eval {
- sub create_frame() {
- my ($pkg, $file, $line, $fn) = caller(0);
- $DB::package = $pkg;
- return [
- {
- file => $file,
- fn => $fn,
- line => $line,
- pkg => $pkg,
- }];
- }
- };
DB::LineCache::cache(__FILE__);
- my $frame_ary = create_frame();
+ my $frame_ary = Devel::Trepan::CmdProcessor::Mock::create_frame();
$proc->frame_setup($frame_ary);
$proc->{settings}{highlight} = 0;
$cmd->run([$NAME]);
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
-use strict;
+use strict; use warnings;
use Exporter;
-use warnings;
+
+use vars qw(@EXPORT @ISA); @ISA = ('Exporter');
+@EXPORT = qw(create_frame);
use rlib '../../..';
use Devel::Trepan::CmdProcessor;
@@ -15,6 +17,18 @@ sub setup() {
$proc;
}
+sub create_frame() {
+ my ($pkg, $file, $line, $fn) = caller(0);
+ return [
+ {
+ file => $file,
+ fn => $fn,
+ line => $line,
+ pkg => $pkg,
+ }];
+}
+
+
if (__FILE__ eq $0) {
my $proc=Devel::Trepan::CmdProcessor::Mock::setup;
print $proc, "\n";

0 comments on commit 3317edb

Please sign in to comment.