Debian Codegraph @

t/01-newline-at-end.t

raw symbols SCIP
1 #!perl -T
2
3 use strict;
4 use warnings FATAL => 'all';
5 use Test::More;
6
7 plan tests => 2;
8
9 #####
10 ##### This test ensures that if the file contains a new line at the end
11 ##### then that newline will be preserved
12 ##### The read-from-file tests for this are in JavaScript-Minifier.t
13 #####
14
15 use JavaScript::Minifier;
16
17 my $js_with_new_line = <<'END';
18 function (s) { alert("Foo"); }
19 END
20
21 chomp( my $js_without_new_line = $js_with_new_line );
22
23 like(
24 minify(input => $js_with_new_line),
25 qr/\n\z/,
26 'Last new line was preserved',
27 );
28
29 like(
30 minify(input => $js_without_new_line),
31 qr/[^\n]\z/,
32 'Last new line was not added because it was absent originally',
33 );