1#!perl -Tw
2
3use warnings;
4use strict;
5use 5.010;
6
7use Test::More tests => 3;
8
9use Carp::Assert::More;
10
11sub important_function {
12    assert_context_nonvoid( 'important_function must not be called in void context' );
13
14    return 2112;
15}
16
17local $@;
18$@ = '';
19
20
21# Keep the value returned.
22eval {
23    my $x = important_function();
24};
25is( $@, '' );
26
27
28# Keep the value in an array.
29eval {
30    my @x = important_function();
31};
32is( $@, '' );
33
34
35# Ignore the value returned.
36eval {
37    important_function();
38};
39like( $@, qr/\QAssertion (important_function must not be called in void context) failed!/ );
40
41
42exit 0;
43