Debian Codegraph @

t/embedded-WWW-Mechanize-Shell.t

raw
1 #!/opt/perl58/bin/perl -w
2
3 use Test::More 'no_plan';
4
5 package Catch;
6
7 sub TIEHANDLE {
8 my($class, $var) = @_;
9 return bless { var => $var }, $class;
10 }
11
12 sub PRINT {
13 my($self) = shift;
14 ${'main::'.$self->{var}} .= join '', @_;
15 }
16
17 sub OPEN {} # XXX Hackery in case the user redirects
18 sub CLOSE {} # XXX STDERR/STDOUT. This is not the behavior we want.
19
20 sub READ {}
21 sub READLINE {}
22 sub GETC {}
23 sub BINMODE {}
24
25 my $Original_File = 'lib/WWW/Mechanize/Shell.pm';
26
27 package main;
28
29 # pre-5.8.0's warns aren't caught by a tied STDERR.
30 $SIG{__WARN__} = sub { $main::_STDERR_ .= join '', @_; };
31 tie *STDOUT, 'Catch', '_STDOUT_' or die $!;
32 tie *STDERR, 'Catch', '_STDERR_' or die $!;
33
34 SKIP: {
35 # A header testing whether we find all prerequisites :
36 # Check for module WWW::Mechanize::Shell
37 eval { require WWW::Mechanize::Shell };
38 skip "Need module WWW::Mechanize::Shell to run this test", 1
39 if $@;
40
41 # Check for module strict
42 eval { require strict };
43 skip "Need module strict to run this test", 1
44 if $@;
45
46
47 # The original POD test
48 undef $main::_STDOUT_;
49 undef $main::_STDERR_;
50 eval q{
51 my $example = sub {
52 local $^W = 0;
53
54 #line 33 lib/WWW/Mechanize/Shell.pm
55
56 #!/usr/bin/perl -w
57 use strict;
58 use WWW::Mechanize::Shell;
59
60 my $shell = WWW::Mechanize::Shell->new("shell");
61
62 if (@ARGV) {
63 $shell->source_file( @ARGV );
64 } else {
65 $shell->cmdloop;
66 };
67
68
69
70
71 ;
72
73 }
74 };
75 is($@, '', "example from line 33");
76
77 };
78 SKIP: {
79 # A header testing whether we find all prerequisites :
80 # Check for module WWW::Mechanize::Shell
81 eval { require WWW::Mechanize::Shell };
82 skip "Need module WWW::Mechanize::Shell to run this test", 1
83 if $@;
84
85 # Check for module strict
86 eval { require strict };
87 skip "Need module strict to run this test", 1
88 if $@;
89
90
91 # The original POD test
92 {
93 undef $main::_STDOUT_;
94 undef $main::_STDERR_;
95 #line 33 lib/WWW/Mechanize/Shell.pm
96
97 #!/usr/bin/perl -w
98 use strict;
99 use WWW::Mechanize::Shell;
100
101 my $shell = WWW::Mechanize::Shell->new("shell");
102
103 if (@ARGV) {
104 $shell->source_file( @ARGV );
105 } else {
106 $shell->cmdloop;
107 };
108
109
110
111
112 BEGIN {
113 require WWW::Mechanize::Shell;
114 $ENV{PERL_RL} = 0;
115 $ENV{COLUMNS} = '80';
116 $ENV{LINES} = '24';
117 };
118 BEGIN {
119 no warnings 'once';
120 no warnings 'redefine';
121 *WWW::Mechanize::Shell::cmdloop = sub {};
122 *WWW::Mechanize::Shell::display_user_warning = sub {};
123 *WWW::Mechanize::Shell::source_file = sub {};
124 };
125 isa_ok( $shell, "WWW::Mechanize::Shell" );
126
127 undef $main::_STDOUT_;
128 undef $main::_STDERR_;
129 }
130
131 };
132 SKIP: {
133 # A header testing whether we find all prerequisites :
134
135 # The original POD test
136 undef $main::_STDOUT_;
137 undef $main::_STDERR_;
138
139 };