File: signatures.t

package info (click to toggle)
libdevel-size-perl 0.85-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 388 kB
  • sloc: perl: 737; makefile: 3
file content (38 lines) | stat: -rw-r--r-- 985 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
#!/usr/bin/perl -w

use strict;


BEGIN {
    require Test::More;
    unless (eval "no warnings 'experimental::signatures'; 1") {
	Test::More->import(skip_all => "No signatures");
    }
    # Ho ho, this is going to need a better implementation once they are no
    # longer experimental.
    Test::More->import();
}

no warnings "experimental::signatures";
use feature "signatures";

use Devel::Size qw(total_size);

my $warn_count;

$SIG{__WARN__} = sub {
    return if $_[0] eq "Devel::Size: Can't size up perlio layers yet\n";
    ++$warn_count;
    warn @_;
};

# This is mostly a test for the benifit of taunting ASAN and the warnings code.

cmp_ok(total_size(sub ($foo) {}), '>', 0, "basic signature");
cmp_ok(total_size(sub ($bar = "x" x 1024) {}), '>', 1024, "signature with default");
cmp_ok(total_size(sub ($foo, @bar) {}), '>', 0, "more signature");
cmp_ok(total_size(sub (%baz) {}), '>', 0, "more slurpy");

is($warn_count, undef, 'No warnings emitted');

done_testing();