-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path115-compiler-warnings.t
60 lines (51 loc) · 1.75 KB
/
115-compiler-warnings.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!perl
# A test to make sure that C::TinyCompiler handles compiler errors and
# warnings, and differentiates between the two.
use 5.006;
use strict;
use warnings;
use Test::More;
use Test::Warn;
use C::TinyCompiler;
## Single warning ##
my $context = C::TinyCompiler->new;
$context->code('Body') .= q{
#warning "This is only a test"
};
# Test::Warnings API:
##my $warning_message = eval { warning { $context->compile } };
# No dying:
#is($@, '', 'Compiler warning did not cause compiler to croak');
## Got the right message
#like($warning_message, qr/This is only a test/, 'Warning text was properly warned');
# Test::Warn API
eval {
warning_like { $context->compile } qr/This is only a test/,
'Warning text was properly warned';
pass('Compiler warning did not cause the compiler to croak');
} or fail('Compiler warning caused the compiler to croak');
## Multiple warnings ##
$context = C::TinyCompiler->new;
$context->code('Body') .= q{
#warning "Test1"
#warning "Test2"
};
eval {
TODO: {
local $TODO = 'Does not yet support multiple warnings.';
warnings_like { $context->compile } [ qr/Test1/, qr/Test2/ ],
'Both first and second warning are issued';
};
pass('Multiple compiler warnings did not cause the compiler to croak');
} or fail('Multiple compiler warnings caused the compiler to croak');
my $warning_message = eval { warning { $context->compile } };
# Test::Warnings API:
#$warning_message = eval { warning { $context->compile } };
## No dying:
#is($@, '', 'Multiple compiler warning did not cause compiler to croak');
#TODO: {
# local $TODO = 'Does not yet support multiple warnings.';
# like($warning_message, qr/Test1/, 'First warning was properly warned');
# like($warning_message, qr/Test2/, 'Second warning was properly warned');
#};
done_testing;