Skip to content

Commit

Permalink
Test &infix:<===> with 0-denominator Rationals
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Dec 31, 2016
1 parent fea29a3 commit fd7c11b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
25 changes: 24 additions & 1 deletion S32-num/fatrat.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 284;
plan 285;

# Basic test functions specific to FatRats.

Expand Down Expand Up @@ -279,4 +279,27 @@ subtest 'Rational.isNaN' => {
is-deeply <-4/5>.isNaN, False, '-5/5';
}

subtest '=== with 0-denominator FatRats' => {
plan 15;
sub postfix:<F> (Rat $_ --> FatRat) { FatRat.new: .numerator, .denominator }

is-deeply <0/0>F === <0/0>F, True, ' 0/0 === 0/0';
is-deeply <2/0>F === <2/0>F, True, ' 2/0 === 2/0';
is-deeply <-2/0>F === <-2/0>F, True, '-2/0 === -2/0';

is-deeply <0/0>F === <2/0>F, False, ' 0/0 === 2/0';
is-deeply <2/0>F === <0/0>F, False, ' 2/0 === 0/0';
is-deeply <5/0>F === <2/0>F, False, ' 5/0 === 2/0';
is-deeply <2/0>F === <5/0>F, False, ' 2/0 === 5/0';
is-deeply <-5/0>F === <-2/0>F, False, '-5/0 === -2/0';
is-deeply <-2/0>F === <-5/0>F, False, '-2/0 === -5/0';

is-deeply <0/0>F === <2/2>F, False, ' 0/0 === 2/2';
is-deeply <2/2>F === <0/0>F, False, ' 2/2 === 0/0';
is-deeply <5/2>F === <2/0>F, False, ' 5/2 === 2/0';
is-deeply <2/0>F === <5/2>F, False, ' 2/0 === 5/2';
is-deeply <-5/2>F === <-2/0>F, False, '-5/2 === -2/0';
is-deeply <-2/0>F === <-5/2>F, False, '-2/0 === -5/2';
}

# vim: ft=perl6
24 changes: 23 additions & 1 deletion S32-num/rat.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 836;
plan 837;

# Basic test functions specific to rational numbers.

Expand Down Expand Up @@ -355,4 +355,26 @@ subtest 'Rational.isNaN' => {
is-deeply <-4/5>.isNaN, False, '-5/5';
}

subtest '=== with 0-denominator Rats' => {
plan 15;

is-deeply <0/0> === <0/0>, True, ' 0/0 === 0/0';
is-deeply <2/0> === <2/0>, True, ' 2/0 === 2/0';
is-deeply <-2/0> === <-2/0>, True, '-2/0 === -2/0';

is-deeply <0/0> === <2/0>, False, ' 0/0 === 2/0';
is-deeply <2/0> === <0/0>, False, ' 2/0 === 0/0';
is-deeply <5/0> === <2/0>, False, ' 5/0 === 2/0';
is-deeply <2/0> === <5/0>, False, ' 2/0 === 5/0';
is-deeply <-5/0> === <-2/0>, False, '-5/0 === -2/0';
is-deeply <-2/0> === <-5/0>, False, '-2/0 === -5/0';

is-deeply <0/0> === <2/2>, False, ' 0/0 === 2/2';
is-deeply <2/2> === <0/0>, False, ' 2/2 === 0/0';
is-deeply <5/2> === <2/0>, False, ' 5/2 === 2/0';
is-deeply <2/0> === <5/2>, False, ' 2/0 === 5/2';
is-deeply <-5/2> === <-2/0>, False, '-5/2 === -2/0';
is-deeply <-2/0> === <-5/2>, False, '-2/0 === -5/2';
}

# vim: ft=perl6

0 comments on commit fd7c11b

Please sign in to comment.