This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Extract a constructor.
authorShlomi Fish <shlomif@shlomifish.org>
Wed, 12 Sep 2012 13:29:46 +0000 (16:29 +0300)
committerRicardo Signes <rjbs@cpan.org>
Mon, 12 Nov 2012 14:18:21 +0000 (09:18 -0500)
This will help in converting the other instances to DebugWrap.

lib/perl5db.t

index 94a923e..ad92dc8 100644 (file)
@@ -393,10 +393,12 @@ package main;
     );
 }
 
+sub calc_new_var_wrapper
 {
-    local $ENV{PERLDB_OPTS} = "ReadLine=0";
-    my $target = '../lib/perl5db/t/eval-line-bug';
-    my $wrapper = DebugWrap->new(
+    my ($target, $extra_opts) = @_;
+    $extra_opts ||= '';
+    local $ENV{PERLDB_OPTS} = "ReadLine=0" . $extra_opts;
+    return DebugWrap->new(
         {
             cmds =>
             [
@@ -409,11 +411,16 @@ package main;
             prog => $target,
         }
     );
+}
 
-    $wrapper->contents_like( qr/new_var = <Foo>/,
-        "no strict 'vars' in evaluated lines.",
-    );
+{
+    calc_new_var_wrapper('../lib/perl5db/t/eval-line-bug')
+        ->contents_like(
+            qr/new_var = <Foo>/,
+            "no strict 'vars' in evaluated lines.",
+        );
 }
+
 # Testing that we can set a line in the middle of the file.
 {
     my $wrapper = DebugWrap->new(