File: 80checks%2Bsignature.t

package info (click to toggle)
libdata-checks-perl 0.10-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 320 kB
  • sloc: ansic: 1,095; perl: 805; pascal: 12; sh: 6; makefile: 3
file content (35 lines) | stat: -rw-r--r-- 1,100 bytes parent folder | download
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
#!/usr/bin/perl

use v5.22;
use warnings;

use Test2::V0;

BEGIN {
   plan skip_all => "Data::Checks >= 0.03 is not available"
      unless eval { require Data::Checks;
                    Data::Checks->VERSION( '0.03' ) };
   plan skip_all => "Signature::Attribute::Checked >= 0.04 is not available"
      unless eval { require Signature::Attribute::Checked;
                    Signature::Attribute::Checked->VERSION( '0.04' ) };

   Data::Checks->import(qw( Defined ));
   Signature::Attribute::Checked->import;

   diag( "Data::Checks $Data::Checks::VERSION, " .
         "Signature::Attribute::Checked $Signature::Attribute::Checked::VERSION" );
}

# We know this must be available since Signature::Attribute::Checked would
# depend on it
use Sublike::Extended;
use experimental qw( signatures );

extended sub func ( $x :Checked(Defined) ) { return $x }

is( func(123), 123, 'func() accepts defined argument' );
ok( dies { func(undef) }, 'rejects undefined argument' );
# Don't be overly sensitive on the format of the message, in case it changes.
# It's just for human interest

done_testing;