Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
More tests for gcd and lcm.
  • Loading branch information
colomon committed Oct 28, 2011
1 parent 891aa14 commit 19c97a0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
24 changes: 23 additions & 1 deletion S03-operators/gcd.t
@@ -1,6 +1,6 @@
use v6;
use Test;
plan 5;
plan 16;

# L<S32::Numeric/Numeric/"=item gcd">

Expand All @@ -16,5 +16,27 @@ is -432 gcd 63, 9, "The gcd of -432 and 63 is 9";
is 4342 gcd 65536, 2, "The gcd of 4342 and 65536 is 2";
isa_ok 4342 gcd 65536, Int, "The gcd of 4342 and 65536 is an Int";

is ([gcd] 25..26), 1, '[gcd] Range works';
{
my @a = 50, 70, 100, 2005;
is ([gcd] @a), 5, '[gcd] array works';
}

{
is 10.1 gcd 5.3, 5, "gcd converts Rats to Ints correctly";
isa_ok 10.1 gcd 5.3, Int, "and the result is an Int";
is 10.1e0 gcd 5.3e0, 5, "gcd converts Nums to Ints correctly";
isa_ok 10.1e0 gcd 5.3e0, Int, "and the result is an Int";
}

#?rakudo skip "big ints NYI"
{
is 123123123123123123123123123 gcd 3, 3, "gcd handles big Int and small Int";
is 123123123123123123123123123 gcd 2, 1, "gcd handles big Int and small Int";
is 3 gcd 123123123123123123123123123, 3, "gcd handles small Int and big Int";
is 7 gcd 123123123123123123123123123, 1, "gcd handles small Int and big Int";
is 123123123123123123123123123123 gcd 123123123123123123123123123, 123, "gcd handles big Int and big Int";
}

done;
# vim: ft=perl6
19 changes: 18 additions & 1 deletion S03-operators/lcm.t
@@ -1,6 +1,6 @@
use v6;
use Test;
plan 6;
plan 15;

# L<S32::Numeric/Numeric/"=item lcm">

Expand All @@ -18,5 +18,22 @@ isa_ok 4342 lcm 65536, Int, "The lcm of 4342 and 65536 is an Int";

is ([lcm] 1..3), 6, '[lcm] Range works';

{
is 10.1 lcm 5.3, 10, "lcm converts Rats to Ints correctly";
isa_ok 10.1 lcm 5.3, Int, "and the result is an Int";
is 10.1e0 lcm 5.3e0, 10, "lcm converts Nums to Ints correctly";
isa_ok 10.1e0 lcm 5.3e0, Int, "and the result is an Int";
}

#?rakudo skip "big ints NYI"
{
is 123123123123123123123123123 lcm 3, 123123123123123123123123123, "lcm handles big Int and small Int";
is 123123123123123123123123123 lcm 2, 246246246246246246246246246, "lcm handles big Int and small Int";
is 3 lcm 123123123123123123123123123, 123123123123123123123123123, "lcm handles small Int and big Int";
is 7 lcm 123123123123123123123123123, 861861861861861861861861861, "lcm handles small Int and big Int";
is 123123123123123123123123123123 lcm 123123123123123123123123123,
123246369492615738861985108107984861738615492369246123, "lcm handles big Int and big Int";
}

done;
# vim: ft=perl6

0 comments on commit 19c97a0

Please sign in to comment.