File: 01-newline-at-end.t

package info (click to toggle)
libjavascript-minifier-perl 1.16-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 404 kB
  • sloc: perl: 477; javascript: 142; makefile: 7
file content (33 lines) | stat: -rw-r--r-- 668 bytes parent folder | download | duplicates (3)
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
#!perl -T

use strict;
use warnings FATAL => 'all';
use Test::More;

plan tests => 2;

#####
##### This test ensures that if the file contains a new line at the end
##### then that newline will be preserved
##### The read-from-file tests for this are in JavaScript-Minifier.t
#####

use JavaScript::Minifier;

my $js_with_new_line = <<'END';
function (s) { alert("Foo"); }
END

chomp( my $js_without_new_line = $js_with_new_line );

like(
    minify(input => $js_with_new_line),
    qr/\n\z/,
    'Last new line was preserved',
);

like(
    minify(input => $js_without_new_line),
    qr/[^\n]\z/,
    'Last new line was not added because it was absent originally',
);