1#!perl
2
3use strict;
4use warnings;
5
6use Test::More 0.88 tests => 2;
7use Capture::Tiny ':all';
8
9my ($stdout, $stderr, $exit) = capture {
10    system("'$^X' -Iblib/lib t/test-script.pl");
11};
12
13ok(defined($exit) && $exit == 0, 'Expect exit status of 0');
14
15my $expected = <<'END_EXPECTED';
16first call to atexit() returned value of type CODE
17second call to atexit() returned value of type CODE
18*** Leaving Scope 2 ***
19cleanup() executing: args = Scope 2, Callback 2
20*** Finished Scope 2 ***
21*** Leaving Scope 1 ***
22cleanup() executing: args = Scope 1, Callback 2
23cleanup() executing: args = Scope 1, Callback 1
24*** Finished Scope 1 ***
25*** Now performing program-exit processing ***
26cleanup() executing: args = This call was registered second
27cleanup() executing: args = This call was registered first
28END_EXPECTED
29
30is($stdout, $expected, "Did we get expected output?");
31