Permalink
Browse files

Change the cmp_ok() file/line faking to something that won't make NYT…

…Prof cry.
  • Loading branch information...
1 parent 190eac7 commit be184df62f9a8f3e548135aa3a69b51e77084141 @schwern schwern committed Nov 13, 2009
Showing with 10 additions and 9 deletions.
  1. +2 −1 lib/Test/Builder.pm
  2. +6 −6 t/fail-more.t
  3. +2 −2 t/undef.t
View
@@ -1059,8 +1059,9 @@ sub cmp_ok {
my($pack, $file, $line) = $self->caller();
+ # This is so that warnings come out at the caller's level
$test = eval qq[
-#line 1 "cmp_ok [from $file line $line]"
+#line $line "(eval in cmp_ok) $file"
\$got $type \$expect;
];
$error = $@;
View
@@ -411,19 +411,19 @@ ERR
my $warnings = '';
local $SIG{__WARN__} = sub { $warnings .= join '', @_ };
-# line 404
+# line 415
cmp_ok( 42, '==', "foo", ' == with strings' );
out_ok( <<OUT, <<ERR );
not ok - == with strings
OUT
# Failed test ' == with strings'
-# at $0 line 404.
+# at $0 line 415.
# got: 42
# expected: foo
ERR
My::Test::like(
$warnings,
- qr/^Argument "foo" isn't numeric in .* at cmp_ok \[from $Filename line 404\] line 1\.\n$/
+ qr/^Argument "foo" isn't numeric in .* at \(eval in cmp_ok\) $Filename line 415\.\n$/
);
$warnings = '';
}
@@ -433,7 +433,7 @@ ERR
my $warnings = '';
local $SIG{__WARN__} = sub { $warnings .= join '', @_ };
-#line 426
+#line 437
cmp_ok( undef, "ne", "", "undef ne empty string" );
$TB->is_eq( $out->read, <<OUT );
@@ -445,15 +445,15 @@ OUT
$TB->is_eq( $err->read, <<ERR );
# Failed test 'undef ne empty string'
-# at $0 line 426.
+# at $0 line 437.
# got: undef
# expected: ''
ERR
}
My::Test::like(
$warnings,
- qr/^Use of uninitialized value.* in string ne at cmp_ok \[from $Filename line 426\] line 1\.\n\z/
+ qr/^Use of uninitialized value.* in string ne at \(eval in cmp_ok\) $Filename line 437.\n\z/
);
}
View
@@ -70,9 +70,9 @@ eq_hash ( { foo => undef, bar => { baz => undef, moo => 23 } },
no_warnings;
-#line 64
+#line 74
cmp_ok( undef, '<=', 2, ' undef <= 2' );
-warnings_like(qr/Use of uninitialized value.* at cmp_ok \[from $Filename line 64\] line 1\.\n/);
+warnings_like(qr/Use of uninitialized value.* at \(eval in cmp_ok\) $Filename line 74\.\n/);

0 comments on commit be184df

Please sign in to comment.