File: 02-parse.t

package info (click to toggle)
libcss-lessp-perl 0.86-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 148 kB
  • sloc: perl: 520; makefile: 12
file content (33 lines) | stat: -rw-r--r-- 1,045 bytes parent folder | download | duplicates (2)
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
use strict;
use warnings;
use IO::File;
use Test::More;
use CSS::LESSp;

###############################################################################
# figure out how many JS files we're going to run through for testing
my @files = <t/less/*.less>;
plan tests => scalar @files;

###############################################################################
# test each of the JS files in turn
foreach my $file (@files) {
    (my $min_file = $file) =~ s/\.less$/\.css/;
    my $str = slurp( $file );
    my $min = slurp( $min_file );
    my @res = CSS::LESSp->parse( $str );

    is( join("",@res), $min, $file );
}

###############################################################################
# HELPER METHOD: slurp in contents of file to scalar.
###############################################################################
sub slurp {
    my $filename = shift;
    my $fin = IO::File->new( $filename, '<' ) || die "can't open '$filename'; $!";
    my $str = join('', <$fin>);
    $fin->close();
    chomp( $str );
    return $str;
}