Debian Codegraph @

t/22trailing-comment-lines.t

raw symbols SCIP
1 #!/usr/bin/perl
2
3 # This script attempts to reproduce:
4 # https://rt.cpan.org/Ticket/Display.html?id=30402
5 #
6 # #30402: WriteConfig does not write the last lines of a file if they are comments
7
8 use Test::More tests => 1;
9
10 use strict;
11 use warnings;
12
13 use lib "./t/lib";
14 use File::Spec;
15 use Config::IniFiles;
16 use Config::IniFiles::Slurp qw( slurp );
17
18 {
19 my $conf = Config::IniFiles->new(
20 -file => File::Spec->catfile(
21 File::Spec->curdir(), 't', 'trailing-comments.ini'
22 )
23 );
24
25 my $new_file =
26 File::Spec->catfile( File::Spec->curdir(), 't', 'new-trail.ini' );
27
28 $conf->WriteConfig($new_file);
29
30 # TEST
31 like(
32 scalar( slurp($new_file) ),
33 qr{; End Comment 1\n; End Comment 2\n+\z}ms,
34 "WriteConfig() Preserved end comments."
35 );
36
37 # Remove the generated files so they won't pollute the filesystem /
38 # working-copy.
39 unlink($new_file);
40 }
41