<commit_before>#! perl
# Copyright: 2001-2005 The Perl Foundation.  All Rights Reserved.
# $Id$

use strict;
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
use Parrot::Test tests => 20;


=head1 NAME

t/src/io.t - IO Subsystem

=head1 SYNOPSIS

	% perl -Ilib t/src/io.t

=head1 DESCRIPTION

Tests the IO subsystem.

=cut


$/=undef; # slurp mode

sub setup
{
	my $name = @_ ? shift : "temp.file";
	my $content = @_ ? shift : "This is a test\n";

	open(FILE, ">$name") or die "Failed to create $name";
        binmode FILE;
	print FILE $content;
	close(FILE);

	unlink("does_not_exist") if -e "does_not_exist";
}

sub teardown
{
	my $name = @_ ? shift : "temp.file";

	unlink($name) if -e $name;
	die "Failed to delete $name"if -e $name;
}

my $main = <<'CODE';
#include <parrot/parrot.h>
#include <parrot/embed.h>

static opcode_t *the_test(Parrot_Interp, opcode_t *, opcode_t *);

int main(int argc, char* argv[])
{
    Parrot_Interp interpreter = Parrot_new(NULL);
    if (!interpreter) {
        return 1;
    }
    Parrot_init(interpreter);

    Parrot_run_native(interpreter, the_test);

    Parrot_exit(0);
    return 0;
}<commit_msg>io: try harder to delete temp files to prevent test failures<commit_after>#! perl
# Copyright: 2001-2005 The Perl Foundation.  All Rights Reserved.
# $Id$

use strict;
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
use Parrot::Test tests => 20;


=head1 NAME

t/src/io.t - IO Subsystem

=head1 SYNOPSIS

	% perl -Ilib t/src/io.t

=head1 DESCRIPTION

Tests the IO subsystem.

=cut


$/=undef; # slurp mode

sub setup
{
	my $name = @_ ? shift : "temp.file";
	my $content = @_ ? shift : "This is a test\n";

	open(FILE, ">$name") or die "Failed to create $name";
        binmode FILE;
	print FILE $content;
	close(FILE);

	unlink("does_not_exist") if -e "does_not_exist";
}

sub teardown
{
	my $name = @_ ? shift : "temp.file";

	my $delete_counter;
	unlink($name) while( -e $name and 3 > $delete_counter++ and sleep 1);
	die "Failed to delete $name" if -e $name;
}

my $main = <<'CODE';
#include <parrot/parrot.h>
#include <parrot/embed.h>

static opcode_t *the_test(Parrot_Interp, opcode_t *, opcode_t *);

int main(int argc, char* argv[])
{
    Parrot_Interp interpreter = Parrot_new(NULL);
    if (!interpreter) {
        return 1;
    }
    Parrot_init(interpreter);

    Parrot_run_native(interpreter, the_test);

    Parrot_exit(0);
    return 0;
}
{'fraction_non_alphanumeric': 0.14913722267871815, 'fraction_numerical': 0.013968775677896467, 'mean_word_length': 3.411231884057971, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, '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': '1937783', 'n_tokens_mistral': 992, 'n_tokens_neox': 934, 'n_words': 269}