]> git.vpit.fr Git - perl/modules/Lexical-Types.git/blob - t/21-scalar-padsv.t
Bump perl dependency to 5.8.4
[perl/modules/Lexical-Types.git] / t / 21-scalar-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 {
36  use Lexical::Types as => sub {
37   # In 5.10, this closure is compiled before hints are enabled, so no hintseval
38   # op is added at compile time to propagate the hints inside the eval.
39   # That's why we need to re-use Lexical::Types explicitely.
40   eval 'use Lexical::Types; my Int $x';
41   @_;
42  };
43
44  my Int $x;
45  is_deeply \@lines, [ 1, __LINE__-1 ], 'hooking inside the \'as\' callback';
46 }