<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 6;

#Str methods
##existence
is 'pi.txt'.e, 1, 'It exists';
is 'xyzzy'.e, 0, "It doesn't";

##is empty
is 'empty.txt'.z, 1, 'Is empty';
is 'pi.txt'.z, 0, 'Is not';

##file size
is 'empty.txt'.s, 0, 'No size';
is 'pi.txt'.s, 11, 'size of file'; #if this test fails, check the size of pi.txt first, and change if necessary :)<commit_msg>[t/spec] Rewrite to create test files on the file rather than picking them from the spectest directory tree.<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 8;

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
is $existing-file.e, 1, 'It exists';
is $non-existent-file.e, 0, "It doesn't";

##is empty
is $zero-length-file.z, 1, 'Is empty';
is $existing-file.z, 0, 'Is not';

##file size
is $zero-length-file.s, 0, 'No size';
is $existing-file.s, 11, 'size of file'; #if this test fails, check the size of pi.txt first, and change if necessary :)


# 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.16472749540722598, 'fraction_numerical': 0.021432945499081445, 'mean_word_length': 3.8486646884273, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '189564', 'n_tokens_mistral': 639, 'n_tokens_neox': 594, 'n_words': 222}