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