<commit_before>use v6;
use Test;
plan 43;

# L<S03/Changes to Perl 5 operators/"imposes a numeric">

# <NAME>: L<http://www.nntp.perl.org/group/perl.perl6.compiler/1134>
is(+'0012', 12, "+'0012' is 12");
is(+'0000',  0, "+'0000' is  0");
is(+'000a',  0, "+'000a' is  0 (illegal number)");

is(+'1.9e3', 1900, "+'1.9e3' is 1900");
is(+'Inf', Inf, "+'Inf' is Inf");
is(+'Info', 0, "+'Info' is 0");
is(+'-Inf', -Inf, "+'-Inf' is -Inf");
is(+'-Info', 0, "+'-Info' is 0");
is(+'NaN', NaN, "+'NaN' is NaN");
is(+'NaNa', 0, "+'NaNa' is 0");

{
    # XXX Not sure whether the following tests are correct
    is(+'Inf ',      Inf, "numification of strings with whitspace (1)");
    is(+'Inf o',       0, "numification of strings with whitspace (2)");
    is(+'NaN ',      NaN, "numification of strings with whitspace (3)");
    is(+'NaN a',       0, "numification of strings with whitspace (4)");
    is(+"Inf\t",     Inf, "numification of strings with whitspace (5)");
    is(+"Inf\to",      0, "numification of strings with whitspace (6)");
    is(+"NaN\t",     NaN, "numification of strings with whitspace (7)");
    is(+"NaN\ta",      0, "numification of strings with whitspace (8)");
    is(+"Inf\n",     Inf, "numification of strings with whitspace (9)");
    is(+"Inf\no",      0, "numification of strings with whitspace (10)");
    is(+"NaN\n",     NaN, "numification of strings with whitspace (11)");
    is(+"NaN\na",      0, "numification of strings with whitspace (12)");
    is(+"Inf\n\t ",  Inf, "numification of strings with whitspace (13)");
    is(+"Inf\n\t o",   0, "numification of strings with whitspace (14)");
    is(+"NaN\n\t ",  NaN, "numification of strings with whitspace (15)");
    is(+"NaN\n\t a",   0, "numification of strings with whitspace (16)");
    is(+"3 ",          3, "numification of strings with whitspace (17)");
}

is(+'aInf',  0, "+'aInf'  is 0");
is(+'aInfo', 0, "+'aInfo' is 0");
is(+'aNaN',  0, "+'aNaN'  is 0");
is(+'aNaNa', 0, "+'aNaNa' is 0");

is( Inf,  'Inf', "'Inf' is Inf");
is(-Inf, '-Inf', "'-Inf' is -Inf");

is(+(~(+Inf)),  Inf, "'+Inf' is Inf");
is(+(~(-Inf)), -Inf, "'-Inf' is -Inf");


# RT #62622
#?rakudo todo 'RT #62622'
{
    my Int $x;

    lives_ok { $x = +'2' }, 'can assign string "2" to Int variable';
    is( $x, 2, 'assign string "2" to Int variable works' );

    lives_ok { $x = "4" - 3 }, 'lives: Int $x = "4" - 3';
    is( $x, 1, 'works: Int $x = "4" - 3' );
}

{
    my Num $x;

    lives_ok { $x = +'2' }, 'can assign string "2" to Num variable';
    is( $x, 2, 'assign string "2" to Num variable works' );

    lives_ok { $x = "4" - 3 }, 'lives: Num $x = "4" - 3';
    is( $x, 1, 'works: Num $x = "4" - 3' );
}

# vim: ft=perl6<commit_msg>[t/spec] Unfudge four tests that are passing, but add two fudged tests to help verify those previously fudged tests are correct.<commit_after>use v6;
use Test;
plan 45;

# L<S03/Changes to Perl 5 operators/"imposes a numeric">

# <NAME>: L<http://www.nntp.perl.org/group/perl.perl6.compiler/1134>
is(+'0012', 12, "+'0012' is 12");
is(+'0000',  0, "+'0000' is  0");
is(+'000a',  0, "+'000a' is  0 (illegal number)");

is(+'1.9e3', 1900, "+'1.9e3' is 1900");
is(+'Inf', Inf, "+'Inf' is Inf");
is(+'Info', 0, "+'Info' is 0");
is(+'-Inf', -Inf, "+'-Inf' is -Inf");
is(+'-Info', 0, "+'-Info' is 0");
is(+'NaN', NaN, "+'NaN' is NaN");
is(+'NaNa', 0, "+'NaNa' is 0");

{
    # XXX Not sure whether the following tests are correct
    is(+'Inf ',      Inf, "numification of strings with whitspace (1)");
    is(+'Inf o',       0, "numification of strings with whitspace (2)");
    is(+'NaN ',      NaN, "numification of strings with whitspace (3)");
    is(+'NaN a',       0, "numification of strings with whitspace (4)");
    is(+"Inf\t",     Inf, "numification of strings with whitspace (5)");
    is(+"Inf\to",      0, "numification of strings with whitspace (6)");
    is(+"NaN\t",     NaN, "numification of strings with whitspace (7)");
    is(+"NaN\ta",      0, "numification of strings with whitspace (8)");
    is(+"Inf\n",     Inf, "numification of strings with whitspace (9)");
    is(+"Inf\no",      0, "numification of strings with whitspace (10)");
    is(+"NaN\n",     NaN, "numification of strings with whitspace (11)");
    is(+"NaN\na",      0, "numification of strings with whitspace (12)");
    is(+"Inf\n\t ",  Inf, "numification of strings with whitspace (13)");
    is(+"Inf\n\t o",   0, "numification of strings with whitspace (14)");
    is(+"NaN\n\t ",  NaN, "numification of strings with whitspace (15)");
    is(+"NaN\n\t a",   0, "numification of strings with whitspace (16)");
    is(+"3 ",          3, "numification of strings with whitspace (17)");
}

is(+'aInf',  0, "+'aInf'  is 0");
is(+'aInfo', 0, "+'aInfo' is 0");
is(+'aNaN',  0, "+'aNaN'  is 0");
is(+'aNaNa', 0, "+'aNaNa' is 0");

is( Inf,  'Inf', "'Inf' is Inf");
is(-Inf, '-Inf', "'-Inf' is -Inf");

is(+(~(+Inf)),  Inf, "'+Inf' is Inf");
is(+(~(-Inf)), -Inf, "'-Inf' is -Inf");


# RT #62622
{
    my Int $x;

    lives_ok { $x = +'2' }, 'can assign string "2" to Int variable';
    #?rakudo todo 'Assignment of +"2" to Int variable creates a Num variable in Rakudo-ng'
    isa_ok( $x, Int, 'assign string "2" to Int creates an Int' );
    is( $x, 2, 'assign string "2" to Int variable works' );

    lives_ok { $x = "4" - 3 }, 'lives: Int $x = "4" - 3';
    #?rakudo todo 'Assignment of +"2" to Int variable creates a Num variable in Rakudo-ng'
    isa_ok( $x, Int, 'Int $x = "4" - 3 creates an Int' );
    is( $x, 1, 'works: Int $x = "4" - 3' );
}

{
    my Num $x;

    lives_ok { $x = +'2' }, 'can assign string "2" to Num variable';
    is( $x, 2, 'assign string "2" to Num variable works' );

    lives_ok { $x = "4" - 3 }, 'lives: Num $x = "4" - 3';
    is( $x, 1, 'works: Num $x = "4" - 3' );
}

# vim: ft=perl6
{'fraction_non_alphanumeric': 0.22457408363448633, 'fraction_numerical': 0.04715195319222165, 'mean_word_length': 3.2024584237165583, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3721469', 'n_tokens_mistral': 2441, 'n_tokens_neox': 2300, 'n_words': 754}