I propose the following patch. The effect is to propagate the provided message
(if any) when one comparison value is undefined, such that the point of failure
in the test case is easier to locate. Similar code exists elsewhere in
Test::Unit::Assert (e.g. $assert_subs{'str_equals'}).
Comments?
Thanks,
&ers
-----begin Test-Unit-0.25-anders1.patch-----
diff -Naur Test-Unit-0.25/lib/Test/Unit/Assert.pm
Test-Unit-0.25-anders1/lib/Test/Unit/Assert.pm
--- Test-Unit-0.25/lib/Test/Unit/Assert.pm 2005-10-15 13:25:28.000000000
-0700
+++ Test-Unit-0.25-anders1/lib/Test/Unit/Assert.pm 2008-12-16
17:44:28.071447000 -0800
@@ -124,7 +124,7 @@
# pass
}
elsif (defined($args[0]) xor defined($args[1])) {
- $self->fail('one arg was not defined');
+ $self->fail(@args>2 ? join('', @args[2..$#args]) : 'one arg was
not defined');
}
elsif (is_numeric($args[0])) {
$self->assert_num_equals(@args);
diff -Naur Test-Unit-0.25/t/tlib/AssertTest.pm
Test-Unit-0.25-anders1/t/tlib/AssertTest.pm
--- Test-Unit-0.25/t/tlib/AssertTest.pm 2005-10-15 14:19:18.000000000 -0700
+++ Test-Unit-0.25-anders1/t/tlib/AssertTest.pm 2008-12-16 17:44:03.032513000
-0800
@@ -25,6 +25,8 @@
# A false-negative that burned me; problem with is_numeric
# Test must be all on one line
[ __LINE__, sub { shift->assert_equals("start
o:MyClass=HASH(0x1404343f0) | any o:MyClass=HASH(0x1404343f0) e:start | any
o:MyClass=HASH(0x1404343f0) e:in", "start o: e: | any o:start e: | any o:in
e:"); } ],
+ "explanation" => [ __LINE__, sub { shift->assert_equals(0, undef,
"explanation") }],
+ "one arg was not defined" => [ __LINE__, sub { shift->assert_equals(0,
undef) }],
);
}
-----end Test-Unit-0.25-anders1.patch-----
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may
contain
confidential information. Any unauthorized review, use, disclosure or
distribution
is prohibited. If you are not the intended recipient, please contact the
sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Perlunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/perlunit-users