File: 30autowarn.t

package info (click to toggle)
libdata-dumper-simple-perl 0.11-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 112 kB
  • sloc: perl: 344; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 911 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
38
39
40
41
42
#!/usr/bin/perl
# '$Id: 30autowarn.t,v 1.1 2004/08/03 04:48:52 ovid Exp $';
use warnings;
use strict;
use Test::More tests => 3;

my $warning;
$SIG{__WARN__} = sub { $warning = join '' => @_ };

my $carp;
sub carp { $carp = join '' => @_ };

my $CLASS;
BEGIN
{
    chdir 't' if -d 't';
    unshift @INC => '../lib';
    $CLASS = 'Data::Dumper::Simple';
    use_ok($CLASS, autowarn => 1) or die;
}

my $scalar = 'Ovid';
my @array  = qw/Data Dumper Simple Rocks!/;
my %hash   = (
    at => 'least',
    I  => 'hope',
    it => 'does',
);

my $expected = Data::Dumper->Dump(
    [$scalar, \@array, \%hash],
    [qw/$scalar *array *hash/]
);

Dumper($scalar, @array, %hash);
is($warning, $expected, 'Dumper should be able to autowarn');

no Data::Dumper::Simple;
use Data::Dumper::Simple autowarn => 'carp';
Dumper($scalar, @array, %hash);
is($carp, $expected, 
    '... even if we use a different function name');