Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 58 lines (47 sloc) 1.308 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
use v6;
use Test;
plan 13;

# L<S02/"Infinity and C<NaN>" /Perl 6 by default makes standard IEEE floating point concepts visible>

{
    my $x = Inf;

    ok( $x == Inf , 'numeric equal');
    ok( $x eq 'Inf', 'string equal');
}

{
    my $x = -Inf;
    ok( $x == -Inf, 'negative numeric equal' );
    ok( $x eq '-Inf', 'negative string equal' );
}

#?rakudo skip 'integer Inf'
{
    my $x = Inf.Int;
    ok( $x == Inf, 'int numeric equal' );
    #?pugs todo
    ok( $x eq 'Inf', 'int string equal' );
}

#?rakudo skip 'integer Inf'
{
    my $x = ( -Inf ).Int;
    ok( $x == -Inf, 'int numeric equal' );
    #?pugs todo
    ok( $x eq '-Inf', 'int string equal' );
}

# Inf should == Inf. Additionally, Inf's stringification (~Inf), "Inf", should
# eq to the stringification of other Infs.
# Thus:
# Inf == Inf # true
# and:
# Inf eq Inf # same as
# ~Inf eq ~Inf # true

#?pugs 4 todo
ok truncate(Inf) ~~ Inf, 'truncate(Inf) ~~ Inf';
#?rakudo 3 todo 'Int conversion of NaN and Inf'
ok NaN.Int === NaN, 'Inf.Int === Int';
ok Inf.Int === Inf, 'Inf.Int === Int';
ok (-Inf).Int === (-Inf), 'Inf.Int === Int';

# RT #70730
#?pugs skip 'parsefail'
{
    ok ( rand * Inf ) === Inf, 'multiply rand by Inf without maximum recursion depth exceeded';
}

# vim: ft=perl6
Something went wrong with that request. Please try again.