| 1 | #!perl -T |
| 2 | |
| 3 | use strictscip-perl cpan JavaScript-Minifier 1.17 strict/; |
| 4 | use warningsscip-perl cpan JavaScript-Minifier 1.17 warnings/ FATAL => 'all'; |
| 5 | use Test::Morescip-perl cpan JavaScript-Minifier 1.17 Test/More/; |
| 6 | |
| 7 | planscip-perl cpan JavaScript-Minifier 1.17 main/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::Minifierscip-perl cpan JavaScript-Minifier 1.17 JavaScript/Minifier/; |
| 16 | |
| 17 | my $js_with_new_line = <<'END'; |
| 18 | function (s) { alert("Foo"); } |
| 19 | END |
| 20 | |
| 21 | chompscip-perl cpan JavaScript-Minifier 1.17 main/chomp().( my $js_without_new_line = $js_with_new_line ); |
| 22 | |
| 23 | likescip-perl cpan JavaScript-Minifier 1.17 main/like().( |
| 24 | minifyscip-perl cpan JavaScript-Minifier 1.17 main/minify().(input => $js_with_new_line), |
| 25 | qr/\n\z/, |
| 26 | 'Last new line was preserved', |
| 27 | ); |
| 28 | |
| 29 | likescip-perl cpan JavaScript-Minifier 1.17 main/like().( |
| 30 | minifyscip-perl cpan JavaScript-Minifier 1.17 main/minify().(input => $js_without_new_line), |
| 31 | qr/[^\n]\z/, |
| 32 | 'Last new line was not added because it was absent originally', |
| 33 | ); |