@@ -6,7 +6,7 @@ use warnings;
6
6
use File::Temp qw/ tempfile tempdir / ;
7
7
use File::Basename;
8
8
use Test::More;
9
- use IO:: Capture::Stderr ;
9
+ use Capture::Tiny ' :all ' ;
10
10
plan tests => 11;
11
11
use_ok(' CheckSpelling::DictionaryCoverage' );
12
12
@@ -84,34 +84,24 @@ is($output2, "1-4-0-other:$one_match_name [other:$one_match_name]($one_match) (4
84
84
85
85
($fh , $filename ) = tempfile();
86
86
close $fh ;
87
- my $capture = IO::Capture::Stderr-> new();
88
- $capture -> start();
89
- CheckSpelling::DictionaryCoverage::main($filename , " no-such-file" );
90
- $capture -> stop();
91
- is((join " \n " , $capture -> read ()), " Couldn't open dictionary \` no-such-file\` (dictionary-not-found)
87
+ my ($stdout , $stderr , @result );
88
+ ($stdout , $stderr , @result ) = capture { CheckSpelling::DictionaryCoverage::main($filename , " no-such-file" ); };
89
+ is($stderr , " Couldn't open dictionary \` no-such-file\` (dictionary-not-found)
92
90
" , ' dictionary-not-found' );
93
91
94
- $capture = IO::Capture::Stderr-> new();
95
- $capture -> start();
96
- CheckSpelling::DictionaryCoverage::main(" /dev/no-such-file" , ());
97
- $capture -> stop();
98
- is((join " \n " , $capture -> read ()), ' Could not read /dev/no-such-file
92
+ ($stdout , $stderr , @result ) = capture { CheckSpelling::DictionaryCoverage::main(" /dev/no-such-file" , ()); };
93
+ is($stderr , ' Could not read /dev/no-such-file
99
94
' , ' no-such-file' );
100
95
101
- $capture = IO::Capture::Stderr-> new();
102
- $capture -> start();
103
- CheckSpelling::DictionaryCoverage::main($filename , " /dev/no-such-file.dic" );
104
- $capture -> stop();
105
- my $dictionary_coverage = (join " \n " , $capture ? $capture -> read () : ());
96
+ ($stdout , $stderr , @result ) = capture { CheckSpelling::DictionaryCoverage::main($filename , " /dev/no-such-file.dic" ); };
97
+ my $dictionary_coverage = $stderr ;
106
98
if ($dictionary_coverage =~ / hunspell-unavailable/ ) {
107
99
is($dictionary_coverage , ' Could not load Text::Hunspell for `/dev/no-such-file.dic` (hunspell-unavailable)
108
100
' , ' no-such-file' );
109
101
} else {
110
102
is($dictionary_coverage , " Couldn't open dictionary `/dev/no-such-file.dic` (dictionary-not-found)
111
103
" , ' no-such-file' );
112
104
}
113
- $capture = IO::Capture::Stderr-> new();
114
- $capture -> start();
115
105
($fh , $filename ) = tempfile();
116
106
print $fh ' world
117
107
hello
@@ -120,9 +110,8 @@ worked
120
110
something
121
111
' ;
122
112
close $fh ;
123
- CheckSpelling::DictionaryCoverage::main($filename , ' t/sample.dic' );
124
- $capture -> stop();
125
- $dictionary_coverage = (join " \n " , $capture ? $capture -> read () : ());
113
+ ($stdout , $stderr , @result ) = capture { CheckSpelling::DictionaryCoverage::main($filename , ' t/sample.dic' ); };
114
+ $dictionary_coverage = $stderr ;
126
115
if ($dictionary_coverage =~ / hunspell-unavailable/ ) {
127
116
is($dictionary_coverage , ' Could not load Text::Hunspell for `t/sample.dic` (hunspell-unavailable)
128
117
' , ' hunspell-unavailable' )
0 commit comments