File: 11concat.t

package info (click to toggle)
liblog-report-perl 1.40-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 568 kB
  • sloc: perl: 2,905; makefile: 8
file content (43 lines) | stat: -rw-r--r-- 1,101 bytes parent folder | download | duplicates (4)
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
36
37
38
39
40
41
42
43
#!/usr/bin/env perl
# Try concatenation

use warnings;
use strict;
use lib 'lib', '../lib';

use Test::More tests => 16;

use Log::Report;   # no domains, no translator
use Scalar::Util qw/refaddr blessed/;

### examples from Log::Report::Message and more

my $a = __"Hello";
isa_ok($a, 'Log::Report::Message');
my $b = $a . " World!\n";
isa_ok($b, 'Log::Report::Message');
cmp_ok(refaddr $a, '!=', refaddr $b);  # must clone
is("$b", "Hello World!\n");

my $c = 'a' . 'b' . __("c") . __("d") . "e" . __("f");
isa_ok($c, 'Log::Report::Message');
is("$c", "abcdef");
is($c->prepend, 'ab');
isa_ok($c->append, 'Log::Report::Message');
is($c->msgid, 'c');
is($c->untranslated->toString, 'abcdef');

my $d = __("Hello")->concat(' ')->concat(__"World!")->concat("\n");
isa_ok($d, 'Log::Report::Message');
is("$d", "Hello World!\n");
is($d->untranslated->toString, "Hello World!\n");

my $h = __"Hello";
my $w = __"World!";
my $e =  "$h $w\n";
isa_ok($e, 'Log::Report::Message');
is("$e", "Hello World!\n");

### issue #123835

ok ! blessed(($h.$w)->toString), 'append/prepend must be stringified as well';