diff -ur Test-TAP-Model-0.06/lib/Test/TAP/Model/File.pm Test-TAP-Model-0.06_new/lib/Test/TAP/Model/File.pm
--- Test-TAP-Model-0.06/lib/Test/TAP/Model/File.pm 2006-03-27 10:46:39.000000000 -0800
+++ Test-TAP-Model-0.06_new/lib/Test/TAP/Model/File.pm 2006-12-08 22:57:35.000000000 -0800
@@ -28,9 +28,9 @@
}
# predicates about the test file
-sub ok { $_[0]{struct}{results}{passing} };
+sub ok { $_[0]{struct}{results}->passing() };
sub nok { !$_[0]->ok };
-sub skipped { exists $_[0]{struct}{results}{skip_all} };
+sub skipped { $_[0]{struct}{results}->skip_all() };
sub bailed_out {
my $event = $_[0]{struct}{events}[-1] or return;
return unless exists $event->{type};
@@ -45,7 +45,7 @@
sub _mk_objs { my $self = shift; wantarray ? map { $self->subtest_class->new($_) } @_ : @_ }
sub _test_structs {
my $self = shift;
- my $max = $self->{struct}{results}{max};
+ my $max = $self->{struct}{results}->max();
# cases is an array of *copies*... that's what the map is about
my @cases = grep { exists $_->{type} and $_->{type} eq "test" } @{ $self->{struct}{events} };
@@ -82,18 +82,19 @@
}
# queries about the test cases
-sub planned { $_[0]{struct}{results}{max} };
+sub planned { $_[0]{struct}{results}->max() };
sub cases {
- my @values = @{ $_[0]{struct}{results} }{qw/seen max/};
+ my $results = $_[0]{struct}{results};
+ my @values = $results->seen(), $results->max();
my $scalar = List::Util::max(@values);
$_[0]->_c(sub { 1 }, $scalar)
};
-sub actual_cases { $_[0]->_c(sub { $_->{line} ne "stub" }, $_[0]{struct}{results}{seen}) }
-sub ok_tests { $_[0]->_c(sub { $_->{ok} }, $_[0]{struct}{results}{ok}) };
+sub actual_cases { $_[0]->_c(sub { $_->{line} ne "stub" }, $_[0]{struct}{results}->seen() ) }
+sub ok_tests { $_[0]->_c(sub { $_->{ok} }, $_[0]{struct}{results}->ok() ) };
sub nok_tests { $_[0]->_c(sub { not $_->{ok} }, $_[0]->seen - $_[0]->ok_tests )};
-sub todo_tests { $_[0]->_c(sub { $_->{todo} }, $_[0]{struct}{results}{todo}) }
-sub skipped_tests { $_[0]->_c(sub { $_->{skip} }, $_[0]{struct}{results}{skip}) }
+sub todo_tests { $_[0]->_c(sub { $_->{todo} }, $_[0]{struct}{results}->todo() ) }
+sub skipped_tests { $_[0]->_c(sub { $_->{skip} }, $_[0]{struct}{results}->skip() ) }
sub unexpectedly_succeeded_tests { $_[0]->_c(sub { $_->{todo} and $_->{actual_ok} }) }
sub ratio {
diff -ur Test-TAP-Model-0.06/lib/Test/TAP/Model.pm Test-TAP-Model-0.06_new/lib/Test/TAP/Model.pm
--- Test-TAP-Model-0.06/lib/Test/TAP/Model.pm 2006-03-27 10:46:39.000000000 -0800
+++ Test-TAP-Model-0.06_new/lib/Test/TAP/Model.pm 2006-12-08 23:00:34.000000000 -0800
@@ -31,7 +31,7 @@
sub _handle_test {
my($self, $line, $type, $totals) = @_;
- my $curr = $totals->{seen}||0;
+ my $curr = $totals->seen() || 0;
# this is used by pugs' Test.pm, it's rather useful
my $pos;
@@ -40,7 +40,7 @@
$pos = $2;
}
- my %details = %{ $totals->{details}[-1] };
+ my %details = %{ $totals->details()->[-1] };
$self->log_event(
type => 'test',
@@ -48,7 +48,7 @@
ok => $details{ok},
actual_ok => $details{actual_ok},
str => $details{ok} # string for people
- ? "ok $curr/$totals->{max}"
+ ? "ok $curr/" . $totals->max()
: "NOK $curr",
todo => ($details{type} eq 'todo'),
skip => ($details{type} eq 'skip'),
@@ -169,8 +169,8 @@
my $test_file = $self->start_file($file);
- my %results = eval { $self->analyze_file($file) };
- $test_file->{results} = \%results;
+ my $results = eval { $self->analyze_file($file) };
+ $test_file->{results} = $results;
delete $test_file->{results}{details};
$test_file;
diff -ur Test-TAP-Model-0.06/t/basic.t Test-TAP-Model-0.06_new/t/basic.t
--- Test-TAP-Model-0.06/t/basic.t 2006-03-27 10:46:39.000000000 -0800
+++ Test-TAP-Model-0.06_new/t/basic.t 2006-12-08 22:48:43.000000000 -0800
@@ -15,7 +15,7 @@
can_ok($t, "start_file");
my $e = $t->start_file("example");
-$e->{results} = { $t->analyze_fh("example", \*DATA) };
+$e->{results} = $t->analyze_fh("example", \*DATA);
isa_ok(my $s = $t->structure, "HASH");
diff -ur Test-TAP-Model-0.06/t/lib/StringHarness.pm Test-TAP-Model-0.06_new/t/lib/StringHarness.pm
--- Test-TAP-Model-0.06/t/lib/StringHarness.pm 2006-03-27 10:46:39.000000000 -0800
+++ Test-TAP-Model-0.06_new/t/lib/StringHarness.pm 2006-12-08 22:55:45.000000000 -0800
@@ -17,7 +17,7 @@
$output = [split /\n/,$output];
my $r = $s->start_file($name);
- eval { $r->{results} = { $s->analyze($name, $output) } };
+ eval { $r->{results} = $s->analyze($name, $output) };
}
return $s;
diff -ur Test-TAP-Model-0.06/t/oop_file.t Test-TAP-Model-0.06_new/t/oop_file.t
--- Test-TAP-Model-0.06/t/oop_file.t 2006-03-27 10:46:39.000000000 -0800
+++ Test-TAP-Model-0.06_new/t/oop_file.t 2006-12-08 23:08:11.000000000 -0800
@@ -6,10 +6,18 @@
# TODO not very comprehensive
use Test::More tests => 16;
+use Test::Harness::Results;
my $m;
BEGIN { use_ok($m = "Test::TAP::Model::File") }
+my $r = Test::Harness::Results->new();
+$r->inc_max( 3 );
+$r->inc_seen() for 1 .. 12;
+$r->inc_ok( 10 );
+$r->inc_todo() for 1 .. 11;
+$r->inc_skip() for 1 .. 13;
+
isa_ok(my $f = $m->new(my $file = {
events => [
my $ok_case = {
@@ -21,24 +29,17 @@
ok => 0,
},
],
- results => my $r = {
- passing => 0,
- ok => 10,
- todo => 11,
- max => 3,
- seen => 12,
- skip => 13,
- }
+ results => $r,
}), $m);
ok(!$f->ok, "failed");
-$r->{passing} = 1;
+$r->set_passing( 1 );
ok($f->ok, "passed");
is($f->passed, $f->ok, "alias");
is($f->failed, !$f->ok, "negation");
ok(!$f->skipped, "not all skipped");
-$r->{skip_all} = "reason";
+$r->set_skip_all( "reason" );
ok($f->skipped, "all skipped");
# demonstrates scalar context
@@ -49,6 +50,6 @@
is($f->todo_tests, 11, "none are todo");
$nok_case->{todo} = 1;
is($f->todo_tests, 11, "none are todo");
-$r->{todo} = 2;
-is($f->todo_tests, 2, "two todo");
+$r->inc_todo();
+is($f->todo_tests, 12, "two todo");
is($f->skipped_tests, 13, "13 skipped");
diff -ur Test-TAP-Model-0.06/t/pos_guessing.t Test-TAP-Model-0.06_new/t/pos_guessing.t
--- Test-TAP-Model-0.06/t/pos_guessing.t 2006-03-27 10:46:39.000000000 -0800
+++ Test-TAP-Model-0.06_new/t/pos_guessing.t 2006-12-08 22:51:11.000000000 -0800
@@ -11,7 +11,7 @@
isa_ok(my $s = $m->new, $m);
my $f = $s->start_file("foo");
-eval { $f->{results} = { $s->analyze("foo", [split /\n/, <<TAP]) } };
+eval { $f->{results} = $s->analyze("foo", [split /\n/, <<TAP]) };
1..3
ok 1 foo <pos:foo.t at line 2, column 1>
ok 2 foo <pos:file "gorch" line 4>