Skip to content
This repository

Various cleanups #3

Closed
wants to merge 20 commits into from

2 participants

Shlomi Fish R. Bernstein
Shlomi Fish

Hi Rocky,

Please pull the changes here that include various cleanups like "use English qw( -no_match_vars)" , strict and warnings on separate lines, a refactoring of t/Helper.pm etc.

Note that it doesn't contain the fix for the ReadLine loading / t/20*.t tests failing on my system which is on a different branch.

Regards,

-- Shlomi Fish

added some commits October 26, 2011
Shlomi Fish Made Build.PL non-executable and sha-bang-less. 959bf27
Shlomi Fish Fix the Psh required ver to three-dots.
The Psh required version was warned when given 1.8.1 which is more
recent than "1.8" (or 1.8.0). So it was fixed here.
dbf98a7
Shlomi Fish Remove a warning with recent perls.
Deprecated using qw(...) directly as a list.
d877a95
Shlomi Fish Merge https://github.com/rocky/Perl-Devel-Trepan 9597cfe
Shlomi Fish Cleaned up the use statements in t/Helper.pm.
Removed duplicate ones, those that are both on the same line, etc.
bd52240
Shlomi Fish More loading cleanups.
Moved some use/require to the top.
b0d2ec3
Shlomi Fish Add -no_match_vars to use English.
This makes it faster.
ee83ecb
Shlomi Fish Add -no_match_vars to use English statements.
This is faster and more recommended (see perldoc English).
b64ddf6
Shlomi Fish Started cleaning up t/Helper.pm. 7956382
Shlomi Fish More Helper.pm cleanup.
Broke a line and removed an unneeded one.
a3fef16
Shlomi Fish Extract a closure. 3dc282c
Shlomi Fish More cleanups to Helper.pm. fdcff91
Shlomi Fish "file" in identifiers to "fn". aa3ee3b
Shlomi Fish Add a blurb for the is. 5afbebf
Shlomi Fish Add an explicit return. 9abc556
Shlomi Fish Reorganized the strict and warnings. 0e0c7bb
Shlomi Fish More strict and warnings cleanup. 4894b10
Shlomi Fish Separate lines for strict/warnings. 0b790fe
Shlomi Fish use statements cleanup. 449b0f8
Shlomi Fish Got rid of strict and warnings in the same line.
Cleaned up the loaded pragmas otherwise.
6f49cae
R. Bernstein
Owner

I really think this kind of change is really silly, if not bad. I string the lines across because basically each of the lines is boilerplate and I'd like to skip over all of it as much as possible. Computer displays tend to be limited in line length more than they are in column length.

Are Perl experts so rigid that one can't tolerate different styles?

rocky:

Well, this is the first time I've seen such putting several "use" statements on the same line. It has given me a "WTF?" moment, and I found it hard to read. Furthermore, your boilerplat is a little different every time, and I also moved package statements right at the top, which is important.

If you're so keen on keeping them out of the way, you can configure your text editor to fold these lines out of the way:

http://vim.wikia.com/wiki/Folding

(This is for Vim - other decent editors should have similar features.).

Owner

Is this so hard to read?

    $x = 1;  $y = 2; $z = 3; 

that you go around splitting this on several lines? And if it is

     $x = $y = $z = 0;

do you write that as:

     $x = 
     $y = 
     $z = 0;

? Or split this into 3 separate assignment statements?

Do you try to line up the = sign in:

    $first  = 1;
    $second  = 2;
    $third = 3;

?

because this is easier to read? I guess part of the point I am trying to make is that I doubt that just putting stuff on more lines in of itself makes things readable.

The thing about style is it is largely a matter of what one is used to. At one time I preferred indentation to be two spaces because again it is the minimum amount that gets the point across clearly. In some programming languages folks want 2 spaces, in some 4, and in some something different. After a while, I found I could just get used to any. So although I could get used to the multiple line thing, I think it silly and sad I can't write in the way I find the most logical and suits me the best.

When I say boilerplate, part of what I mean is that this stuff is uninteresting. Uninteresting to the point that if you totally skipped those lines and never read them, it wouldn't impact one iota the essentials of the program - the organization of classes, the algorithms, the fundamentals of what this program does and so on.

I know how to elide blocks of code, and I don't see a need to customize my Editor to elide this stuff. I want to write code in this way. The fact that you haven't seen it doesn't in of itself mean that this is a bad thing to do. Try it and live with it for a bit. If after trying it you can elucidate why it is so hard to read and why it is so important for you to be able read this, then let's discuss.

Also sad to me is that were spending this amount of time over things like this rather than:

  • adding watchpoints
  • adding out-of-process debugging
  • adding signal handlers like gdb's "handle" command
  • figuring out how to remove the globalness of the debugger to allow say profiing and debugging to be totally independent
  • finishing and removing some of the weirdnesses of tab ReadLine completion

These to me are the more important issues.

Owner

One other thing I had meant to mention. You said that the boilerplate is different and that puts you off. In some cases I have "strict" before "warnings" and some the other way around. But when you split into several lines, you kept this irregularity in some cases. But again, I think this is all irrelevant; if you are spending time looking at this stuff and making sure strict comes before warnings (or vice versa) then I think you are concerned with the parts of the program that are the least important.

By different boilerplate, I did not mean "strict" before "warnings" or vice-versa (which makes little difference). Instead, I meant stuff like "no warnings $something" which are also there sometimes (and are placed on the same line).

In any case, I'm likely to run into such style issues first when starting to work on your code, and it will likely give other Perl developers besides me some "WTF?" moments. I've introduced some more meaningful changes like the "use English qw( -no_match_vars ) ;" cleanup and the t/Helper.pm cleanup, and I'm still waiting for input on why there are so many "use lib '../../../'" statements in the code (which like I said might prove to be a security breach).

R. Bernstein
Owner

Reine Urban later noticed this and issued a separate pull request. So this has been encorporated now.

R. Bernstein
Owner

This change has been encorporated.

R. Bernstein
Owner

requires has been moved up. There is now a Helper package so the "use English" has to come after that.

R. Bernstein
Owner

Change incorporated. Thanks.

R. Bernstein
Owner

Applied with slight change.

R. Bernstein
Owner

Applied.

R. Bernstein
Owner

Applied. Thanks.

R. Bernstein
Owner

Applied.

R. Bernstein
Owner

Most of this seems dubious.

R. Bernstein
Owner

I don't like fn since it reminds me of function. So using filename is a compromise. With this caveat, applied.

R. Bernstein
Owner

I think I have all of the important changes merged in. Some things I disagree with as noted before. If there's anything you feel missing, let me know.

Thanks for the help.

R. Bernstein rocky closed this November 03, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 20 unique commits by 1 author.

Oct 26, 2011
Shlomi Fish Made Build.PL non-executable and sha-bang-less. 959bf27
Shlomi Fish Fix the Psh required ver to three-dots.
The Psh required version was warned when given 1.8.1 which is more
recent than "1.8" (or 1.8.0). So it was fixed here.
dbf98a7
Oct 29, 2011
Shlomi Fish Remove a warning with recent perls.
Deprecated using qw(...) directly as a list.
d877a95
Shlomi Fish Merge https://github.com/rocky/Perl-Devel-Trepan 9597cfe
Oct 30, 2011
Shlomi Fish Cleaned up the use statements in t/Helper.pm.
Removed duplicate ones, those that are both on the same line, etc.
bd52240
Shlomi Fish More loading cleanups.
Moved some use/require to the top.
b0d2ec3
Shlomi Fish Add -no_match_vars to use English.
This makes it faster.
ee83ecb
Shlomi Fish Add -no_match_vars to use English statements.
This is faster and more recommended (see perldoc English).
b64ddf6
Shlomi Fish Started cleaning up t/Helper.pm. 7956382
Shlomi Fish More Helper.pm cleanup.
Broke a line and removed an unneeded one.
a3fef16
Shlomi Fish Extract a closure. 3dc282c
Shlomi Fish More cleanups to Helper.pm. fdcff91
Shlomi Fish "file" in identifiers to "fn". aa3ee3b
Shlomi Fish Add a blurb for the is. 5afbebf
Shlomi Fish Add an explicit return. 9abc556
Shlomi Fish Reorganized the strict and warnings. 0e0c7bb
Shlomi Fish More strict and warnings cleanup. 4894b10
Shlomi Fish Separate lines for strict/warnings. 0b790fe
Oct 31, 2011
Shlomi Fish use statements cleanup. 449b0f8
Shlomi Fish Got rid of strict and warnings in the same line.
Cleaned up the loaded pragmas otherwise.
6f49cae
This page is out of date. Refresh to see the latest.

Showing 51 changed files with 303 additions and 120 deletions. Show diff stats Hide diff stats

  1. 4  bin/trepanpl
  2. 14  lib/Devel/Trepan/BrkptMgr.pm
  3. 21  lib/Devel/Trepan/CmdProcessor.pm
  4. 2  lib/Devel/Trepan/CmdProcessor/Command/Action.pm
  5. 2  lib/Devel/Trepan/CmdProcessor/Command/Break.pm
  6. 2  lib/Devel/Trepan/CmdProcessor/Command/Condition.pm
  7. 2  lib/Devel/Trepan/CmdProcessor/Command/Delete.pm
  8. 2  lib/Devel/Trepan/CmdProcessor/Command/Display.pm
  9. 2  lib/Devel/Trepan/CmdProcessor/Command/List.pm
  10. 2  lib/Devel/Trepan/CmdProcessor/Command/Macro.pm
  11. 2  lib/Devel/Trepan/CmdProcessor/Command/Restart.pm
  12. 2  lib/Devel/Trepan/CmdProcessor/Command/Undisplay.pm
  13. 11  lib/Devel/Trepan/CmdProcessor/Frame.pm
  14. 8  lib/Devel/Trepan/CmdProcessor/Hook.pm
  15. 2  lib/Devel/Trepan/CmdProcessor/Location.pm
  16. 11  lib/Devel/Trepan/CmdProcessor/Running.pm
  17. 11  lib/Devel/Trepan/CmdProcessor/Validate.pm
  18. 8  lib/Devel/Trepan/Condition.pm
  19. 6  lib/Devel/Trepan/DB.pm
  20. 2  lib/Devel/Trepan/DB/Backtrace.pm
  21. 9  lib/Devel/Trepan/DB/Breakpoint.pm
  22. 9  lib/Devel/Trepan/DB/Display.pm
  23. 11  lib/Devel/Trepan/DB/Eval.pm
  24. 15  lib/Devel/Trepan/DB/LineCache.pm
  25. 2  lib/Devel/Trepan/DB/Sub.pm
  26. 8  lib/Devel/Trepan/IO.pm
  27. 6  lib/Devel/Trepan/IO/Input.pm
  28. 5  lib/Devel/Trepan/IO/StringArray.pm
  29. 8  lib/Devel/Trepan/Interface/Script.pm
  30. 9  lib/Devel/Trepan/Interface/User.pm
  31. 3  lib/Devel/Trepan/Position.pm
  32. 9  lib/Devel/Trepan/Util.pm
  33. 2  t/10test-db-brkpt.t
  34. 7  t/10test-intf-user.t
  35. 8  t/10test-linecache.t
  36. 6  t/10test-options.t
  37. 7  t/10test-proc-hook.t
  38. 8  t/10test-proc-load.t
  39. 8  t/20test-autolist.t
  40. 5  t/20test-break.t
  41. 5  t/20test-display.t
  42. 8  t/20test-eval.t
  43. 5  t/20test-list1.t
  44. 5  t/20test-list2.t
  45. 5  t/20test-list3.t
  46. 5  t/20test-next.t
  47. 5  t/20test-seq1.t
  48. 8  t/20test-step.t
  49. 5  t/20test-trace.t
  50. 7  t/20test-trepanpl-opts.t
  51. 104  t/Helper.pm
4  bin/trepanpl
@@ -2,7 +2,9 @@
2 2
 # Standalone routine to invoke a Perl program under the debugger.
3 3
 
4 4
 # The usual boilerplate...
5  
-use strict; use warnings; use English;
  5
+use strict;
  6
+use warnings;
  7
+use English qw( -no_match_vars );
6 8
 
7 9
 use File::Basename; use File::Spec;
8 10
 
14  lib/Devel/Trepan/BrkptMgr.pm
... ...
@@ -1,10 +1,18 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3  
-use strict; use warnings; no warnings 'redefine';
4  
-use English;
  3
+
  4
+package Devel::Trepan::BrkptMgr;
  5
+
  6
+use strict;
  7
+use warnings;
  8
+no warnings 'redefine';
  9
+
  10
+use English qw( -no_match_vars );
  11
+
  12
+# TODO : What is the meaning of this use lib? Can it be removed?
5 13
 use lib '../..';
  14
+
6 15
 use Devel::Trepan::DB::Breakpoint;
7  
-package Devel::Trepan::BrkptMgr;
8 16
 
9 17
 sub new($$) 
10 18
 {
21  lib/Devel/Trepan/CmdProcessor.pm
... ...
@@ -1,13 +1,23 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org> 
  3
+package Devel::Trepan::CmdProcessor;
  4
+
  5
+use strict;
  6
+use warnings;
  7
+no warnings 'redefine';
  8
+
3 9
 use feature ":5.10";  # Includes "state" feature.
4  
-use Exporter;
5 10
 use feature 'switch';
6  
-use warnings; use strict;
  11
+
  12
+use English qw( -no_match_vars );
  13
+
  14
+use Exporter;
7 15
 
8 16
 # Showing eval results can be done using either data dump package.
9  
-require Data::Dumper; require Data::Dumper::Perltidy;
  17
+require Data::Dumper;
  18
+require Data::Dumper::Perltidy;
10 19
 
  20
+# TODO : Shouldn't this use lib be removed?
11 21
 use lib '../..';
12 22
 require Devel::Trepan::BrkptMgr;
13 23
 require Devel::Trepan::DB::Display;
@@ -23,12 +33,7 @@ require Devel::Trepan::CmdProcessor::Load unless
23 33
     defined $Devel::Trepan::CmdProcessor::Load_seen;
24 34
 require Devel::Trepan::CmdProcessor::Running;
25 35
 require Devel::Trepan::CmdProcessor::Validate;
26  
-use strict;
27  
-use warnings;
28  
-no warnings 'redefine';
29 36
 
30  
-package Devel::Trepan::CmdProcessor;
31  
-use English;
32 37
 use Devel::Trepan::Util qw(hash_merge uniq_abbrev);
33 38
 
34 39
 use vars qw(@EXPORT @ISA $eval_result);
2  lib/Devel/Trepan/CmdProcessor/Command/Action.pm
@@ -4,7 +4,7 @@ use warnings; no warnings 'redefine';
4 4
 use lib '../../../..';
5 5
 
6 6
 package Devel::Trepan::CmdProcessor::Command::Action;
7  
-use English;
  7
+use English qw( -no_match_vars );
8 8
 
9 9
 use if !defined @ISA, Devel::Trepan::Condition ;
10 10
 use if !defined @ISA, Devel::Trepan::CmdProcessor::Command ;
2  lib/Devel/Trepan/CmdProcessor/Command/Break.pm
@@ -6,7 +6,7 @@ use lib '../../../..';
6 6
 # require_relative '../../app/condition'
7 7
 
8 8
 package Devel::Trepan::CmdProcessor::Command::Break;
9  
-use English;
  9
+use English qw( -no_match_vars );
10 10
 use if !defined @ISA, Devel::Trepan::CmdProcessor::Command;
11 11
 unless (defined(@ISA)) {
12 12
     eval "use constant ALIASES    => qw(b);";
2  lib/Devel/Trepan/CmdProcessor/Command/Condition.pm
@@ -4,7 +4,7 @@ use warnings; no warnings 'redefine';
4 4
 use lib '../../../..';
5 5
 
6 6
 package Devel::Trepan::CmdProcessor::Command::Condition;
7  
-use English;
  7
+use English qw( -no_match_vars );
8 8
 
9 9
 use if !defined @ISA, Devel::Trepan::Condition ;
10 10
 use if !defined @ISA, Devel::Trepan::CmdProcessor::Command ;
2  lib/Devel/Trepan/CmdProcessor/Command/Delete.pm
@@ -4,7 +4,7 @@ use warnings; no warnings 'redefine';
4 4
 use lib '../../../..';
5 5
 
6 6
 package Devel::Trepan::CmdProcessor::Command::Delete;
7  
-use English;
  7
+use English qw( -no_match_vars );
8 8
 
9 9
 use if !defined @ISA, Devel::Trepan::CmdProcessor::Command ;
10 10
 
2  lib/Devel/Trepan/CmdProcessor/Command/Display.pm
@@ -4,7 +4,7 @@ use warnings; no warnings 'redefine';
4 4
 use lib '../../../..';
5 5
 
6 6
 package Devel::Trepan::CmdProcessor::Command::Display;
7  
-use English;
  7
+use English qw( -no_match_vars );
8 8
 
9 9
 use if !defined @ISA, Devel::Trepan::DB::Display ;
10 10
 use if !defined @ISA, Devel::Trepan::Condition ;
2  lib/Devel/Trepan/CmdProcessor/Command/List.pm
@@ -6,7 +6,7 @@ use lib '../../../..';
6 6
 # require_relative '../../app/condition'
7 7
 
8 8
 package Devel::Trepan::CmdProcessor::Command::List;
9  
-use English;
  9
+use English qw( -no_match_vars );
10 10
 use Devel::Trepan::DB::LineCache;
11 11
 use Devel::Trepan::CmdProcessor::Validate;
12 12
 use if !defined @ISA, Devel::Trepan::CmdProcessor::Command;
2  lib/Devel/Trepan/CmdProcessor/Command/Macro.pm
@@ -5,7 +5,7 @@ use warnings; no warnings 'redefine';
5 5
 use lib '../../../..';
6 6
 
7 7
 package Devel::Trepan::CmdProcessor::Command::Macro;
8  
-use English;
  8
+use English qw( -no_match_vars );
9 9
 use if !defined @ISA, Devel::Trepan::CmdProcessor::Command ;
10 10
 unless (defined(@ISA)) {
11 11
     eval "use constant CATEGORY   => 'support';";
2  lib/Devel/Trepan/CmdProcessor/Command/Restart.pm
@@ -5,7 +5,7 @@ use warnings; no warnings 'redefine';
5 5
 use lib '../../../..';
6 6
 
7 7
 package Devel::Trepan::CmdProcessor::Command::Restart;
8  
-use English;
  8
+use English qw( -no_match_vars );
9 9
 
10 10
 use if !defined @ISA, Devel::Trepan::CmdProcessor::Command ;
11 11
 unless (defined(@ISA)) {
2  lib/Devel/Trepan/CmdProcessor/Command/Undisplay.pm
@@ -4,7 +4,7 @@ use warnings; no warnings 'redefine';
4 4
 use lib '../../../..';
5 5
 
6 6
 package Devel::Trepan::CmdProcessor::Command::Undisplay;
7  
-use English;
  7
+use English qw( -no_match_vars );
8 8
 
9 9
 use if !defined @ISA, Devel::Trepan::CmdProcessor::Command ;
10 10
 
11  lib/Devel/Trepan/CmdProcessor/Frame.pm
... ...
@@ -1,12 +1,17 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org> 
3  
-use strict; use warnings;
  3
+
  4
+package Devel::Trepan::CmdProcessor;
  5
+
  6
+use strict; 
  7
+use warnings;
  8
+
  9
+# TODO : I don't think this use lib is a good idea.
4 10
 use lib '../../..';
5 11
 use Devel::Trepan::DB::Sub;
6 12
 use Devel::Trepan::Complete;
7 13
 
8  
-package Devel::Trepan::CmdProcessor;
9  
-use English;
  14
+use English qw( -no_match_vars );
10 15
 
11 16
 sub adjust_frame($$$)
12 17
 {
8  lib/Devel/Trepan/CmdProcessor/Hook.pm
... ...
@@ -1,6 +1,11 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org> 
3  
-use strict; use warnings;
  3
+package Devel::Trepan::CmdProcessor::Hook;
  4
+
  5
+use strict; 
  6
+use warnings;
  7
+
  8
+# TODO : I don't think this lib is a good idea.
4 9
 use lib '../../..';
5 10
 
6 11
 use Class::Struct;
@@ -13,7 +18,6 @@ struct CmdProcessorHook => {
13 18
 };
14 19
 
15 20
 
16  
-package Devel::Trepan::CmdProcessor::Hook;
17 21
 #  attr_accessor :list
18 22
 
19 23
 sub new($;$)
2  lib/Devel/Trepan/CmdProcessor/Location.pm
@@ -7,7 +7,7 @@ use lib '../../..';
7 7
 # require_relative '../app/default'
8 8
 
9 9
 package Devel::Trepan::CmdProcessor;
10  
-use English;
  10
+use English qw( -no_match_vars );
11 11
 use Cwd 'abs_path';
12 12
 
13 13
 use File::Basename;
11  lib/Devel/Trepan/CmdProcessor/Running.pm
... ...
@@ -1,15 +1,16 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org> 
3  
-use strict; use warnings;
  3
+package Devel::Trepan::CmdProcessor;
4 4
 
  5
+use strict;
  6
+use warnings;
5 7
 use feature 'switch';
  8
+
  9
+# TODO : I don't think this use lib is a good idea.
6 10
 use lib '../../..';
7 11
 
8 12
 use Devel::Trepan::Position;
9  
-package Devel::Trepan::CmdProcessor;
10  
-use English;
11  
-
12  
-
  13
+use English qw( -no_match_vars );
13 14
 
14 15
 # attr_accessor :stop_condition  # String or nil. When not nil
15 16
 #                                # this has to eval non-nil
11  lib/Devel/Trepan/CmdProcessor/Validate.pm
@@ -3,13 +3,16 @@
3 3
 # Trepan command input validation routines.  A String type is
4 4
 # usually passed in as the argument to validation routines.
5 5
 
6  
-use strict; use warnings;
7  
-use Exporter;
  6
+package Devel::Trepan::CmdProcessor;
8 7
 
  8
+use strict; 
  9
+use warnings;
9 10
 use feature 'switch';
10  
-use lib '../../..';
11 11
 
12  
-package Devel::Trepan::CmdProcessor;
  12
+use Exporter;
  13
+
  14
+# TODO : I don't think this use lib is a good idea.
  15
+use lib '../../..';
13 16
 
14 17
 use Cwd 'abs_path';
15 18
 use Devel::Trepan::DB::Breakpoint;
8  lib/Devel/Trepan/Condition.pm
... ...
@@ -1,8 +1,12 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org>
3  
-use strict; use warnings;
  3
+
4 4
 package Devel::Trepan::Condition;
5  
-use English;
  5
+
  6
+use strict;
  7
+use warnings;
  8
+use English qw( -no_match_vars );
  9
+
6 10
 use vars qw(@EXPORT @ISA);
7 11
 @EXPORT    = qw( is_valid_condition );
8 12
 @ISA = qw(Exporter);
6  lib/Devel/Trepan/DB.pm
@@ -9,7 +9,7 @@ use lib '../..';
9 9
 package DB;
10 10
 use feature 'switch';
11 11
 use warnings; no warnings 'redefine';
12  
-use English;
  12
+use English qw( -no_match_vars );
13 13
 
14 14
 use vars qw($usrctxt $running $caller 
15 15
             $event @ret $ret $return_value @return_value
@@ -87,11 +87,11 @@ BEGIN {
87 87
 	require threads;
88 88
 	require threads::shared;
89 89
 	import threads::shared qw(share);
90  
-	no strict; no warnings;
  90
+	no strict;
  91
+    no warnings;
91 92
 	$DBGR;
92 93
 	share(\$DBGR);
93 94
 	lock($DBGR);
94  
-	use strict; use warnings;
95 95
 	print "Thread support enabled\n";
96 96
     } else {
97 97
 	*lock  = sub(*) {};
2  lib/Devel/Trepan/DB/Backtrace.pm
... ...
@@ -1,6 +1,6 @@
1 1
 package DB;
2 2
 use warnings; no warnings 'redefine';
3  
-use English;
  3
+use English qw( -no_match_vars );
4 4
 
5 5
 =head2 backtrace(skip[,count,scan_for_DB])
6 6
 
9  lib/Devel/Trepan/DB/Breakpoint.pm
@@ -39,9 +39,14 @@ sub icon_char($)
39 39
 }
40 40
 
41 41
 package DB;
  42
+
42 43
 use vars qw($brkpt $package $lineno $max_bp $max_action);
43  
-use strict; use warnings; no warnings 'redefine';
44  
-use English;
  44
+
  45
+use strict;
  46
+use warnings;
  47
+no warnings 'redefine';
  48
+
  49
+use English qw( -no_match_vars );
45 50
 
46 51
 BEGIN {
47 52
     $DB::brkpt   = undef; # current breakpoint
9  lib/Devel/Trepan/DB/Display.pm
... ...
@@ -1,12 +1,15 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3 3
 # FIXME: Could combine manager code from breakpoints and display
4  
-use strict; use warnings; no warnings 'redefine';
5  
-use English;
  4
+
  5
+use strict;
  6
+use warnings;
  7
+no warnings 'redefine';
  8
+
  9
+use English qw( -no_match_vars );
6 10
 use lib '../..';
7 11
 
8 12
 use Class::Struct;
9  
-use strict;
10 13
 
11 14
 struct DBDisplay => {
12 15
     number      => '$', # breakpoint/action number 
11  lib/Devel/Trepan/DB/Eval.pm
... ...
@@ -1,11 +1,15 @@
1 1
 # Eval part of Perl's Core DB.pm library and perl5db.pl with modification.
2 2
 
  3
+# TODO : Shouldn't this use lib be removed?
3 4
 use lib '../..';
4 5
 
5 6
 package DB;
6  
-use warnings; use strict;
7  
-use English;
  7
+
  8
+use warnings;
  9
+use strict;
8 10
 use feature 'switch';
  11
+
  12
+use English qw( -no_match_vars );
9 13
 use vars qw($eval_result @eval_result %eval_result
10 14
             $eval_str $eval_opts $event $return_type );
11 15
 
@@ -30,7 +34,8 @@ sub eval {
30 34
      $OUTPUT_FIELD_SEPARATOR, 
31 35
      $INPUT_RECORD_SEPARATOR, 
32 36
      $OUTPUT_RECORD_SEPARATOR, $WARNING) = @saved;
33  
-    no strict; no warnings;
  37
+    no strict;
  38
+    no warnings;
34 39
     eval "$user_context $eval_str; &DB::save\n"; # '\n' for nice recursive debug
35 40
     _warnall($@) if $@;
36 41
 }
15  lib/Devel/Trepan/DB/LineCache.pm
@@ -39,11 +39,14 @@ use version; $VERSION = '0.1.0';
39 39
 
40 40
 # A package to read and cache lines of a Perl program. 
41 41
 package DB::LineCache;
42  
-use English;
43  
-use strict; use warnings;
  42
+
  43
+use strict;
  44
+use warnings;
44 45
 no warnings 'once';
45 46
 no warnings 'redefine';
46 47
 
  48
+use English qw( -no_match_vars );
  49
+
47 50
 use Cwd 'abs_path';
48 51
 use File::Basename;
49 52
 use File::Spec;
@@ -562,12 +565,14 @@ sub update_cache($;$)
562 565
 	    $lines_href->{plain} = $raw_lines;
563 566
 	    if ($opts->{output} && defined($raw_lines)) {
564 567
 		# Some lines in $raw_lines may be undefined
565  
-		no strict; no warnings;
  568
+		no strict;
  569
+        no warnings;
566 570
 		local $WARNING=0;
567 571
 		my $highlight_lines = highlight_string(join('', @$raw_lines));
568 572
 		my @highlight_lines = split(/\n/, $highlight_lines);
569 573
 		$lines_href->{$opts->{output}} = \@highlight_lines;
570  
-		use strict; use warnings;
  574
+		use strict;
  575
+        use warnings;
571 576
 	    }
572 577
 	    my $entry = {
573 578
 		stat       => $stat,
@@ -618,7 +623,7 @@ sub update_cache($;$)
618 623
 # example usage
619 624
 unless (caller) {
620 625
     BEGIN {
621  
-	use English;
  626
+	use English qw( -no_match_vars );
622 627
 	$PERLDB |= 0x400;
623 628
     };  # Turn on saving @{_<$filename};
624 629
     my $file=__FILE__;
2  lib/Devel/Trepan/DB/Sub.pm
@@ -4,7 +4,7 @@
4 4
 package DB;
5 5
 use warnings; no warnings 'redefine';
6 6
 no warnings 'once';
7  
-use English;
  7
+use English qw( -no_match_vars );
8 8
 
9 9
 use constant SINGLE_STEPPING_EVENT =>  1;
10 10
 use constant DEEP_RECURSION_EVENT  =>  4;
8  lib/Devel/Trepan/IO.pm
@@ -10,12 +10,14 @@
10 10
 # Some ideas originiated as part of Matt Fleming's 2006 Google Summer of
11 11
 # Code project.
12 12
 
13  
-use strict; use warnings;
  13
+package Devel::Trepan::IO::InputBase;
  14
+
  15
+use strict;
  16
+use warnings;
  17
+
14 18
 use Exporter;
15 19
 use lib '../..';
16 20
 
17  
-package Devel::Trepan::IO::InputBase;
18  
-
19 21
 use Devel::Trepan::Util qw(hash_merge);
20 22
 use vars qw(@EXPORT);
21 23
 
6  lib/Devel/Trepan/IO/Input.pm
@@ -5,12 +5,14 @@
5 5
 # input or GNU Readline.
6 6
 # 
7 7
 
8  
-use warnings; use strict;
  8
+package Devel::Trepan::IO::Input;
  9
+use warnings;
  10
+use strict;
9 11
 use Exporter;
10 12
 use Term::ReadLine;
11 13
 
12  
-package Devel::Trepan::IO::Input;
13 14
 
  15
+# TODO : Shouldn't this use lib be removed?
14 16
 use lib '../../..';
15 17
 use Devel::Trepan::Util qw(hash_merge);
16 18
 use Devel::Trepan::IO;
5  lib/Devel/Trepan/IO/StringArray.pm
@@ -4,8 +4,11 @@
4 4
 # Simulate I/O using lists of strings.
5 5
 
6 6
 package Devel::Trepan::IO::StringArrayInput;
7  
-use warnings; use strict;
8 7
 
  8
+use warnings;
  9
+use strict;
  10
+
  11
+# TODO : Shouldn't this use lib be removed?
9 12
 use lib '../../..';
10 13
 use Devel::Trepan::IO;
11 14
 
8  lib/Devel/Trepan/Interface/Script.pm
@@ -2,12 +2,16 @@
2 2
 # Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org>
3 3
 
4 4
 # Module for reading debugger scripts
  5
+package Devel::Trepan::Interface::Script;
  6
+
  7
+use strict; 
  8
+use warnings; 
  9
+no warnings 'redefine';
5 10
 
6  
-use warnings; no warnings 'redefine'; use strict; 
7 11
 use Exporter;
8 12
 use IO::File;
9 13
 
10  
-package Devel::Trepan::Interface::Script;
  14
+# TODO : Shouldn't this use lib be removed?
11 15
 use lib '../../..';
12 16
 use Devel::Trepan::Interface;
13 17
 use Devel::Trepan::IO::Input;
9  lib/Devel/Trepan/Interface/User.pm
@@ -3,10 +3,15 @@
3 3
 
4 4
 # Interface when communicating with the user.
5 5
 
6  
-use warnings; no warnings 'once'; use strict; 
  6
+package Devel::Trepan::Interface::User;
  7
+
  8
+use strict; 
  9
+use warnings; 
  10
+no warnings 'once';
  11
+
7 12
 use Exporter;
8 13
 
9  
-package Devel::Trepan::Interface::User;
  14
+# TODO : Shouldn't this use lib be removed?
10 15
 use lib '../../..';
11 16
 use vars qw(@EXPORT @ISA $HAVE_READLINE);
12 17
 @ISA = qw(Devel::Trepan::Interface Exporter);
3  lib/Devel/Trepan/Position.pm
... ...
@@ -1,4 +1,5 @@
1  
-use strict; use warnings;
  1
+use strict;
  2
+use warnings;
2 3
 
3 4
 use Class::Struct;
4 5
 struct TrepanPosition => {pkg   => '$', filename => '$', line => '$',
9  lib/Devel/Trepan/Util.pm
... ...
@@ -1,8 +1,11 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # Copyright (C) 2011 Rocky Bernstein <rocky@cpan.org>
3  
-use strict; use warnings;
4  
-use feature 'switch';
5 3
 package Devel::Trepan::Util;
  4
+
  5
+use strict;
  6
+use warnings;
  7
+use feature 'switch';
  8
+
6 9
 use vars qw(@EXPORT @ISA);
7 10
 @EXPORT    = qw( hash_merge safe_repr uniq_abbrev extract_expression
8 11
                  parse_eval_suffix);
@@ -125,7 +128,7 @@ unless (caller) {
125 128
 	print extract_expression($stmt), "\n";
126 129
     }
127 130
 
128  
-    for my $cmd qw(eval eval$ eval% eval@ evaluate% none) {
  131
+    for my $cmd (qw(eval eval$ eval% eval@ evaluate% none)) {
129 132
 	printf "parse_eval_suffix($cmd) => '%s'\n", parse_eval_suffix($cmd);
130 133
     }
131 134
 }
2  t/10test-db-brkpt.t
@@ -7,7 +7,7 @@ use Test::More 'no_plan';
7 7
 note( "Testing Devel::Trepan::DB::Breakpoint" );
8 8
 
9 9
 BEGIN {
10  
-    use English;
  10
+    use English qw( -no_match_vars );
11 11
     $PERLDB |= 0x400;
12 12
     use_ok( 'Devel::Trepan::DB::Breakpoint' );
13 13
 }
7  t/10test-intf-user.t
... ...
@@ -1,5 +1,10 @@
1 1
 #!/usr/bin/env perl
2  
-use strict; use warnings; no warnings 'redefine';
  2
+
  3
+use strict;
  4
+use warnings;
  5
+no warnings 'redefine';
  6
+
  7
+# TODO : What is the meaning of this use lib? Can it be removed?
3 8
 use lib '../lib';
4 9
 use vars qw($response); 
5 10
 
8  t/10test-linecache.t
... ...
@@ -1,12 +1,16 @@
1 1
 #!/usr/bin/env perl
2  
-use strict; use warnings;
  2
+
  3
+use strict;
  4
+use warnings;
  5
+
  6
+# TODO : What is the meaning of this use lib? Can it be removed?
3 7
 use lib '../lib';
4 8
 
5 9
 use Test::More 'no_plan';
6 10
 note( "Testing Devel::Trepan::DB::LineCache" );
7 11
 
8 12
 BEGIN {
9  
-    use English;
  13
+    use English qw( -no_match_vars );
10 14
     $PERLDB |= 0x400;
11 15
     use_ok( 'Devel::Trepan::DB::LineCache' );
12 16
 }
6  t/10test-options.t
... ...
@@ -1,5 +1,9 @@
1 1
 #!/usr/bin/env perl
2  
-use strict; use warnings; use English;
  2
+
  3
+use strict;
  4
+use warnings;
  5
+use English qw( -no_match_vars );
  6
+
3 7
 use lib '../lib';
4 8
 
5 9
 use Test::More 'no_plan';
7  t/10test-proc-hook.t
... ...
@@ -1,5 +1,10 @@
1 1
 #!/usr/bin/env perl
2  
-use strict; use warnings; no warnings 'redefine';
  2
+
  3
+use strict;
  4
+use warnings;
  5
+no warnings 'redefine';
  6
+
  7
+# TODO : I don't think this use lib is a good idea.
3 8
 use lib '../lib';
4 9
 use vars qw(@args); 
5 10
 
8  t/10test-proc-load.t
... ...
@@ -1,6 +1,12 @@
1 1
 #!/usr/bin/env perl
2  
-use strict; use warnings; no warnings 'redefine';
  2
+
  3
+use strict;
  4
+use warnings;
  5
+no warnings 'redefine';
  6
+
  7
+# TODO : I don't think this use lib is a good idea.
3 8
 use lib '../lib';
  9
+
4 10
 use vars qw($response); 
5 11
 
6 12
 use Test::More 'no_plan';
8  t/20test-autolist.t
... ...
@@ -1,6 +1,10 @@
1 1
 #!/usr/bin/env perl
2  
-use warnings; use strict;
3  
-use File::Basename; use File::Spec;
  2
+
  3
+use warnings;
  4
+use strict;
  5
+
  6
+use File::Basename;
  7
+use File::Spec;
4 8
 use Test::More 'no_plan';
5 9
 use lib dirname(__FILE__);
6 10
 use Helper;
5  t/20test-break.t
... ...
@@ -1,5 +1,8 @@
1 1
 #!/usr/bin/env perl
2  
-use warnings; use strict;
  2
+
  3
+use warnings;
  4
+use strict;
  5
+
3 6
 use File::Spec;
4 7
 use File::Basename qw(dirname);
5 8
 use lib dirname(__FILE__);
5  t/20test-display.t
... ...
@@ -1,5 +1,8 @@
1 1
 #!/usr/bin/env perl
2  
-use warnings; use strict;
  2
+
  3
+use warnings;
  4
+use strict;
  5
+
3 6
 use File::Spec;
4 7
 use File::Basename qw(dirname);
5 8
 use lib dirname(__FILE__);
8  t/20test-eval.t
... ...
@@ -1,6 +1,10 @@
1 1
 #!/usr/bin/env perl
2  
-use warnings; use strict;
3  
-use File::Basename; use File::Spec;
  2
+
  3
+use warnings;
  4
+use strict;
  5
+
  6
+use File::Basename;
  7
+use File::Spec;
4 8
 use Test::More 'no_plan';
5 9
 use lib dirname(__FILE__);
6 10
 use Helper;
5  t/20test-list1.t
... ...
@@ -1,5 +1,8 @@
1 1
 #!/usr/bin/env perl
2  
-use warnings; use strict;
  2
+
  3
+use warnings;
  4
+use strict;
  5
+
3 6
 use File::Basename; use File::Spec;
4 7
 use Test::More 'no_plan';
5 8
 use lib dirname(__FILE__);
5  t/20test-list2.t
... ...
@@ -1,5 +1,8 @@
1 1
 #!/usr/bin/env perl
2  
-use warnings; use strict;
  2
+
  3
+use warnings;
  4
+use strict;
  5
+
3 6
 use File::Basename; use File::Spec;
4 7
 use Test::More 'no_plan';
5 8
 use lib dirname(__FILE__);
5  t/20test-list3.t
... ...
@@ -1,5 +1,8 @@
1 1
 #!/usr/bin/env perl
2  
-use warnings; use strict;
  2
+
  3
+use warnings;
  4
+use strict;
  5
+
3 6
 use File::Basename; use File::Spec;
4 7
 use Test::More 'no_plan';
5 8
 use lib dirname(__FILE__);
5  t/20test-next.t
... ...
@@ -1,5 +1,8 @@
1 1
 #!/usr/bin/env perl
2  
-use warnings; use strict;
  2
+
  3
+use warnings;
  4
+use strict;
  5
+
3 6
 use File::Basename; use File::Spec;
4 7
 use Test::More 'no_plan';
5 8
 use lib dirname(__FILE__);
5  t/20test-seq1.t
... ...
@@ -1,5 +1,8 @@
1 1
 #!/usr/bin/env perl
2  
-use warnings; use strict;
  2
+
  3
+use warnings;
  4
+use strict;
  5
+
3 6
 use File::Spec;
4 7
 use File::Basename qw(dirname);
5 8
 use lib dirname(__FILE__);
8  t/20test-step.t
... ...
@@ -1,6 +1,10 @@
1 1
 #!/usr/bin/env perl
2  
-use warnings; use strict;
3  
-use File::Basename; use File::Spec;
  2
+
  3
+use warnings;
  4
+use strict;
  5
+
  6
+use File::Basename;
  7
+use File::Spec;
4 8
 use Test::More 'no_plan';
5 9
 use lib dirname(__FILE__);
6 10
 use Helper;
5  t/20test-trace.t
... ...
@@ -1,5 +1,8 @@
1 1
 #!/usr/bin/env perl
2  
-use warnings; use strict;
  2
+
  3
+use warnings;
  4
+use strict;
  5
+
3 6
 use File::Spec;
4 7
 use File::Basename qw(dirname);
5 8
 use lib dirname(__FILE__);
7  t/20test-trepanpl-opts.t
... ...
@@ -1,7 +1,10 @@
1 1
 #!/usr/bin/env perl
  2
+
2 3
 use strict;
3  
-use warnings; use strict;
4  
-use English;
  4
+use warnings;
  5
+
  6
+use English qw( -no_match_vars );
  7
+
5 8
 use File::Basename;
6 9
 use File::Spec;
7 10
 my $trepanpl = File::Spec->catfile(dirname(__FILE__), qw(.. bin trepanpl));
104  t/Helper.pm
... ...
@@ -1,45 +1,95 @@
1  
-use warnings; use strict;
  1
+package Helper;
  2
+
  3
+use warnings; 
  4
+use strict;
  5
+
2 6
 use String::Diff;
  7
+use File::Basename qw(dirname);
3 8
 use File::Spec;
4  
-use File::Basename;
  9
+
  10
+use English qw( -no_match_vars ) ;
  11
+
  12
+require Test::More;
  13
+
5 14
 my $trepanpl = File::Spec->catfile(dirname(__FILE__), qw(.. bin trepanpl));
6 15
 my $debug = $^W;
7 16
 
8  
-package Helper;
9  
-use File::Basename qw(dirname); use File::Spec;
10  
-use English;
11  
-require Test::More;
  17
+sub _slurp
  18
+{
  19
+    my ($filename) = @_;
  20
+
  21
+    open my $in, '<', $filename
  22
+        or die "Cannot open '$filename' for slurping - $!";
  23
+
  24
+    local $/;
  25
+    my $contents = <$in>;
  26
+
  27
+    close($in);
  28
+
  29
+    return $contents;
  30
+}
  31
+
12 32
 sub run_debugger($$;$$)
13 33
 {
14  
-    my ($test_invoke, $cmdfile, $rightfile, $opts) = @_;
  34
+    my ($test_invoke, $cmd_fn, $right_fn, $opts) = @_;
  35
+
15 36
     $opts //= {};
16  
-    Test::More::note( "running $test_invoke with $cmdfile" );
  37
+
  38
+    Test::More::note( "running $test_invoke with $cmd_fn" );
  39
+
17 40
     my $run_opts = $opts->{run_opts} || "--basename --nx --no-highlight";
18  
-    my $full_cmdfile = File::Spec->catfile(dirname(__FILE__), 'data', $cmdfile);
19  
-    $run_opts .= " --command $full_cmdfile" unless ($opts->{no_cmdfile});
20  
-    ($rightfile = $full_cmdfile) =~ s/\.cmd/.right/ unless defined($rightfile);
  41
+    my $full_cmd_fn = File::Spec->catfile(dirname(__FILE__), 'data', $cmd_fn);
  42
+    my $ext_filename = sub {
  43
+        my ($ext) = @_;
  44
+
  45
+        my $new_fn = $full_cmd_fn;
  46
+
  47
+        $new_fn =~ s/\.cmd\z/.$ext/;
  48
+
  49
+        return $new_fn;
  50
+    };
  51
+
  52
+    $run_opts .= " --command $full_cmd_fn" unless ($opts->{no_cmdfile});
  53
+
  54
+    if (!defined($right_fn))
  55
+    {
  56
+        $right_fn = $ext_filename->('right');
  57
+    }
  58
+
21 59
     my $cmd = "$EXECUTABLE_NAME $trepanpl $run_opts $test_invoke";
22 60
     print $cmd, "\n" if $debug;
  61
+
23 62
     my $output = `$cmd`;
24  
-    print $output if $debug;
25 63
     my $rc = $? >> 8;
26  
-    Test::More::is($rc, 0);
27  
-    open(RIGHT_FH, "<$rightfile");
28  
-    undef $INPUT_RECORD_SEPARATOR;
29  
-    my $right_string = <RIGHT_FH>;
30  
-    ($output, $right_string) = $opts->{filter}->($output, $right_string) if $opts->{filter};
31  
-    my $gotfile;
32  
-    ($gotfile = $full_cmdfile) =~ s/\.cmd/.got/;
33  
-    if ($right_string eq $output) {
34  
-	Test::More::ok(1);
35  
-	unlink $gotfile;
  64
+
  65
+    print $output if $debug;
  66
+    Test::More::is($rc, 0, 'Debugger command was executed successfully');
  67
+
  68
+    my $right_string = _slurp($right_fn);
  69
+
  70
+    if ($opts->{filter})
  71
+    {
  72
+        ($output, $right_string) = $opts->{filter}->($output, $right_string);
  73
+    }
  74
+
  75
+    my $got_fn = $ext_filename->('got');
  76
+
  77
+    # TODO : Perhaps make sure we optionally use eq_or_diff from 
  78
+    # Test::Differences here.
  79
+    if (Test::More::is($right_string, $output, 'Output comparison')) {
  80
+        unlink $got_fn;
36 81
     } else {
37  
-	my $diff = String::Diff::diff_merge($output, $right_string);
38  
-	open(GOT_FH, ">$gotfile");
39  
-	print GOT_FH $output;
40  
-	print $diff;
41  
-	Test::More::ok(0, "Output comparison fails");
  82
+        my $diff = String::Diff::diff_merge($output, $right_string);
  83
+
  84
+        open (my $got_fh, '>', $got_fn)
  85
+            or die "Cannot open '$got_fn' for writing - $!";
  86
+        print {$got_fh} $output;
  87
+        close($got_fh);
  88
+
  89
+        Test::More::diag($diff);
42 90
     }
  91
+
  92
+    return;
43 93
 }
44 94
 
45 95
 1;
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.