<commit_before>#!/usr/bin/env perl

# Copyright (C) 2008-2010, <NAME>.

use strict;
use warnings;

# Disable epoll, kqueue and IPv6
BEGIN { $ENV{MOJO_POLL} = $ENV{MOJO_NO_IPV6} = 1 }

use Mojo::IOLoop;
use Test::More;

# Make sure sockets are working
plan skip_all => 'working sockets required for this test!'
  unless Mojo::IOLoop->new->generate_port;
plan tests => 35;

use FindBin;
use lib "$FindBin::Bin/lib";

# I heard you went off and became a rich doctor.
# I've performed a few mercy killings.
package TestApp;

use Mojolicious::Lite;

# Silence
app->log->level('error');

# GET /hello (embedded)
get '/hello' => sub {
    my $self = shift;
    my $name = $self->stash('name');
    $self->render_text("Hello from the $name app!");
};

# Morbo will now introduce the candidates - Puny Human Number One,
# Puny Human Number Two, and Morbo's good friend <NAME>.
# How's the family, Morbo?
# Belligerent and numerous.
package MyTestApp::Test1;

use Mojolicious::Lite;

# Silence
app->log->level('error');

get '/yada' => sub {
    my $self = shift;
    my $name = $self->stash('name');
    $self->render(text => "yada $name works!");
};

# GET /bye (embedded)
get '/bye' => sub {
    my $self = shift;
    my $name = $self->stash('name');
    $self->pause;
    my $async = '';
    $self->client->async->get(
        '/hello/hello' => sub {
            my $client = shift;
            $self->render_text($client->res->body . "$name! $async");
            $self->finish;
        }
    )->process;
    $async .= 'success!';
};

package Mojolicious::Plugin::MyEmbeddedApp;
use base 'Mojolicious::Plugin';

sub register {
    my ($self, $app) = @_;
    $app->routes->route('/foo')
      ->detour(Mojolicious::Plugin::MyEmbeddedApp::App::app());
}

package Mojolicious::Plugin::MyEmbeddedApp::App;
use Mojolicious::Lite;

# Silence
app->log->level('error');

# GET /bar
get '/bar' => {text => 'plugin works!'};

package MyTestApp::Test2;

use Mojolicious::Lite;

# Silence
app->log->level('error');

# GET / (embedded)
get '/' => sub {
    my $self = shift;
    my $name = $self->stash('name');
    my $url  = $self->url_for;
    $self->render_text("Bye from the $name app! $url!");
};

package MyTestApp::Basic;

use base 'Mojo';

sub handler {
    my ($self, $tx) = @_;
    $tx->res->code(200);
    $tx->res->body('Hello stoneage!');
}

package main;

use Mojolicious::Lite;
use Test::Mojo;

# Silence
app->log->level('error');

# /foo/* (plugin app)
plugin 'my_embedded_app';

app->routes->namespace('MyTestApp');

# GET /hello
get '/hello' => 'works';

# /bye/* (dispatch to embedded app)
get('/bye' => {name => 'second embedded'})->detour('MyTestApp::Test1');

# /bar/* (dispatch to embedded app)
get('/bar' => {name => 'third embedded'})->detour(app => 'MyTestApp::Test1');<commit_msg>as basic as an embedded application can be<commit_after>#!/usr/bin/env perl

# Copyright (C) 2008-2010, <NAME>.

use strict;
use warnings;

# Disable epoll, kqueue and IPv6
BEGIN { $ENV{MOJO_POLL} = $ENV{MOJO_NO_IPV6} = 1 }

use Mojo::IOLoop;
use Test::More;

# Make sure sockets are working
plan skip_all => 'working sockets required for this test!'
  unless Mojo::IOLoop->new->generate_port;
plan tests => 35;

use FindBin;
use lib "$FindBin::Bin/lib";

# I heard you went off and became a rich doctor.
# I've performed a few mercy killings.
package TestApp;

use Mojolicious::Lite;

# Silence
app->log->level('error');

# GET /hello (embedded)
get '/hello' => sub {
    my $self = shift;
    my $name = $self->stash('name');
    $self->render_text("Hello from the $name app!");
};

# Morbo will now introduce the candidates - Puny Human Number One,
# Puny Human Number Two, and Morbo's good friend <NAME>.
# How's the family, Morbo?
# Belligerent and numerous.
package MyTestApp::Test1;

use Mojolicious::Lite;

# Silence
app->log->level('error');

get '/yada' => sub {
    my $self = shift;
    my $name = $self->stash('name');
    $self->render(text => "yada $name works!");
};

# GET /bye (embedded)
get '/bye' => sub {
    my $self = shift;
    my $name = $self->stash('name');
    $self->pause;
    my $async = '';
    $self->client->async->get(
        '/hello/hello' => sub {
            my $client = shift;
            $self->render_text($client->res->body . "$name! $async");
            $self->finish;
        }
    )->process;
    $async .= 'success!';
};

package Mojolicious::Plugin::MyEmbeddedApp;
use base 'Mojolicious::Plugin';

sub register {
    my ($self, $app) = @_;
    $app->routes->route('/foo')
      ->detour(Mojolicious::Plugin::MyEmbeddedApp::App::app());
}

package Mojolicious::Plugin::MyEmbeddedApp::App;
use Mojolicious::Lite;

# Silence
app->log->level('error');

# GET /bar
get '/bar' => {text => 'plugin works!'};

package MyTestApp::Test2;

use Mojolicious::Lite;

# Silence
app->log->level('error');

# GET / (embedded)
get '/' => sub {
    my $self = shift;
    my $name = $self->stash('name');
    my $url  = $self->url_for;
    $self->render_text("Bye from the $name app! $url!");
};

package MyTestApp::Basic;

use base 'Mojo::Base';

sub handler {
    my ($self, $tx) = @_;
    $tx->res->code(200);
    $tx->res->body('Hello stoneage!');
}

package main;

use Mojolicious::Lite;
use Test::Mojo;

# Silence
app->log->level('error');

# /foo/* (plugin app)
plugin 'my_embedded_app';

app->routes->namespace('MyTestApp');

# GET /hello
get '/hello' => 'works';

# /bye/* (dispatch to embedded app)
get('/bye' => {name => 'second embedded'})->detour('MyTestApp::Test1');

# /bar/* (dispatch to embedded app)
get('/bar' => {name => 'third embedded'})->detour(app => 'MyTestApp::Test1');
{'fraction_non_alphanumeric': 0.19269813000890473, 'fraction_numerical': 0.007123775601068566, 'mean_word_length': 3.6956521739130435, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 119, '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': '2116819', 'n_tokens_mistral': 2062, 'n_tokens_neox': 2013, 'n_words': 524}