<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 tests => 12;

=head1 NAME

t/configure/configure.t - tests Parrot::Configure

=head1 SYNOPSIS

    prove t/configure/configure.t

=head1 DESCRIPTION

Regressions tests for the L<Parrote::Configure> class.

=cut

BEGIN { use_ok('Parrot::Configure'); }

can_ok('Parrot::Configure', qw(
    new
    data
    options
    steps
    add_steps
    runsteps
));

# ->new()

{
    my $pc = Parrot::Configure->new;

    isa_ok($pc, 'Parrot::Configure');
}

# ->data()

{
    my $pc = Parrot::Configure->new;

    isa_ok($pc->data, 'Parrot::Configure::Data');
}

# ->options()

{
    my $pc = Parrot::Configure->new;

    isa_ok($pc->options, 'Parrot::Configure::Data');
}

# ->steps() / ->add_steps()

{
    my $pc = Parrot::Configure->new;
    
    isa_ok($pc->add_steps(), 'Parrot::Configure');
}

{
    my $pc = Parrot::Configure->new;
    
    is_deeply(scalar $pc->steps, [],
        "->steps() returns array ref in scalar context");
}

{
    my $pc = Parrot::Configure->new;
    
    is_deeply([$pc->steps], [], "->steps() returns () in list context");
}

{
    my $pc = Parrot::Configure->new;
    
    $pc->add_steps(qw(foo::step));
    is_deeply(scalar $pc->steps, [qw(foo::step)],
        "->steps() returns the proper list");
}

{
    my $pc = Parrot::Configure->new;
    
    $pc->add_steps(qw(foo::step bar::step baz::step));
    is_deeply(scalar $pc->steps, [qw(foo::step bar::step baz::step)],
        "->steps() returns the proper list");
}

# ->runsteps()

{
    my $pc = Parrot::Configure->new;

    isa_ok($pc->runsteps, 'Parrot::Configure');
}

{
    package test::step;

    # XXX is there a better way of doing this?
    $INC{'test/step.pm'}++;

    use vars qw($ran);
    use base qw(Parrot::Configure::Step::Base);

    $ran = 0;
    sub runstep
    {
        $ran = 1;
    }

    package main;

    my $pc = Parrot::Configure->new;

    $pc->add_steps('test::step');
    $pc->runsteps;
    # otherwise runsteps() output will make Test::Harness think this test
    # failed.
    print "\n";
    is($test::step::ran, 1, "test step was invokved");
}

<commit_msg>test that ->runsteps() is calling 'step'->runstep() with the proper parameters add skipped of the unimplemented ->add_step()<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 tests => 22;

=head1 NAME

t/configure/configure.t - tests Parrot::Configure

=head1 SYNOPSIS

    prove t/configure/configure.t

=head1 DESCRIPTION

Regressions tests for the L<Parrote::Configure> class.

=cut

BEGIN { use_ok('Parrot::Configure'); }

can_ok('Parrot::Configure', qw(
    new
    data
    options
    steps
    add_steps
    runsteps
));

# ->new()

{
    my $pc = Parrot::Configure->new;

    isa_ok($pc, 'Parrot::Configure');
}

# ->data()

{
    my $pc = Parrot::Configure->new;

    isa_ok($pc->data, 'Parrot::Configure::Data');
}

# ->options()

{
    my $pc = Parrot::Configure->new;

    isa_ok($pc->options, 'Parrot::Configure::Data');
}

# ->steps() / ->add_steps()

{
    my $pc = Parrot::Configure->new;
    
    isa_ok($pc->add_steps(), 'Parrot::Configure');
}

{
    my $pc = Parrot::Configure->new;
    
    is_deeply(scalar $pc->steps, [],
        "->steps() returns array ref in scalar context");
}

{
    my $pc = Parrot::Configure->new;
    
    is_deeply([$pc->steps], [], "->steps() returns () in list context");
}

{
    my $pc = Parrot::Configure->new;
    
    $pc->add_steps(qw(foo::step));
    is_deeply(scalar $pc->steps, [qw(foo::step)],
        "->steps() returns the proper list");
}

{
    my $pc = Parrot::Configure->new;
    
    $pc->add_steps(qw(foo::step bar::step baz::step));
    is_deeply(scalar $pc->steps, [qw(foo::step bar::step baz::step)],
        "->steps() returns the proper list");
}

# ->steps() / ->add_step()

SKIP: {
    skip "->add_step() is unimplimented", 3;

{
    my $pc = Parrot::Configure->new;
    
    isa_ok($pc->add_step(), 'Parrot::Configure');
}

{
    my $pc = Parrot::Configure->new;
    
    $pc->add_step('foo::step');
    is_deeply(scalar $pc->steps, [qw(foo::step)],
        "->steps() returns the proper list after ->add_step() w/o args");
}

{
    my $pc = Parrot::Configure->new;
    
    $pc->add_step('foo::step', qw(bar baz));
    is_deeply(scalar $pc->steps, [qw(foo::step)],
        "->steps() returns the proper list after ->add_step() with args");
}
}

# ->runsteps()

{
    my $pc = Parrot::Configure->new;

    isa_ok($pc->runsteps, 'Parrot::Configure');
}

{
    package test::step;

    # XXX is there a better way of doing this?
    $INC{'test/step.pm'}++;

    use vars qw($ran);
    use base qw(Parrot::Configure::Step::Base);

    $ran = 0;
    sub runstep
    {
        $ran = 1;
    }

    package main;

    my $pc = Parrot::Configure->new;

    $pc->add_steps('test::step');
    $pc->runsteps;
    # otherwise runsteps() output will make Test::Harness think this test
    # failed.
    print "\n";
    is($test::step::ran, 1, "test step was invokved");
}

{
    package test::step::params;

    # XXX is there a better way of doing this?
    $INC{'test/step/params.pm'}++;

    use vars qw($self $conf @params);
    use base qw(Parrot::Configure::Step::Base);

    sub runstep
    {
        ($self, $conf, @params) = @_;
    }

    package main;

    my $pc = Parrot::Configure->new;

    $pc->add_steps('test::step::params');
    $pc->runsteps;
    # otherwise runsteps() output will make Test::Harness think this test
    # failed.
    print "\n";
    is($test::step::params::self, 'test::step::params',
        "->runstep() is called as class method");
    isa_ok($test::step::params::conf, 'Parrot::Configure');
    is_deeply(\@test::step::params::conf, [],
        "no extra parameters were passed to ->runstep()");
}

SKIP: {
    skip "->add_step() is unimplimented", 4;
{
    package test::step::stepparams;

    # XXX is there a better way of doing this?
    $INC{'test/step/stepparams.pm'}++;

    use vars qw($self $conf @params);
    use base qw(Parrot::Configure::Step::Base);

    sub runstep
    {
        ($self, $conf, @params) = @_;
    }

    package main;

    my $pc = Parrot::Configure->new;

    $pc->add_step('test::step::stepparams', 24, qw( bar baz bong ), 42);
    $pc->runsteps;
    # otherwise runsteps() output will make Test::Harness think this test
    # failed.
    print "\n";
    isa_ok($test::step::stepparams::self, 'Parrot::Configure');
    isa_ok($test::step::stepparams::conf, 'Parrot::Configure');
    cmp_ok($test::step::stepparams::self, 'ne', $test::step::stepparams::conf,
        '$self and $conf params are not the same object');
    is_deeply(\@test::step::stepparams::conf, [24, qw( bar baz bong ), 42],
        "proper additional parameters were passed to ->runstep()");
}
}


{'fraction_non_alphanumeric': 0.18931691250179006, 'fraction_numerical': 0.006014606902477445, 'mean_word_length': 3.0913884007029875, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 99, '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': '7452025', 'n_tokens_mistral': 2644, 'n_tokens_neox': 2529, 'n_words': 572}