Debian Codegraph @

t/26scalar-filehandle.t

raw symbols SCIP
1 #!/usr/bin/perl
2 # This script is a regression test for:
3 #
4 # https://rt.cpan.org/Ticket/Display.html?id=54997
5 #
6 # Failure to read the ini file contents from a filehandle made out of a scalar
7 #
8 # <<< [patch] stat() on unopened filehandle warning thrown when using
9 # filehandle made from a scalar. >>>
10
11 use Test::More;
12
13 use strict;
14 use warnings;
15
16 use Carp qw(cluck);
17 use English qw(-no_match_vars);
18
19 use Config::IniFiles;
20
21 if ( !eval { require 5.008; } )
22 {
23 plan skip_all =>
24 "We need filehandles made from scalar which is a feature of Perl above 5.8.x";
25 }
26 else
27 {
28 plan tests => 2;
29 }
30
31 {
32 my $contents = <<'EOF';
33 [section1]
34 key = val
35 EOF
36
37 open my $scalar_fh, "<", \$contents;
38
39 my $conf = eval {
40 $WARNING = 1;
41 $SIG{__WARN__} = \&Carp::croak;
42 Config::IniFiles->new( -file => $scalar_fh );
43 } or warn $EVAL_ERROR;
44
45 # TEST
46 ok( !$EVAL_ERROR,
47 "Object was initialised from filehandle made out of a scalar." );
48
49 # TEST
50 is( $conf->val( "section1", "key" ), "val", "Object works." );
51
52 undef $conf;
53 close $scalar_fh;
54 }
55