<commit_before>#!/usr/bin/perl
# -*- perl -*-

use strict;
use warnings;
use File::Basename;
use File::Spec::Functions;
use YAML::XS;

################################################################################
package DIR;
################################################################################

sub new
{
	my $pkg = $_[0];
	my $root = $_[1];
	my $parent = $_[2];
	my $opt = $_[3] || {};
	return bless {
		root => $root,
		parent => $parent,
		wtodo => $opt->{wtodo},
		todo => $opt->{todo},
		clean => $opt->{clean},
		style => $opt->{style},
		prec => $opt->{prec},
		start => $opt->{start},
		end => $opt->{end},
	}, $pkg;
}

sub query
{
	# check if we found the option
	if (defined $_[0]->{$_[1]}) {
		return $_[0]->{$_[1]};
	}
	# otherwise dispatch to parent
	if (defined $_[0]->{parent}) {
		return $_[0]->{parent}->query($_[1]);
	}
	# or not found
	return undef;
}

################################################################################
package SPEC;
################################################################################

use CSS::Sass;
use Cwd qw(getcwd);
use Carp qw(croak);
use File::Spec::Functions;

my $cwd = getcwd;
my $cwd_win = $cwd;
my $cwd_nix = $cwd;
$cwd_win =~ s/[\/\\]/\\/g;
$cwd_nix =~ s/[\/\\]/\//g;

# everything is normalized
my $norm_output = sub ($) {
	eval { # ignore invalid utf8
		$_[0] =~ s/(?:\r?\n)+/\n/g;
		$_[0] =~ s/;(?:\s*;)+/;/g;
		$_[0] =~ s/;\s*}/}/g;
		# normalize debug entries
		$_[0] =~ s/[^\n]+(\d+) DEBUG: /$1: DEBUG: /g;
		# normalize directory entries
		$_[0] =~ s/\/libsass-todo-issues\//\/libsass-issues\//g;
		$_[0] =~ s/\/libsass-closed-issues\//\/libsass-issues\//g;
		$_[0] =~ s/\Q$cwd_win\E[\/\\]t[\/\\]sass-spec[\/\\]/\/sass\//g;
		$_[0] =~ s/\Q$cwd_nix\E[\/\\]t[\/\\]sass-spec[\/\\]/\/sass\//g;
		# normalize nth-child binomial whitespace
		$_[0] =~ s/\(\s*(\d+n)\s*([+-])\s*(\d+)\s*\)/($1 $2 $3)/g;
	}
};<commit_msg>Fix spec test by trimming trailing white-space<commit_after>#!/usr/bin/perl
# -*- perl -*-

use strict;
use warnings;
use File::Basename;
use File::Spec::Functions;
use YAML::XS;

################################################################################
package DIR;
################################################################################

sub new
{
	my $pkg = $_[0];
	my $root = $_[1];
	my $parent = $_[2];
	my $opt = $_[3] || {};
	return bless {
		root => $root,
		parent => $parent,
		wtodo => $opt->{wtodo},
		todo => $opt->{todo},
		clean => $opt->{clean},
		style => $opt->{style},
		prec => $opt->{prec},
		start => $opt->{start},
		end => $opt->{end},
	}, $pkg;
}

sub query
{
	# check if we found the option
	if (defined $_[0]->{$_[1]}) {
		return $_[0]->{$_[1]};
	}
	# otherwise dispatch to parent
	if (defined $_[0]->{parent}) {
		return $_[0]->{parent}->query($_[1]);
	}
	# or not found
	return undef;
}

################################################################################
package SPEC;
################################################################################

use CSS::Sass;
use Cwd qw(getcwd);
use Carp qw(croak);
use File::Spec::Functions;

my $cwd = getcwd;
my $cwd_win = $cwd;
my $cwd_nix = $cwd;
$cwd_win =~ s/[\/\\]/\\/g;
$cwd_nix =~ s/[\/\\]/\//g;

# everything is normalized
my $norm_output = sub ($) {
	eval { # ignore invalid utf8
		$_[0] =~ s/(?:\r?\n)+/\n/g;
		$_[0] =~ s/;(?:\s*;)+/;/g;
		$_[0] =~ s/;\s*}/}/g;
		# trim trailing spaces
		$_[0] =~ s/(?<!\s)[\t ]+$//gm;
		# normalize debug entries
		$_[0] =~ s/[^\n]+(\d+) DEBUG: /$1: DEBUG: /g;
		# normalize directory entries
		$_[0] =~ s/\/libsass-todo-issues\//\/libsass-issues\//g;
		$_[0] =~ s/\/libsass-closed-issues\//\/libsass-issues\//g;
		$_[0] =~ s/\Q$cwd_win\E[\/\\]t[\/\\]sass-spec[\/\\]/\/sass\//g;
		$_[0] =~ s/\Q$cwd_nix\E[\/\\]t[\/\\]sass-spec[\/\\]/\/sass\//g;
		# normalize nth-child binomial whitespace
		$_[0] =~ s/\(\s*(\d+n)\s*([+-])\s*(\d+)\s*\)/($1 $2 $3)/g;
	}
};
{'fraction_non_alphanumeric': 0.41451571684129823, 'fraction_numerical': 0.01303347814975722, 'mean_word_length': 3.577777777777778, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4633900', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1543, 'n_words': 302}