<commit_before>use v6;
use Test;

# Maybe someone can put in a better smartlink? --lue
# L<S32::IO/"A file test, where X is one of the letters listed below.">

plan 26;

my $existing-file = "tempfile-file-tests";
my $non-existent-file = "non-existent-file-tests";
my $zero-length-file = "tempfile-zero-length-file-tests";

{ # write the file first
    my $fh = open($existing-file, :w);
    $fh.print: "0123456789A";
    $fh.close();
}

{ # write the file first
    my $fh = open($zero-length-file, :w);
    $fh.close();
}

#Str methods
##existence
ok $existing-file.e, 'It exists';
isa_ok $existing-file.e, Bool, '.e returns Bool';
ok $existing-file ~~ :e, 'It exists';
#?rakudo todo 'Rakudo gets the type of ~~ :e form incorrect'
isa_ok $existing-file ~~ :e, Bool, '~~ :e returns Bool';
nok $non-existent-file.e, "It doesn't";
isa_ok $non-existent-file.e, Bool, '.e returns Bool';
nok $non-existent-file ~~ :e, "It doesn't";
#?rakudo todo 'Rakudo gets the type of ~~ :e form incorrect'
isa_ok $non-existent-file ~~ :e, Bool, '~~ :e returns Bool';

##is empty
ok $zero-length-file.z, 'Is empty';
isa_ok $zero-length-file.z, Bool, '.z returns Bool';
ok $zero-length-file ~~ :z, 'Is empty';
#?rakudo todo 'Rakudo gets the type of ~~ :z form incorrect'
isa_ok $zero-length-file ~~ :z, Bool, '~~ :z returns Bool';
nok $existing-file.z, 'Is not';
isa_ok $existing-file.z, Bool, '.z returns Bool';
nok $existing-file ~~ :z, 'Is not';
#?rakudo todo 'Rakudo gets the type of ~~ :z form incorrect'
isa_ok $existing-file ~~ :z, Bool, '~~ :z returns Bool';

##file size
is $zero-length-file.s, 0, 'No size';
isa_ok $zero-length-file.s, Int, '.s returns Int';
is $zero-length-file ~~ :s, 0, 'No size';
isa_ok $zero-length-file ~~ :s, Int, '~~ :s returns Int';
is $existing-file.s, 11, 'size of file';
isa_ok $existing-file.s, Int, '.s returns Int';
#?rakudo todo 'Rakudo gets the size wrong with the ~~ :s form'
is $existing-file ~~ :s, 11, 'size of file';
isa_ok $existing-file ~~ :s, Int, '~~ :s returns Int';

# clean up
is unlink($existing-file), 1, 'file has been removed';
is unlink($zero-length-file), 1, 'file has been removed';

# vim: ft=perl6<commit_msg>[t/spec] Refudge after infix:<===>(Int, Int) change.<commit_after>use v6;
use Test;

# Maybe someone can put in a better smartlink? --lue
# L<S32::IO/"A file test, where X is one of the letters listed below.">

plan 26;

my $existing-file = "tempfile-file-tests";
my $non-existent-file = "non-existent-file-tests";
my $zero-length-file = "tempfile-zero-length-file-tests";

{ # write the file first
    my $fh = open($existing-file, :w);
    $fh.print: "0123456789A";
    $fh.close();
}

{ # write the file first
    my $fh = open($zero-length-file, :w);
    $fh.close();
}

#Str methods
##existence
ok $existing-file.e, 'It exists';
isa_ok $existing-file.e, Bool, '.e returns Bool';
ok $existing-file ~~ :e, 'It exists';
isa_ok $existing-file ~~ :e, Bool, '~~ :e returns Bool';
nok $non-existent-file.e, "It doesn't";
isa_ok $non-existent-file.e, Bool, '.e returns Bool';
nok $non-existent-file ~~ :e, "It doesn't";
isa_ok $non-existent-file ~~ :e, Bool, '~~ :e returns Bool';

##is empty
ok $zero-length-file.z, 'Is empty';
isa_ok $zero-length-file.z, Bool, '.z returns Bool';
ok $zero-length-file ~~ :z, 'Is empty';
isa_ok $zero-length-file ~~ :z, Bool, '~~ :z returns Bool';
nok $existing-file.z, 'Is not';
isa_ok $existing-file.z, Bool, '.z returns Bool';
nok $existing-file ~~ :z, 'Is not';
isa_ok $existing-file ~~ :z, Bool, '~~ :z returns Bool';

##file size
is $zero-length-file.s, 0, 'No size';
isa_ok $zero-length-file.s, Int, '.s returns Int';
is $zero-length-file ~~ :s, 0, 'No size';
#?rakudo todo 'Rakudo gets the type and size wrong with the ~~ :s form'
isa_ok $zero-length-file ~~ :s, Int, '~~ :s returns Int';
is $existing-file.s, 11, 'size of file';
isa_ok $existing-file.s, Int, '.s returns Int';
#?rakudo 2 todo 'Rakudo gets the type and size wrong with the ~~ :s form'
is $existing-file ~~ :s, 11, 'size of file';
isa_ok $existing-file ~~ :s, Int, '~~ :s returns Int';

# clean up
is unlink($existing-file), 1, 'file has been removed';
is unlink($zero-length-file), 1, 'file has been removed';

# vim: ft=perl6
{'fraction_non_alphanumeric': 0.18967988533205923, 'fraction_numerical': 0.011705685618729096, 'mean_word_length': 4.124847001223991, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1413500', 'n_tokens_mistral': 1673, 'n_tokens_neox': 1596, 'n_words': 520}