File: 08_serialize.t

package info (click to toggle)
libdancer-perl 1.3521%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,460 kB
  • sloc: perl: 7,436; xml: 2,211; sh: 54; makefile: 32; sql: 5
file content (37 lines) | stat: -rw-r--r-- 1,032 bytes parent folder | download | duplicates (5)
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
# this test makes sure the "console" logger send log messages to STDERR

use strict;
use warnings;
use Test::More import => ['!pass'];

plan skip_all => "Test::Output is needed for this test"
    unless Dancer::ModuleLoader->load('Test::Output');

plan tests => 4;

use Dancer ':syntax';
set logger => 'Console';

Test::Output::stderr_like(
    sub { Dancer::Logger::warning(['a']) }, 
    qr/\[\d+\]  warn @.+> \['a'\] in/,
    'Arrayref correctly serialized',
);

Test::Output::stderr_like(
    sub { Dancer::Logger::warning( { this => 'that' } ) }, 
    qr/\[\d+\]  warn @.+> \{'this' => 'that'\} in/,
    'Hashref correctly serialized',
);

Test::Output::stderr_like(
    sub { Dancer::Logger::warning( qw/hello world/ ) }, 
    qr/\[\d+\]  warn @.+> helloworld in/,
    'Multiple arguments are okay',
);

Test::Output::stderr_like(
    sub { Dancer::Logger::warning( { b => 1, a => 2, e => 3, d => 4, c => 5}) }, 
    qr/\[\d+\]  warn @.+> \{'a' => 2,'b' => 1,'c' => 5,'d' => 4,'e' => 3\}/,
    'Hash keys are sorted okay',
);