summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-03-08 21:08:21 -0600
committerJesse Luehrs <doy@tozt.net>2012-03-08 21:08:21 -0600
commitb9841300cb47cee9d6cda24b3477c763530b947f (patch)
treeaeb3dfebc87c767c57e5583fdf4bdd664f2cdfc8
parent0a0a01d1d8b1d48d68e6b8e37fc38dd4ca553b97 (diff)
downloadcarp-always-color-b9841300cb47cee9d6cda24b3477c763530b947f.tar.gz
carp-always-color-b9841300cb47cee9d6cda24b3477c763530b947f.zip
fix test suite for carp dot stuff
-rw-r--r--t/detect.t12
-rw-r--r--t/eval.t12
-rw-r--r--t/html.t20
-rw-r--r--t/term.t24
4 files changed, 34 insertions, 34 deletions
diff --git a/t/detect.t b/t/detect.t
index 6c4f7d3..5104fa0 100644
--- a/t/detect.t
+++ b/t/detect.t
@@ -8,22 +8,22 @@ BEGIN {
plan tests => 2;
}
-sub output_is {
+sub output_like {
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);
+ like($pty->read, $expected, $desc);
}
-output_is(<<EOF,
+output_like(<<EOF,
use Carp::Always::Color;
warn "foo";
EOF
- "\e[33mfoo\e[m at -e line 2\n",
+ qr/\e\[33mfoo\e\[m at -e line 2\b/,
"detection works for terminal output");
-output_is(<<EOF,
+output_like(<<EOF,
my \$stderr;
BEGIN {
close(STDERR);
@@ -33,5 +33,5 @@ output_is(<<EOF,
warn "foo";
print \$stderr;
EOF
- "<span style=\"color:#880\">foo</span> at -e line 7\n",
+ qr+<span style=\"color:#880\">foo</span> at -e line 7\b+,
"detection works for terminal output");
diff --git a/t/eval.t b/t/eval.t
index 7ccd181..fbed876 100644
--- a/t/eval.t
+++ b/t/eval.t
@@ -8,25 +8,25 @@ BEGIN {
plan tests => 2;
}
-sub output_is {
+sub output_like {
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);
+ like($pty->read, $expected, $desc);
}
-output_is(<<EOF,
+output_like(<<EOF,
use Carp::Always::Color;
eval { die "foo" };
if (\$@) {
die \$@;
}
EOF
- "\e[31m\e[31mfoo\e[m\e[m at -e line 2\n\teval {...} called at -e line 4\n",
+ qr/\e\[31m\e\[31mfoo\e\[m\e\[m at -e line 2\.?\n\teval {\.\.\.} called at -e line 4\b/,
"rethrowing works");
-output_is(<<EOF,
+output_like(<<EOF,
use Carp::Always::Color;
sub foo {
eval { die "foo" };
@@ -36,5 +36,5 @@ output_is(<<EOF,
}
foo();
EOF
- "\e[31m\e[31mfoo\e[m\e[m at -e line 3\n\teval {...} called at -e line 3\n\tmain::foo() called at -e line 5\n\tmain::foo() called at -e line 8\n",
+ qr/\e\[31m\e\[31mfoo\e\[m\e\[m at -e line 3\.?\n\teval {\.\.\.} called at -e line 3\n\tmain::foo\(\) called at -e line 5\.?\n\tmain::foo\(\) called at -e line 8\n/,
"rethrowing works inside functions");
diff --git a/t/html.t b/t/html.t
index f51914d..1b6188c 100644
--- a/t/html.t
+++ b/t/html.t
@@ -8,44 +8,44 @@ BEGIN {
plan tests => 4;
}
-sub output_is {
+sub output_like {
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);
+ like($pty->read, $expected, $desc);
}
-output_is(<<EOF,
+output_like(<<EOF,
use Carp::Always::Color::HTML;
warn "foo";
EOF
- "<span style=\"color:#880\">foo</span> at -e line 2\n",
+ qr+<span style=\"color:#880\">foo</span> at -e line 2\b+,
"simple warns work");
-output_is(<<EOF,
+output_like(<<EOF,
use Carp::Always::Color::HTML;
sub foo {
warn "foo";
}
foo();
EOF
- "<span style=\"color:#880\">foo</span> at -e line 3\n\tmain::foo() called at -e line 5\n",
+ qr+<span style=\"color:#880\">foo</span> at -e line 3\.?\n\tmain::foo\(\) called at -e line 5\n+,
"warns with a stacktrace work");
-output_is(<<EOF,
+output_like(<<EOF,
use Carp::Always::Color::HTML;
die "foo";
EOF
- "<span style=\"color:#800\">foo</span> at -e line 2\n",
+ qr+<span style=\"color:#800\">foo</span> at -e line 2\b+,
"simple dies work");
-output_is(<<EOF,
+output_like(<<EOF,
use Carp::Always::Color::HTML;
sub foo {
die "foo";
}
foo();
EOF
- "<span style=\"color:#800\">foo</span> at -e line 3\n\tmain::foo() called at -e line 5\n",
+ qr+<span style=\"color:#800\">foo</span> at -e line 3\.?\n\tmain::foo\(\) called at -e line 5\n+,
"dies with a stacktrace work");
diff --git a/t/term.t b/t/term.t
index 8eb479a..2df6b64 100644
--- a/t/term.t
+++ b/t/term.t
@@ -8,51 +8,51 @@ BEGIN {
plan tests => 5;
}
-sub output_is {
+sub output_like {
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);
+ like($pty->read, $expected, $desc);
}
-output_is(<<EOF,
+output_like(<<EOF,
use Carp::Always::Color::Term;
warn "foo";
EOF
- "\e[33mfoo\e[m at -e line 2\n",
+ qr/\e\[33mfoo\e\[m at -e line 2\b/,
"simple warns work");
-output_is(<<EOF,
+output_like(<<EOF,
use Carp::Always::Color::Term;
sub foo {
warn "foo";
}
foo();
EOF
- "\e[33mfoo\e[m at -e line 3\n\tmain::foo() called at -e line 5\n",
+ qr/\e\[33mfoo\e\[m at -e line 3\.?\n\tmain::foo\(\) called at -e line 5\n/,
"warns with a stacktrace work");
-output_is(<<EOF,
+output_like(<<EOF,
use Carp::Always::Color::Term;
die "foo";
EOF
- "\e[31mfoo\e[m at -e line 2\n",
+ qr/\e\[31mfoo\e\[m at -e line 2\b/,
"simple dies work");
-output_is(<<EOF,
+output_like(<<EOF,
use Carp::Always::Color::Term;
sub foo {
die "foo";
}
foo();
EOF
- "\e[31mfoo\e[m at -e line 3\n\tmain::foo() called at -e line 5\n",
+ qr/\e\[31mfoo\e\[m at -e line 3\.?\n\tmain::foo\(\) called at -e line 5\n/,
"dies with a stacktrace work");
-output_is(<<EOF,
+output_like(<<EOF,
use Carp::Always::Color::Term;
die "foo at bar line 23";
EOF
- "\e[31mfoo at bar line 23\e[m at -e line 2\n",
+ qr/\e\[31mfoo at bar line 23\e\[m at -e line 2\b/,
"weird messages work");