1#!perl
2# -*- mode: cperl ; compile-command: "cd .. ; ./Build ; prove -vb t/99-*.t" -*-
3use strict;
4use warnings;
5
6# Tests for the purpose of shutting up Devel::Cover about some stuff
7# that really is tested.  Like, trust me already?
8
9use Test::Trap;
10
11# Set up a plan:
12use Test::Builder; BEGIN { my $t = Test::Builder->new; $t->plan( tests => 7 ) }
13
14BEGIN {
15  scalar trap { exists &Test::More::ok };
16  $trap->return_nok( 0, '&Test::More::ok not created before the use' );
17  $trap->quiet;
18}
19
20use Test::More;
21
22BEGIN {
23  scalar trap { exists &Test::More::ok };
24  $trap->return_ok( 0, '&Test::More::ok created now' );
25  $trap->quiet;
26}
27
28trap {
29  Test::Trap::Builder->new->layer_implementation('Test::Trap', []);
30};
31$trap->die_like( qr/^Unknown trap layer \"ARRAY/, 'Cannot specify layers as arrayrefs' );
32
33my $early_exit = 1;
34END {
35  ok( $early_exit, 'Failing to raise an exception: Early exit' );
36  is( $?, 8, 'Exiting with exit code 8' );
37  # let Test::More handle exit codes different from 8:
38  $? = 0 if $? == 8;
39}
40$trap->Exception("Failing");
41undef $early_exit;
42