#!/usr/bin/env perl use strict; use warnings; use Test::More; BEGIN { eval "use IO::Pty::Easy;"; plan skip_all => "IO::Pty::Easy is required for this test" if $@; plan tests => 4; } sub output_is { local $Test::Builder::Level = $Test::Builder::Level + 1; my ($script, $expected, $desc) = @_; my $pty = IO::Pty::Easy->new; $pty->spawn("$^X", "-e", $script); is($pty->read, $expected, $desc); } output_is(<foo at -e line 2\n", "simple warns work"); output_is(<foo at -e line 3\n\tmain::foo() called at -e line 5\n", "warns with a stacktrace work"); output_is(<foo at -e line 2\n", "simple dies work"); output_is(<foo at -e line 3\n\tmain::foo() called at -e line 5\n", "dies with a stacktrace work");