]> git.vpit.fr Git - perl/modules/Lexical-Types.git/blob - t/11-integrate.t
Renumber test files
[perl/modules/Lexical-Types.git] / t / 11-integrate.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 5 + 4;
7
8 {
9  package MyTypes;
10
11  BEGIN { require Lexical::Types; }
12
13  sub import {
14   eval 'package Str; package Int';
15   Lexical::Types->import(
16    as => sub { __PACKAGE__, 'new_' . lc($_[0]) }
17   );
18  }
19
20  sub unimport {
21   Lexical::Types->unimport;
22  }
23
24  sub new_str {
25   $_[1] = 'str:' . (caller(0))[2];
26   local $Test::Builder::Level = $Test::Builder::Level + 1;
27   Test::More::is($_[2], 'Str', 'original type is correct');
28   ();
29  }
30
31  sub new_int {
32   $_[1] = (caller(0))[2];
33   local $Test::Builder::Level = $Test::Builder::Level + 1;
34   Test::More::is($_[2], 'Int', 'original type is correct');
35   ();
36  }
37 }
38
39 {
40  BEGIN { MyTypes->import }
41  my Str $x;
42  is $x, 'str:' . (__LINE__-1), 'MyTypes->new_str 1';
43  {
44   BEGIN { MyTypes->unimport }
45   my Str $y;
46   is $y, undef, 'pragma not in use';
47   {
48    BEGIN { MyTypes->import }
49    my Int $z;
50    is $z, __LINE__-1, 'MyTypes->new_int 1';
51   }
52  }
53  my Str $y;
54  is $y, 'str:' . (__LINE__-1), 'MyTypes->new_str 2';
55  my Int $z;
56  is $z, __LINE__-1, 'MyTypes->new_int 2';
57 }