Permalink
Browse files

Fix Math::BigInt.succ and .pred so that they do not modify the origin…

…al object. Add tests.
  • Loading branch information...
1 parent 3b298b9 commit 25fdf3faa4605b8fa87e5ee5e111fb733e8412d7 @colomon committed Jan 31, 2011
Showing with 12 additions and 2 deletions.
  1. +2 −2 lib/Math/BigInt.pm
  2. +5 −0 t/01-basic.t
  3. +5 −0 t/05-metaops.t
View
@@ -55,8 +55,8 @@ class Math::BigInt does Real {
!bdIsZero($x.bd);
}
- method succ(Math::BigInt $x:) { bdIncrement($x.bd); self; }
- method pred(Math::BigInt $x:) { bdDecrement($x.bd); self; }
+ method succ(Math::BigInt $x:) { $x + 1; }
+ method pred(Math::BigInt $x:) { $x - 1; }
multi sub postfix:<L>(Str $a) is export(:DEFAULT) {
Math::BigInt.new($a);
View
@@ -45,4 +45,9 @@ plan *;
ok 1L, "and it's True";
}
+{
+ my @fifty = 1L ... 50L;
+ is ~@fifty, ~(1..50), "1L ... 50L works right";
+}
+
done;
View
@@ -21,6 +21,11 @@ plan *;
}
is ~$b, ~$a, 'L* and * both generate is exactly 50!';
+ my @fifty = 1L ... 50L;
+ is ~@fifty, ~(1..50), "1L ... 50L works right";
+ # is ~reducewith(&infix:<*>, @fifty), ~$a, 'and so does reduced * on 1L..50L';
+ is ~reducewith(&infix:<L*>, 1..50), ~$a, 'and so does reduced L* on 1..50';
+
# skip "Rakudo does not properly find infix:<L*> for [L*]";
# is ~([L*] 1..50), ~$a, 'and so does [L*] 1..50';
}

0 comments on commit 25fdf3f

Please sign in to comment.