Author: jkeenan
Date: Mon Oct 1 19:42:27 2007
New Revision: 21730
Modified:
branches/reconfigure/t/configure/046-inter.t
branches/reconfigure/t/configure/047-inter.t
Log:
Revise two tests: runsteps should be method called on rather than .
Modified: branches/reconfigure/t/configure/046-inter.t
==============================================================================
--- branches/reconfigure/t/configure/046-inter.t (original)
+++ branches/reconfigure/t/configure/046-inter.t Mon Oct 1 19:42:27 2007
@@ -5,10 +5,10 @@
use strict;
use warnings;
-use Test::More tests => 11;
+use Test::More qw(no_plan); # tests => 11;
use Carp;
use lib qw( lib t/configure/testlib );
-use_ok('inter::theta');
+#use_ok('inter::theta');
use Parrot::Configure;
use Parrot::Configure::Options qw( process_options );
use Parrot::IO::Capture::Mini;
@@ -29,31 +29,53 @@
my $conf = Parrot::Configure->new;
ok( defined $conf, "Parrot::Configure->new() returned okay" );
-my ( $task, $step_name, @step_params, $step, $ret );
-my $pkg = q{inter::theta};
+my $step = q{inter::theta};
+my $description = 'Determining if your computer does theta';
-$conf->add_steps($pkg);
-$conf->options->set( %{$args} );
-
-$task = $conf->steps->[0];
-$step_name = $task->step;
[EMAIL PROTECTED] = @{ $task->params };
-
-$step = $step_name->new();
-ok( defined $step, "$step_name constructor returned defined value" );
-isa_ok( $step, $step_name );
-ok( $step->description(), "$step_name has description" );
-my ( @prompts, $object );
[EMAIL PROTECTED] = (q{n});
-$object = tie *STDIN, 'Tie::Filehandle::Preempt::Stdin', @prompts;
-can_ok( 'Tie::Filehandle::Preempt::Stdin', ('READLINE') );
-isa_ok( $object, 'Tie::Filehandle::Preempt::Stdin' );
-
-$ret = $step->runstep($conf);
-ok( defined $ret, "$step_name runstep() returned defined value" );
+$conf->add_steps($step);
+my @confsteps = @{ $conf->steps };
+isnt( scalar @confsteps, 0,
+ "Parrot::Configure object 'steps' key holds non-empty array reference" );
+is( scalar @confsteps, 1, "Parrot::Configure object 'steps' key holds ref to
1-element array" );
+my $nontaskcount = 0;
+foreach my $k (@confsteps) {
+ $nontaskcount++ unless $k->isa("Parrot::Configure::Task");
+}
+is( $nontaskcount, 0, "Each step is a Parrot::Configure::Task object" );
+is( $confsteps[0]->step, $step, "'step' element of Parrot::Configure::Task
struct identified" );
+is( ref( $confsteps[0]->params ),
+ 'ARRAY', "'params' element of Parrot::Configure::Task struct is array ref"
);
+ok( !ref( $confsteps[0]->object ),
+ "'object' element of Parrot::Configure::Task struct is not yet a ref" );
+
+$conf->options->set(%args);
+is( $conf->options->{c}->{debugging},
+ 1, "command-line option '--debugging' has been stored in object" );
+
+#my ( @prompts, $object );
[EMAIL PROTECTED] = (q{n});
+#$object = tie *STDIN, 'Tie::Filehandle::Preempt::Stdin', @prompts;
+#can_ok( 'Tie::Filehandle::Preempt::Stdin', ('READLINE') );
+#isa_ok( $object, 'Tie::Filehandle::Preempt::Stdin' );
+
+my $rv;
+my ( $tie, @lines );
+{
+ $tie = tie *STDOUT, "Parrot::IO::Capture::Mini"
+ or croak "Unable to tie";
+ $rv = $conf->runsteps;
+ @lines = $tie->READLINE;
+}
+ok($rv, "runsteps() returned true value");
+my $bigmsg = join q{}, @lines;
+like(
+ $bigmsg,
+ qr/$description\.\.\./s,
+ "Got STDOUT message expected upon running $step"
+);
-$object = undef;
-untie *STDIN;
+#$object = undef;
+#untie *STDIN;
pass("Completed all tests in $0");
Modified: branches/reconfigure/t/configure/047-inter.t
==============================================================================
--- branches/reconfigure/t/configure/047-inter.t (original)
+++ branches/reconfigure/t/configure/047-inter.t Mon Oct 1 19:42:27 2007
@@ -5,10 +5,9 @@
use strict;
use warnings;
-use Test::More tests => 12;
+use Test::More qw(no_plan); # tests => 12;
use Carp;
use lib qw( lib t/configure/testlib );
-use_ok('inter::theta');
use Parrot::Configure;
use Parrot::Configure::Options qw( process_options );
use Parrot::IO::Capture::Mini;
@@ -29,39 +28,54 @@
my $conf = Parrot::Configure->new;
ok( defined $conf, "Parrot::Configure->new() returned okay" );
-my ( $task, $step_name, @step_params, $step, $ret );
-my $pkg = q{inter::theta};
+my $step = q{inter::theta};
+my $description = 'Determining if your computer does theta';
-$conf->add_steps($pkg);
-$conf->options->set( %{$args} );
+$conf->add_steps($step);
+my @confsteps = @{ $conf->steps };
+isnt( scalar @confsteps, 0,
+ "Parrot::Configure object 'steps' key holds non-empty array reference" );
+is( scalar @confsteps, 1, "Parrot::Configure object 'steps' key holds ref to
1-element array" );
+my $nontaskcount = 0;
+foreach my $k (@confsteps) {
+ $nontaskcount++ unless $k->isa("Parrot::Configure::Task");
+}
+is( $nontaskcount, 0, "Each step is a Parrot::Configure::Task object" );
+is( $confsteps[0]->step, $step, "'step' element of Parrot::Configure::Task
struct identified" );
+is( ref( $confsteps[0]->params ),
+ 'ARRAY', "'params' element of Parrot::Configure::Task struct is array ref"
);
+ok( !ref( $confsteps[0]->object ),
+ "'object' element of Parrot::Configure::Task struct is not yet a ref" );
+
+$conf->options->set(%args);
+is( $conf->options->{c}->{debugging},
+ 1, "command-line option '--debugging' has been stored in object" );
-$task = $conf->steps->[0];
-$step_name = $task->step;
[EMAIL PROTECTED] = @{ $task->params };
-
-$step = $step_name->new();
-ok( defined $step, "$step_name constructor returned defined value" );
-isa_ok( $step, $step_name );
-ok( $step->description(), "$step_name has description" );
my ( @prompts, $object );
@prompts = (q{n});
$object = tie *STDIN, 'Tie::Filehandle::Preempt::Stdin', @prompts;
can_ok( 'Tie::Filehandle::Preempt::Stdin', ('READLINE') );
isa_ok( $object, 'Tie::Filehandle::Preempt::Stdin' );
+my $rv;
+my ( $tie, @lines );
{
- my $tie_out = tie *STDOUT, "Parrot::IO::Capture::Mini"
+ $tie = tie *STDOUT, "Parrot::IO::Capture::Mini"
or croak "Unable to tie";
- $ret = $step->runstep($conf);
- ok( defined $ret, "$step_name runstep() returned defined value" );
- my $line = $tie_out->READLINE;
- my $question = 'Will Perl 6 be out before Christmas?';
- like($line, qr/$question/, "got expected prompt");
+ $rv = $conf->runsteps;
+ @lines = $tie->READLINE;
+ undef $tie;
}
+ok($rv, "runsteps() returned true value");
+my $bigmsg = join q{}, @lines;
+like(
+ $bigmsg,
+ qr/$description\.\.\./s,
+ "Got STDOUT message expected upon running $step"
+);
$object = undef;
untie *STDIN;
-untie *STDOUT;
pass("Completed all tests in $0");