]> git.vpit.fr Git - perl/modules/Lexical-Types.git/blob - t/13-padsv.t
0509260d821f246df2c8770abec9b0b86e37851d
[perl/modules/Lexical-Types.git] / t / 13-padsv.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Config qw<%Config>;
7
8 use Test::More tests => 4;
9
10 sub Str::TYPEDSCALAR {
11  my $buf = (caller(0))[2];
12  open $_[1], '<', \$buf;
13  ()
14 }
15
16 {
17  use Lexical::Types;
18
19  my Str $x;
20  our $r = <$x>;
21  is $r, __LINE__-2, 'trick for our - readline';
22
23  my Str $y;
24  my $s = <$y>;
25  is $s, __LINE__-2, 'trick for my - readline';
26
27  my $z = 7;
28  is $z, 7, 'trick for others';
29 }
30
31 my @lines;
32
33 sub Int::TYPEDSCALAR { push @lines, (caller(0))[2]; () }
34
35 SKIP: {
36  skip 'Broken with threaded perls before 5.8.4' => 1
37                                       if $Config{useithreads} and $] < 5.008004;
38
39  use Lexical::Types as => sub {
40   # In 5.10, this closure is compiled before hints are enabled, so no hintseval
41   # op is added at compile time to propagate the hints inside the eval.
42   # That's why we need to re-use Lexical::Types explicitely.
43   eval 'use Lexical::Types; my Int $x';
44   @_;
45  };
46
47  my Int $x;
48  is_deeply \@lines, [ 1, __LINE__-1 ], 'hooking inside the \'as\' callback';
49 }