File: sort-naturally.t

package info (click to toggle)
libcode-tidyall-plugin-sortlines-naturally-perl 0.000003-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 168 kB
  • sloc: perl: 94; makefile: 9; sh: 4
file content (50 lines) | stat: -rw-r--r-- 832 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/perl

use strict;
use warnings;

use utf8;
use open ':std', ':encoding(utf8)';

use Capture::Tiny qw(capture_merged);
use Code::TidyAll;
use File::Slurper qw( read_text write_text );
use File::Spec ();
use File::Temp qw( tempdir );
use Test::More;

my $file_name = 'to-sort';
my $dir       = tempdir( CLEANUP => 1 );
my $full_path = File::Spec->catfile( $dir, $file_name );

write_text( $full_path, <<'EOF');
eel
Ed
easy
rôle
role
roles
rage
Rose
EOF

my $ct = Code::TidyAll->new(
    root_dir => $dir,
    plugins  => { 'SortLines::Naturally' => { select => $file_name }, }
);

my $output;
$output = capture_merged { $ct->process_all() };
is( $output, "[tidied]  $file_name\n", 'expected output' );
is( scalar( read_text( $full_path ) ), <<'EOF', 'sorted' );
easy
Ed
eel
rage
rôle
role
roles
Rose
EOF

done_testing();