Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Clean up tests (moritz++) and todo one.
  • Loading branch information
colomon committed Jul 16, 2011
1 parent bbf0a8a commit 9e1a6c4
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions S32-num/abs.t
@@ -1,6 +1,6 @@
use v6;
use Test;
plan 39;
plan 49;

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

Expand All @@ -10,28 +10,20 @@ Basic tests for the abs() builtin
=end pod

# In the next two blocks of tests, make an exception for type checking
# on Ints, because right now Ints in Rakudo are still mostly treated
# as Parrot Integers, and Integer.abs returns a Num. -- colomon
for 0, 0 / 1, 0.0e0, 1, 50, 60.0e0, 99.99 -> $x {
is(abs($x), $x, "got the right absolute value for $x");
is($x.abs, $x, 'got the right absolute value for $x='~$x);

for 0, 0 / 1, 0.0e0, 1, 50, 60.0e0, 99.99 {
is(abs($_), $_, "got the right absolute value for $_");
is(.abs, $_, 'got the right absolute value for $_='~$_);

unless $_ ~~ Int {
ok(abs($_) ~~ $_.WHAT, "got the right data type (" ~ $_.WHAT ~ ") of absolute value for $_");
ok($_.abs ~~ $_.WHAT, 'got the right data type (' ~ $_.WHAT ~ ') of absolute value for $_='~$_);
}
is (abs($x)).WHAT.gist, $x.WHAT.gist, 'type of abs($x) agrees with type of $x';
is $x.abs.WHAT.gist, $x.WHAT.gist, 'type of $x.abs agrees with type of $x';
}

for -1, -50, -60.0e0, -9999 / 100 {
is(abs($_), -$_, "got the right absolute value for $_");
is(.abs, -$_, 'got the right absolute value for $_='~$_);

unless $_ ~~ Int {
ok(abs($_) ~~ $_.WHAT, "got the right data type (" ~ $_.WHAT ~ ") of absolute value for $_");
ok($_.abs ~~ $_.WHAT, 'got the right data type (' ~ $_.WHAT ~ ') of absolute value for $_='~$_);
}
is (abs($_)).WHAT.gist, $_.WHAT.gist, 'type of abs($_) agrees with type of $_';
is $_.abs.WHAT.gist, $_.WHAT.gist, 'type of $_.abs agrees with type of $_';
}

is( abs(NaN), NaN, 'absolute value of NaN is NaN');
Expand All @@ -40,7 +32,8 @@ is( abs(-Inf), Inf, 'absolute value of -Inf is Inf');

is( abs("-10"), 10, 'absolute value of "-10" is 10');

is( abs(70596).WHAT, 70596.abs.WHAT, 'abs(x).WHAT parses as x.abs.WHAT' );
#?rakudo todo "abs(70596).WHAT parsing as abs(70596.WHAT)"
is( abs(70596).WHAT.gist, 70596.abs.WHAT.gist, 'abs(x).WHAT parses as x.abs.WHAT' );

done;

Expand Down

0 comments on commit 9e1a6c4

Please sign in to comment.