<commit_before>#! perl

use Test::More;

BEGIN {
        use Class::C3;
        use MRO::Compat;
}

use Artemis::Reports::DPath::Mason 'render';
use Artemis::Schema::TestTools;
use Test::Fixture::DBIC::Schema;
use Data::Dumper;

print "TAP Version 13\n";
plan tests => 4;

# -------------------- path division --------------------

my $mason = new Artemis::Reports::DPath::Mason;
my $result;
my $template;
my $path;

# -----------------------------------------------------------------------------------------------------------------
construct_fixture( schema  => reportsdb_schema, fixture => 't/fixtures/reportsdb/report.yml' );
# -----------------------------------------------------------------------------------------------------------------

use Cwd 'abs_path', 'cwd';


# component paths look (and must be) absolute, but are always taken relative to comp_root
like($mason->render(file     => "/t/helloworld.mas"),   qr/Hello, world!\s*/, "mason hello world file");
is(  $mason->render(template => "SOME_TEMPLATE"),       "SOME_TEMPLATE",      "mason stupid template");
like($mason->render(template => "foo <% 'bar' %> baz"), qr/foo bar baz\s*/,   "mason template with static content tags");
$template = q{
% my $bar = 'hello affe zomtec';
foo <% $bar %> baz
};
is($mason->render(template => $template), "
foo hello affe zomtec baz
", "mason template with variables 1");<commit_msg>- DPAth::Mason - tests for dpath in template embedding<commit_after>#! perl

use Test::More;

BEGIN {
        use Class::C3;
        use MRO::Compat;
}

use Artemis::Reports::DPath::Mason 'render';
use Artemis::Schema::TestTools;
use Test::Fixture::DBIC::Schema;
use Data::Dumper;

print "TAP Version 13\n";
plan tests => 5;

# -------------------- path division --------------------

my $mason = new Artemis::Reports::DPath::Mason;
my $result;
my $template;
my $path;

# -----------------------------------------------------------------------------------------------------------------
construct_fixture( schema  => reportsdb_schema, fixture => 't/fixtures/reportsdb/report.yml' );
# -----------------------------------------------------------------------------------------------------------------

use Cwd 'abs_path', 'cwd';


# component paths look (and must be) absolute, but are always taken relative to comp_root
like($mason->render(file     => "/t/helloworld.mas"),   qr/Hello, world!\s*/, "mason hello world file");
is(  $mason->render(template => "SOME_TEMPLATE"),       "SOME_TEMPLATE",      "mason stupid template");
like($mason->render(template => "foo <% 'bar' %> baz"), qr/foo bar baz\s*/,   "mason template with static content tags");
$template = q{
% my $bar = 'hello affe zomtec';
foo <% $bar %> baz
};
$expected = q{
foo hello affe zomtec baz
};
is($mason->render(template => $template), $expected, "mason template with variables 1");

$template = q|
% my @res = reportdata '{ "suite.name" => "perfmon" }//tap/tests_planned';
Planned tests:
% foreach (@res) {
  <% $_ %>
% }
|;
$expected = q|
Planned tests:
  4
  3
  4
  3
|;
is($mason->render(template => $template), $expected, "mason template with dpath perfmon tests_planned");
{'fraction_non_alphanumeric': 0.3126994256541161, 'fraction_numerical': 0.004467134652201659, 'mean_word_length': 2.0947680157946693, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 33, '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': '570603', 'n_tokens_mistral': 974, 'n_tokens_neox': 931, 'n_words': 258}