Permalink
Browse files

Simple tests for adding negative numbers.

  • Loading branch information...
1 parent 93f1578 commit 1d897d3439328996354181154431cdef27c64603 @colomon committed May 11, 2011
Showing with 27 additions and 0 deletions.
  1. +27 −0 t/02-arith.t
View
@@ -13,6 +13,33 @@ plan *;
is $c, "100000000000000001", "and it's 100000000000000001";
}
+{
+ my $a = Math::BigInt.new("100000000000000000");
+ my $b = Math::BigInt.new("-1");
+
+ my $c = $a + $b;
+ isa_ok $c, Math::BigInt, "100000000000000000 + -1 is a BigInt";
+ is $c, "99999999999999999", "and it's 99999999999999999";
+}
+
+{
+ my $a = Math::BigInt.new("-100000000000000000");
+ my $b = Math::BigInt.new("1");
+
+ my $c = $a + $b;
+ isa_ok $c, Math::BigInt, "-100000000000000000 + 1 is a BigInt";
+ is $c, "-99999999999999999", "and it's -99999999999999999";
+}
+
+{
+ my $a = Math::BigInt.new("-100000000000000000");
+ my $b = Math::BigInt.new("-1");
+
+ my $c = $a + $b;
+ isa_ok $c, Math::BigInt, "-100000000000000000 + -1 is a BigInt";
+ is $c, "-100000000000000001", "and it's -100000000000000001";
+}
+
# adding normal ints and BigInts
{
my $a = Math::BigInt.new("100000000000000000");

0 comments on commit 1d897d3

Please sign in to comment.