File: 07-empty-block.t

package info (click to toggle)
libfilter-signatures-perl 0.19-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 236 kB
  • sloc: perl: 1,321; makefile: 2
file content (49 lines) | stat: -rw-r--r-- 1,122 bytes parent folder | download | duplicates (2)
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
44
45
46
47
48
49
#!perl -w
use strict;
use Test::More tests => 6;
use Data::Dumper;

require Filter::signatures;
# Mimic parts of the setup of Filter::Simple
my $extractor =
$Filter::Simple::placeholder = $Filter::Simple::placeholder
    = qr/\Q$;\E(.{4})\Q$;\E/s;

if( $^V >= 5.20 ) {
  require warnings; warnings->unimport('experimental::signatures');
  require feature; feature->import( 'signatures');
};

sub run_code_ok {
    my( $name, $expected,$decl, @args ) = @_;
    local $_ = $decl;
    my $org;
    if( $^V >= 5.20 ) {
        $org = eval $_
            or die $@;
    };
    Filter::signatures::transform_arguments();
    no warnings 'redefine';
    my $l = eval $_;
    die $@ if $@;
    my $got = $l->(@args);
    my $native = $org ? $org->(@args ): $expected;
    is $got, $expected, $name
        or do { diag $decl; diag $_ };
    is $expected, $native, "Sanity check vs native code";
}

run_code_ok( "No signature", undef, <<'SUB' );
#line 1
sub {}
SUB

run_code_ok( "Empty block", undef, <<'SUB' );
#line 1
sub () {}
SUB

run_code_ok( "Empty block with defaults", undef, <<'SUB' );
#line 1
sub ($name='batman') {}
SUB