File: 07_compilation_warning.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-- 854 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
36
37
use Test::More;

use Dancer ':syntax', ':tests';
use Dancer::Test;
use Dancer::Logger;

plan skip_all => "File::Temp 0.22 required"
    unless Dancer::ModuleLoader->load( 'File::Temp', '0.22' );

my $dir = File::Temp::tempdir(CLEANUP => 1, TMPDIR => 1);
set appdir => $dir;
Dancer::Logger->init('File');

# perl <= 5.8.x won't catch the warning
plan skip_all => 'Need perl >= 5.10' if $] < 5.010;

set warnings => 1, show_errors => 1;

get '/warning' => sub {
    my $bar;
	"$bar foo";
};

my @tests = (
    { path     => '/warning',
      expected => qr/Use of uninitialized value \$bar in concatenation/ },
);

plan tests => scalar(@tests);

foreach my $test (@tests) {
    response_content_like [GET => $test->{path}] => $test->{expected},
      "response looks good for ".$test->{path};
}

Dancer::Logger::logger->{fh}->close;
File::Temp::cleanup();