perltidy code and add .perltidyrc to repo
[p5sagit/Log-Contextual.git] / t / arg.t
CommitLineData
8112b699 1use strict;
2use warnings;
3
4use Log::Contextual::SimpleLogger;
5use Test::More 'no_plan';
6my $var_log;
7my $var;
8
9my @levels = qw(debug trace warn info error fatal);
10
11BEGIN {
12 $var_log = Log::Contextual::SimpleLogger->new({
6ae293d7 13 levels => [qw(trace debug info warn error fatal)],
14 coderef => sub { $var = shift }
15 })
8112b699 16}
17
18use Log::Contextual qw{ :log :dlog}, -logger => $var_log;
19
20my @args = qw(fizz buzz fizzbuzz);
21
22for my $level (@levels) {
6ae293d7 23 for my $prefix (qw(log logS Dlog DlogS)) {
8112b699 24
6ae293d7 25 my $original = local $_ = "don't tread on me";
26 my $method_name = "${prefix}_${level}";
27 my $ref = __PACKAGE__->can($method_name)
28 or die "no ref found for method $method_name";
8112b699 29
6ae293d7 30 $ref->(sub { "$method_name" }, @args);
31 ok($_ eq $original, "\$_ was not disturbed by $method_name");
32 ok($var eq "[$level] $method_name\n", "log argument was correct");
33 }
8112b699 34}