<commit_before>#! perl
use Server;
use Client;
use config;
use Test::More;
use Time::HiRes qw(time);
use strict;

my $server = Server->new($config::HTTPD);
$server->loadModule(
    mod_parrot => $config::BUILDDIR . '/build/mod_parrot.so'
);

$server->configure(
    ParrotLoader => 'psgi.pbc',
    ParrotLoaderPath => $config::BUILDDIR . '/build',
    ParrotLanguage => 'winxed .wxd',
);

my $helloworld = <<WINXED;
function main(var env) {
    say("im not in output");
    return [ 203, { "x-hello": "world"}, "this is a sample psgi app"];
}
WINXED

my $delayed = <<WINXED;
function delayed(var responder) {
    responder(203, {'x-hello':'world'}, "a delayed response");
}

function main[main](var env) {
    return delayed;
}
WINXED

my $streaming = <<WINXED;
function delayed(var responder) {
    var writer = responder(203, {'x-hello':'world'});
    sleep(1);
    say(typeof(writer));
}

function main[main](var env) {
    return delayed;
}
WINXED

$server->serve("hello.wxd", $helloworld, 0755);
$server->serve("delay.wxd", $delayed, 0755);
$server->serve('streaming.wxd', $streaming, 0755);
$server->debug();
Client::setup($server);
is(content("hello.wxd"), "this is a sample psgi app");
is(status("hello.wxd"), 203);
is(headers("hello.wxd")->{'x-hello'}, 'world');
is(content('delay.wxd'), "a delayed response");
is(headers('delay.wxd')->{'x-hello'}, 'world');
is(status('delay.wxd'), 203);

my $now = time;
is(content('streaming.wxd'), 'some message');
my $then = time;
ok($then - $now > 0.5);

print $server->errors;
done_testing;<commit_msg>Resolve a minor test issue<commit_after>#! perl
use Server;
use Client;
use config;
use Test::More tests => 8;
use Time::HiRes qw(time);
use strict;

my $server = Server->new($config::HTTPD);
$server->loadModule(
    mod_parrot => $config::BUILDDIR . '/build/mod_parrot.so'
);

$server->configure(
    ParrotLoader => 'psgi.pbc',
    ParrotLoaderPath => $config::BUILDDIR . '/build',
    ParrotLanguage => 'winxed .wxd',
);

my $helloworld = <<WINXED;
function main(var env) {
    say("im not in output");
    return [ 203, { "x-hello": "world"}, "this is a sample psgi app"];
}
WINXED

my $delayed = <<WINXED;
function delayed(var responder) {
    responder(203, {'x-hello':'world'}, "a delayed response");
}

function main[main](var env) {
    return delayed;
}
WINXED

my $streaming = <<WINXED;
function delayed(var responder) {
    var writer = responder(203, {'x-hello':'world'});
    sleep(1);
   	writer.write('some message'); 
}

function main[main](var env) {
    return delayed;
}
WINXED

$server->serve("hello.wxd", $helloworld, 0755);
$server->serve("delay.wxd", $delayed, 0755);
$server->serve('streaming.wxd', $streaming, 0755);
$server->start();
Client::setup($server);
is(content("hello.wxd"), "this is a sample psgi app");
is(status("hello.wxd"), 203);
is(headers("hello.wxd")->{'x-hello'}, 'world');
is(content('delay.wxd'), "a delayed response");
is(headers('delay.wxd')->{'x-hello'}, 'world');
is(status('delay.wxd'), 203);

my $now = time;
is(content('streaming.wxd'), 'some message');
my $then = time;
ok($then - $now > 0.5);

{'fraction_non_alphanumeric': 0.20780897063568893, 'fraction_numerical': 0.0196837689577283, 'mean_word_length': 5.042884990253412, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 33, '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': '2681580', 'n_tokens_mistral': 1184, 'n_tokens_neox': 1138, 'n_words': 267}