File: before_510.t

package info (click to toggle)
libmethod-signatures-perl 20170211-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 672 kB
  • sloc: perl: 3,860; makefile: 2
file content (54 lines) | stat: -r--r--r-- 1,150 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
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;

plan skip_all => "This only applies to Perls before 5.10" if $] >= 5.010;

use Method::Signatures;

{
    eval
    q{
        func neg_and_odd_and_prime ($x where [0..10]) {
            return 1;
        }
    };

    like $@, qr{\Q'where' constraint only available under Perl 5.10 or later.\E},
             "Perls <5.10 properly error out on where constraints";
}

{
    eval
    q{
        package Stuff;
        use Method::Signatures;

        method add($this //= 23, $that //= 42) {
            return $this + $that;
        }
    };

    like $@, qr{\Q'//=' defaults only available under Perl 5.10 or later.\E},
            "Perls <5.10 properly error out on //= declaration";
}

{
    eval
    q{
        package Stuff;
        use Method::Signatures;
        method add($this = 23 when '', $that = 42 when '') {
            no warnings 'uninitialized';
            return $this + $that;
        }
    };

    like $@, qr{\Q'when' modifier on default only available under Perl 5.10 or later.\E},
            "Perls <5.10 properly error out on 'when' conditions";
}

done_testing;