File: stringify.t

package info (click to toggle)
liblog-any-perl 1.717-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 448 kB
  • sloc: perl: 1,499; makefile: 11
file content (35 lines) | stat: -rw-r--r-- 567 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use warnings;
use strict;
use Test::More tests => 1;

{

    package Test_URI;

    use overload '""' => \&stringify;

    sub new {
        my ( $class, $s ) = @_;
        return bless { s => $s }, $class;
    }

    sub stringify {
        my ($self) = @_;
        return $self->{s};
    }

}

use Log::Any '$log';
use Log::Any::Adapter 'Test';

my $uri = Test_URI->new('http://slashdot.org/');

$log->infof( 'Fetching %s', $uri );

is(
    Log::Any::Adapter::Test->msgs->[0]->{message},
    'Fetching http://slashdot.org/',
    'URI was correctly stringified'
);