diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-04-30 20:06:11 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-04-30 20:09:40 -0500 |
commit | ddd601047a76fb519d4acba4c59d77ebfde1fa6e (patch) | |
tree | 2a5840e61ce7a6868d522015ddc74c0f938d9be5 /t/004-eval.t | |
parent | ce489a3dcdcd8dcc1dec85b92698e0b94c85ca38 (diff) | |
download | carp-always-color-ddd601047a76fb519d4acba4c59d77ebfde1fa6e.tar.gz carp-always-color-ddd601047a76fb519d4acba4c59d77ebfde1fa6e.zip |
only color the actual warning/error
also clean up a couple more edge cases
Diffstat (limited to 't/004-eval.t')
-rw-r--r-- | t/004-eval.t | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/t/004-eval.t b/t/004-eval.t new file mode 100644 index 0000000..3500dc0 --- /dev/null +++ b/t/004-eval.t @@ -0,0 +1,40 @@ +#!/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 => 2; +} + +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(<<EOF, + use Carp::Always::Color; + eval { die "foo" }; + if (\$@) { + die \$@; + } +EOF + "\e[31m\e[31mfoo\e[m\e[m at -e line 4\n", + "rethrowing works"); + +output_is(<<EOF, + use Carp::Always::Color; + sub foo { + eval { die "foo" }; + if (\$@) { + die \$@; + } + } + foo(); +EOF + "\e[31m\e[31mfoo\e[m\e[m at -e line 5\n\tmain::foo() called at -e line 8\n", + "rethrowing works inside functions"); |