Regenerate test files
[gitmo/Mouse.git] / t / 010_basics / 007_always_strict_warnings.t
CommitLineData
60ad2cb7 1#!/usr/bin/perl
fde8e43f 2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
60ad2cb7 5
fde8e43f 6use Test::More;
60ad2cb7 7
8# for classes ...
9{
10 package Foo;
11 use Mouse;
12
13 eval '$foo = 5;';
14 ::ok($@, '... got an error because strict is on');
15 ::like($@, qr/Global symbol \"\$foo\" requires explicit package name at/, '... got the right error');
16
17 {
18 my $warn;
19 local $SIG{__WARN__} = sub { $warn = $_[0] };
20
21 ::ok(!$warn, '... no warning yet');
22
23 eval 'my $bar = 1 + "hello"';
24
25 ::ok($warn, '... got a warning');
26 ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning');
27 }
28}
29
30# and for roles ...
31{
32 package Bar;
33 use Mouse::Role;
34
35 eval '$foo = 5;';
36 ::ok($@, '... got an error because strict is on');
37 ::like($@, qr/Global symbol \"\$foo\" requires explicit package name at/, '... got the right error');
38
39 {
40 my $warn;
41 local $SIG{__WARN__} = sub { $warn = $_[0] };
42
43 ::ok(!$warn, '... no warning yet');
44
45 eval 'my $bar = 1 + "hello"';
46
47 ::ok($warn, '... got a warning');
48 ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning');
49 }
50}
60ad2cb7 51
52# and for exporters
53{
54 package Bar;
55 use Mouse::Exporter;
56
57 eval '$foo = 5;';
58 ::ok($@, '... got an error because strict is on');
59 ::like($@, qr/Global symbol \"\$foo\" requires explicit package name at/, '... got the right error');
60
61 {
62 my $warn;
63 local $SIG{__WARN__} = sub { $warn = $_[0] };
64
65 ::ok(!$warn, '... no warning yet');
66
67 eval 'my $bar = 1 + "hello"';
68
69 ::ok($warn, '... got a warning');
70 ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning');
71 }
72}
fde8e43f 73
74done_testing;