1use warnings;
2use strict;
3
4use Test::More tests => 53;
5
6BEGIN { $SIG{__WARN__} = sub { die "WARNING: $_[0]" }; }
7
8require_ok "Lexical::Var";
9
10eval q{ Lexical::Var->import(); };
11like $@, qr/\ALexical::Var does no default importation/;
12eval q{ Lexical::Var->unimport(); };
13like $@, qr/\ALexical::Var does no default unimportation/;
14eval q{ Lexical::Var->import('foo'); };
15like $@, qr/\Aimport list for Lexical::Var must alternate /;
16eval q{ Lexical::Var->import('$foo', \1); };
17like $@, qr/\Acan't set up lexical variable outside compilation/;
18eval q{ Lexical::Var->unimport('$foo'); };
19like $@, qr/\Acan't set up lexical variable outside compilation/;
20
21eval q{ use Lexical::Var; };
22like $@, qr/\ALexical::Var does no default importation/;
23eval q{ no Lexical::Var; };
24like $@, qr/\ALexical::Var does no default unimportation/;
25
26eval q{ use Lexical::Var 'foo'; };
27like $@, qr/\Aimport list for Lexical::Var must alternate /;
28
29eval q{ use Lexical::Var undef, \1; };
30like $@, qr/\Avariable name is not a string/;
31eval q{ use Lexical::Var \1, sub{}; };
32like $@, qr/\Avariable name is not a string/;
33eval q{ use Lexical::Var undef, "wibble"; };
34like $@, qr/\Avariable name is not a string/;
35
36eval q{ use Lexical::Var 'foo', \1; };
37like $@, qr/\Amalformed variable name/;
38eval q{ use Lexical::Var '$', \1; };
39like $@, qr/\Amalformed variable name/;
40eval q{ use Lexical::Var '$foo(bar', \1; };
41like $@, qr/\Amalformed variable name/;
42eval q{ use Lexical::Var '$1foo', \1; };
43like $@, qr/\Amalformed variable name/;
44eval q{ use Lexical::Var '$foo\x{e9}bar', \1; };
45like $@, qr/\Amalformed variable name/;
46eval q{ use Lexical::Var '$foo::bar', \1; };
47like $@, qr/\Amalformed variable name/;
48eval q{ use Lexical::Var '!foo', \1; };
49like $@, qr/\Amalformed variable name/;
50eval q{ use Lexical::Var 'foo', "wibble"; };
51like $@, qr/\Amalformed variable name/;
52
53eval q{ use Lexical::Var '$foo', "wibble"; };
54like $@, qr/\Avariable is not scalar reference/;
55
56eval q{ no Lexical::Var undef, \1; };
57like $@, qr/\Avariable name is not a string/;
58eval q{ no Lexical::Var \1, sub{}; };
59like $@, qr/\Avariable name is not a string/;
60eval q{ no Lexical::Var undef, "wibble"; };
61like $@, qr/\Avariable name is not a string/;
62
63eval q{ no Lexical::Var 'foo', \1; };
64like $@, qr/\Amalformed variable name/;
65eval q{ no Lexical::Var '$', \1; };
66like $@, qr/\Amalformed variable name/;
67eval q{ no Lexical::Var '$foo(bar', \1; };
68like $@, qr/\Amalformed variable name/;
69eval q{ no Lexical::Var '$foo::bar', \1; };
70like $@, qr/\Amalformed variable name/;
71eval q{ no Lexical::Var '!foo', \1; };
72like $@, qr/\Amalformed variable name/;
73
74require_ok "Lexical::Sub";
75
76eval q{ Lexical::Sub->import(); };
77like $@, qr/\ALexical::Sub does no default importation/;
78eval q{ Lexical::Sub->unimport(); };
79like $@, qr/\ALexical::Sub does no default unimportation/;
80eval q{ Lexical::Sub->import('foo'); };
81like $@, qr/\Aimport list for Lexical::Sub must alternate /;
82
83eval q{ use Lexical::Sub; };
84like $@, qr/\ALexical::Sub does no default importation/;
85eval q{ no Lexical::Sub; };
86like $@, qr/\ALexical::Sub does no default unimportation/;
87
88eval q{ use Lexical::Sub 'foo'; };
89like $@, qr/\Aimport list for Lexical::Sub must alternate /;
90
91eval q{ use Lexical::Sub undef, sub{}; };
92like $@, qr/\Asubroutine name is not a string/;
93eval q{ use Lexical::Sub sub{}, \1; };
94like $@, qr/\Asubroutine name is not a string/;
95eval q{ use Lexical::Sub undef, "wibble"; };
96like $@, qr/\Asubroutine name is not a string/;
97
98eval q{ use Lexical::Sub '$', sub{}; };
99like $@, qr/\Amalformed subroutine name/;
100eval q{ use Lexical::Sub 'foo(bar', sub{}; };
101like $@, qr/\Amalformed subroutine name/;
102eval q{ use Lexical::Sub '1foo', sub{}; };
103like $@, qr/\Amalformed subroutine name/;
104eval q{ use Lexical::Sub 'foo\x{e9}bar', sub{}; };
105like $@, qr/\Amalformed subroutine name/;
106eval q{ use Lexical::Sub 'foo::bar', sub{}; };
107like $@, qr/\Amalformed subroutine name/;
108eval q{ use Lexical::Sub '!foo', sub{}; };
109like $@, qr/\Amalformed subroutine name/;
110
111eval q{ use Lexical::Sub 'foo', "wibble"; };
112like $@, qr/\Asubroutine is not code reference/;
113
114eval q{ no Lexical::Sub undef, sub{}; };
115like $@, qr/\Asubroutine name is not a string/;
116eval q{ no Lexical::Sub sub{}, \1; };
117like $@, qr/\Asubroutine name is not a string/;
118eval q{ no Lexical::Sub undef, "wibble"; };
119like $@, qr/\Asubroutine name is not a string/;
120
121eval q{ no Lexical::Sub '$', sub{}; };
122like $@, qr/\Amalformed subroutine name/;
123eval q{ no Lexical::Sub 'foo(bar', sub{}; };
124like $@, qr/\Amalformed subroutine name/;
125eval q{ no Lexical::Sub 'foo::bar', sub{}; };
126like $@, qr/\Amalformed subroutine name/;
127eval q{ no Lexical::Sub '!foo', sub{}; };
128like $@, qr/\Amalformed subroutine name/;
129
1301;
131