diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-04-30 18:16:01 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-04-30 18:16:01 -0500 |
commit | 5397fc87adb897178a4c23211cb44b310358fbd5 (patch) | |
tree | a8a7b693e593094d97f0f9e4f543e7cebc1bc9a7 /t/003-detect.t | |
parent | 6b58f6f6e15615ef92aba8f24cffe9f43c6b0a49 (diff) | |
download | carp-always-color-5397fc87adb897178a4c23211cb44b310358fbd5.tar.gz carp-always-color-5397fc87adb897178a4c23211cb44b310358fbd5.zip |
tests0.01
Diffstat (limited to 't/003-detect.t')
-rw-r--r-- | t/003-detect.t | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/t/003-detect.t b/t/003-detect.t new file mode 100644 index 0000000..aadcf88 --- /dev/null +++ b/t/003-detect.t @@ -0,0 +1,37 @@ +#!/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; + warn "foo"; +EOF + "\e[33mfoo at -e line 2\e[m\n", + "detection works for terminal output"); + +output_is(<<EOF, + my \$stderr; + BEGIN { + close(STDERR); + open(STDERR, '>', \\\$stderr); + } + use Carp::Always::Color; + warn "foo"; + print \$stderr; +EOF + "<span style=\"color:#880\">foo at -e line 7</span>\n", + "detection works for terminal output"); |