CSS-Minifier-XS
view release on metacpan or search on metacpan
t/minify-collapse-zeroes.t view on Meta::CPAN
#!/usr/bin/perl
use strict;
use warnings;
use if $ENV{AUTOMATED_TESTING}, 'Test::DiagINC'; use Test::More;
use CSS::Minifier::XS qw(minify);
###############################################################################
# When collapsing "zeroes", we ONLY want to collapse ones that are genuine
# numeric values. We should NOT be collapsing identifier/filename fragments
# that simply happen to begin with a "0" (e.g. "status-0.png").
subtest 'identifiers w/zeroes are preserved' => sub {
is minify('a{background:url(0.png)}'), 'a{background:url(0.png)}', 'paren: 0.png';
is minify('a{background:url(001.png)}'), 'a{background:url(001.png)}', 'paren: 001.png';
is minify('a{background:url(img/0.png)}'), 'a{background:url(img/0.png)}', 'slash: img/0.png';
is minify('a{background:url(a.png),url(0.png)}'), 'a{background:url(a.png),url(0.png)}', 'comma list: 0.png';
};
###############################################################################
# Verify that leading-zeroes in identifiers are preserved.
xt/author/leaks-xs.t view on Meta::CPAN
note sprintf(
"RSS before: %d KB, after: %d KB, growth: %d KB over %d calls (%.3f KB/call)",
$rss_before,
$rss_after,
$rss_growth,
$ITERS_TESTING,
$rss_growth / $ITERS_TESTING,
);
###############################################################################
# Allow for some memory allocator noise and fragmentation.
#
# If total growth exceeds this threshold, odds are high that we're leaking.
my $THRESHOLD_KB = 4_000;
cmp_ok $rss_growth, '<', $THRESHOLD_KB,
"minify() does not leak memory (RSS growth $rss_growth KB < $THRESHOLD_KB KB)";
###############################################################################
done_testing();
( run in 1.265 second using v1.01-cache-2.11-cpan-364913b4093 )