<commit_before># Modules.
use File::Object;
use Tags2::Output::Indent;
use Test::More 'tests' => 3;

# Include helpers.
do File::Object->new->up->file('get_stdout.inc')->serialize;

print "Testing: 'auto_flush' parameter.\n";
my $obj = Tags2::Output::Indent->new(
	'auto_flush' => 1,
	'output_handler' => \*STDOUT,
	'xml' => 1,
);
my $ret = get_stdout($obj, 1, ['b', 'tag'], ['e', 'tag']);
my $right_ret = '<tag />';
is($ret, $right_ret);

$obj->reset;
$ret = get_stdout($obj, 1, ['b', 'tag'], ['d', 'data'], ['e', 'tag']);
$right_ret = <<'END';
<tag>
  data
</tag>
END
chomp $right_ret;
is($ret, $right_ret);

$obj->reset;
$ret = get_stdout($obj, 1, ['b', 'tag'], ['b', 'other_tag'], ['d', 'data'], 
	['e', 'other_tag'], ['e', 'tag']);
$right_ret = <<'END';
<tag>
  <other_tag>
    data
  </other_tag>
</tag>
END
chomp $right_ret;
is($ret, $right_ret);<commit_msg>Remove get_stdout() calling. Add two new tests.<commit_after># Modules.
use File::Object;
use IO::Scalar;
use Tags2::Output::Indent;
use Test::More 'tests' => 5;

print "Testing: 'auto_flush' parameter.\n";
my $obj = Tags2::Output::Indent->new(
	'auto_flush' => 1,
	'output_handler' => \*STDOUT,
	'xml' => 1,
);
my $ret;
tie *STDOUT, 'IO::Scalar', \$ret;
$obj->put(
	['b', 'tag'],
	['e', 'tag'],
);
untie *STDOUT;
my $right_ret = '<tag />';
is($ret, $right_ret);

$obj->reset;
undef $ret;
tie *STDOUT, 'IO::Scalar', \$ret;
$obj->put(['b', 'tag']);
$obj->put(['e', 'tag']);
untie *STDOUT;
is($ret, $right_ret);

$obj->reset;
undef $ret;
tie *STDOUT, 'IO::Scalar', \$ret;
$obj->put(
	['b', 'tag'],
	['d', 'data'],
	['e', 'tag'],
);
untie *STDOUT;
$right_ret = <<'END';
<tag>
  data
</tag>
END
chomp $right_ret;
is($ret, $right_ret);

$obj->reset;
undef $ret;
tie *STDOUT, 'IO::Scalar', \$ret;
$obj->put(
	['b', 'tag'],
	['b', 'other_tag'],
	['d', 'data'],
	['e', 'other_tag'],
	['e', 'tag'],
);
untie *STDOUT;
$right_ret = <<'END';
<tag>
  <other_tag>
    data
  </other_tag>
</tag>
END
chomp $right_ret;
is($ret, $right_ret);

$obj->reset;
undef $ret;
tie *STDOUT, 'IO::Scalar', \$ret;
$obj->put(['b', 'tag']);
$obj->put(['b', 'other_tag']);
$obj->put(['d', 'data']);
$obj->put(['e', 'other_tag']);
$obj->put(['e', 'tag']);
untie *STDOUT;
is($ret, $right_ret);
{'fraction_non_alphanumeric': 0.2927158273381295, 'fraction_numerical': 0.005845323741007194, 'mean_word_length': 5.375358166189112, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1675645', 'n_tokens_mistral': 1003, 'n_tokens_neox': 967, 'n_words': 228}