<commit_before># -*- perl -*-

# Usefult for debugging the xs with prints:
# cd text-sass-xs && ./Build && perl -Mlib=blib/arch -Mlib=blib/lib t/01_xs.t

use strict;
use warnings;

use Test::More tests => 34;
BEGIN { use_ok('CSS::Sass') };

my $r;
$r = CSS::Sass::compile_sass("this is invalid sass source", {});
is  ($r->{error_status},  1,           "Failed compile sets error_status");
like($r->{error_message}, qr/error:/,  "Failed compile sets error_message");
is  ($r->{output_string}, undef,       "Failed compile sets output_string to undef");


$r = CSS::Sass::compile_sass(".valid { color: red; }", {});
is  ($r->{error_status},  0,           "Successful compile clears error_status");
is  ($r->{error_message}, undef,       "Successful compile sets error_message to undef");
isnt($r->{output_string}, undef,       "Successful compile sets output_string");


# $options->{output_style}
$r = CSS::Sass::compile_sass(".valid { color: red; }", { output_style => CSS::Sass::SASS_STYLE_NESTED });
is    ($r->{error_status},  0,           "output_style=>SASS_STYLE_NESTED no_error_status");
is    ($r->{error_message}, undef,       "output_style=>SASS_STYLE_NESTED error_message is undef");
like  ($r->{output_string}, qr/\{\n/,    "output_style=>SASS_STYLE_NESTED has returns in output");

$r = CSS::Sass::compile_sass("\n.valid {\n color: red; }", { output_style => CSS::Sass::SASS_STYLE_COMPRESSED });
is    ($r->{error_status},  0,           "output_style=>SASS_STYLE_COMPRESSED no_error_status");
is    ($r->{error_message}, undef,       "output_style=>SASS_STYLE_COMPRESSED error_message is undef");
unlike($r->{output_string}, qr/{\n/,     "output_style=>SASS_STYLE_COMPRESSED has no returns in output");


# $options->{source_comment}
$r = CSS::Sass::compile_sass("\n.valid {\n color: red; }", { source_comments => 1 });
is    ($r->{error_status},  0,           "source_comments=>1 no error_status");
is    ($r->{error_message}, undef,       "source_comments=>1 error_message is undef");
like  ($r->{output_string}, qr@/\*@,     "source_comments=>1 has added comments");

# $options->{source_comment}
$r = CSS::Sass::compile_sass("\n.valid {\n color: red; }", { source_comments => 0 });
is    ($r->{error_status},  0,           "source_comments=>0 no error_status");
is    ($r->{error_message}, undef,       "source_comments=>0 error_message is undef");
unlike($r->{output_string}, qr@/\*@,     "source_comments=>0 has no added comments");


# $options->{include_paths}
$r = CSS::Sass::compile_sass('@import "colors"; .valid { color: $red; }', { });
is    ($r->{error_status},  1,           "failed import sets error_status");
like  ($r->{error_message}, qr/error:/,  "failed import sets error_message");
is    ($r->{output_string}, undef,       "failed import output_string is undef");

$r = CSS::Sass::compile_sass('@import "colors"; .valid { color: $red; }', { include_paths => 't/inc' });
is    ($r->{error_status},  0,           "import no error_status");
is    ($r->{error_message}, undef,       "import error_message is undef");
like  ($r->{output_string}, qr/#ff1111/, "import imported red");

my $pathsep = $^O eq 'MSWin32' ? ';' : ':';
$r = CSS::Sass::compile_sass('@import "colors"; .valid { color: $red; }', { include_paths => "t/nonexistent${pathsep}t/inc" });
is    ($r->{error_status},  0,           "import w/ 2 paths no error_status");
is    ($r->{error_message}, undef,       "import w/ 2 paths error_message is undef");
like  ($r->{output_string}, qr/#ff1111/, "import w/ 2 paths imported red");


# $options->{image_path}
$r = CSS::Sass::compile_sass('.valid { color: image-url("path"); }', { });
is    ($r->{error_status},  0,                        "image_path no error_status");
is    ($r->{error_message}, undef,                    "image_path error_message is undef");
like  ($r->{output_string}, qr@url\("/path"\)@,       "image_path defaults to /");

$r = CSS::Sass::compile_sass('.valid { color: image-url("path"); }', { image_path => "/a/b/c" });
is    ($r->{error_status},  0,                        "image_path w/ 2 paths no error_status");
is    ($r->{error_message}, undef,                    "image_path w/ 2 paths error_message is undef");<commit_msg>[01_xs.t] Fix test names for image_path tests.<commit_after># -*- perl -*-

# Usefult for debugging the xs with prints:
# cd text-sass-xs && ./Build && perl -Mlib=blib/arch -Mlib=blib/lib t/01_xs.t

use strict;
use warnings;

use Test::More tests => 34;
BEGIN { use_ok('CSS::Sass') };

my $r;
$r = CSS::Sass::compile_sass("this is invalid sass source", {});
is  ($r->{error_status},  1,           "Failed compile sets error_status");
like($r->{error_message}, qr/error:/,  "Failed compile sets error_message");
is  ($r->{output_string}, undef,       "Failed compile sets output_string to undef");


$r = CSS::Sass::compile_sass(".valid { color: red; }", {});
is  ($r->{error_status},  0,           "Successful compile clears error_status");
is  ($r->{error_message}, undef,       "Successful compile sets error_message to undef");
isnt($r->{output_string}, undef,       "Successful compile sets output_string");


# $options->{output_style}
$r = CSS::Sass::compile_sass(".valid { color: red; }", { output_style => CSS::Sass::SASS_STYLE_NESTED });
is    ($r->{error_status},  0,           "output_style=>SASS_STYLE_NESTED no_error_status");
is    ($r->{error_message}, undef,       "output_style=>SASS_STYLE_NESTED error_message is undef");
like  ($r->{output_string}, qr/\{\n/,    "output_style=>SASS_STYLE_NESTED has returns in output");

$r = CSS::Sass::compile_sass("\n.valid {\n color: red; }", { output_style => CSS::Sass::SASS_STYLE_COMPRESSED });
is    ($r->{error_status},  0,           "output_style=>SASS_STYLE_COMPRESSED no_error_status");
is    ($r->{error_message}, undef,       "output_style=>SASS_STYLE_COMPRESSED error_message is undef");
unlike($r->{output_string}, qr/{\n/,     "output_style=>SASS_STYLE_COMPRESSED has no returns in output");


# $options->{source_comment}
$r = CSS::Sass::compile_sass("\n.valid {\n color: red; }", { source_comments => 1 });
is    ($r->{error_status},  0,           "source_comments=>1 no error_status");
is    ($r->{error_message}, undef,       "source_comments=>1 error_message is undef");
like  ($r->{output_string}, qr@/\*@,     "source_comments=>1 has added comments");

# $options->{source_comment}
$r = CSS::Sass::compile_sass("\n.valid {\n color: red; }", { source_comments => 0 });
is    ($r->{error_status},  0,           "source_comments=>0 no error_status");
is    ($r->{error_message}, undef,       "source_comments=>0 error_message is undef");
unlike($r->{output_string}, qr@/\*@,     "source_comments=>0 has no added comments");


# $options->{include_paths}
$r = CSS::Sass::compile_sass('@import "colors"; .valid { color: $red; }', { });
is    ($r->{error_status},  1,           "failed import sets error_status");
like  ($r->{error_message}, qr/error:/,  "failed import sets error_message");
is    ($r->{output_string}, undef,       "failed import output_string is undef");

$r = CSS::Sass::compile_sass('@import "colors"; .valid { color: $red; }', { include_paths => 't/inc' });
is    ($r->{error_status},  0,           "import no error_status");
is    ($r->{error_message}, undef,       "import error_message is undef");
like  ($r->{output_string}, qr/#ff1111/, "import imported red");

my $pathsep = $^O eq 'MSWin32' ? ';' : ':';
$r = CSS::Sass::compile_sass('@import "colors"; .valid { color: $red; }', { include_paths => "t/nonexistent${pathsep}t/inc" });
is    ($r->{error_status},  0,           "import w/ 2 paths no error_status");
is    ($r->{error_message}, undef,       "import w/ 2 paths error_message is undef");
like  ($r->{output_string}, qr/#ff1111/, "import w/ 2 paths imported red");


# $options->{image_path}
$r = CSS::Sass::compile_sass('.valid { color: image-url("path"); }', { });
is    ($r->{error_status},  0,                        "image_path default no error_status");
is    ($r->{error_message}, undef,                    "image_path default error_message is undef");
like  ($r->{output_string}, qr@url\("/path"\)@,       "image_path defaults to /");

$r = CSS::Sass::compile_sass('.valid { color: image-url("path"); }', { image_path => "/a/b/c" });
is    ($r->{error_status},  0,                        "image_path paths no error_status");
is    ($r->{error_message}, undef,                    "image_path paths error_message is undef");
{'fraction_non_alphanumeric': 0.1941908713692946, 'fraction_numerical': 0.00901007705986959, 'mean_word_length': 3.856649395509499, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 117, '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': '4344734', 'n_tokens_mistral': 3014, 'n_tokens_neox': 2887, 'n_words': 679}