# HG changeset patch # User cin # Date 1442182313 -10800 # Node ID 9335cf010b23c94ba66193629ffc2e463638406d # Parent f7eeafbd33da47232b240f20438cadf3211ebb05 refactoring diff -r f7eeafbd33da -r 9335cf010b23 lib/IMPL/Test/Plan.pm --- a/lib/IMPL/Test/Plan.pm Sun Sep 13 19:30:49 2015 +0300 +++ b/lib/IMPL/Test/Plan.pm Mon Sep 14 01:11:53 2015 +0300 @@ -152,9 +152,9 @@ $this->_Tell(RunTest => $badTest); my $result = new IMPL::Test::Result( - Name => $test->Name, - State => IMPL::Test::Result::FAIL, - Exception => $e + name => $test->Name, + state => IMPL::Test::Result::FAIL, + exception => $e ); $this->_Tell(EndTest => $badTest,$result); push @results,$result; diff -r f7eeafbd33da -r 9335cf010b23 lib/IMPL/Test/Result.pm --- a/lib/IMPL/Test/Result.pm Sun Sep 13 19:30:49 2015 +0300 +++ b/lib/IMPL/Test/Result.pm Mon Sep 14 01:11:53 2015 +0300 @@ -2,8 +2,20 @@ use strict; use warnings; -use parent qw(IMPL::Object IMPL::Object::Autofill IMPL::Object::Serializable); -use IMPL::Class::Property; +use IMPL::Const qw(:prop); +use IMPL::declare { + base => [ + 'IMPL::Object' => undef, + 'IMPL::Object::Serializable' => '@_' + ], + props => [ + name => PROP_RW, + state => PROP_RW, + exception => PROP_RW, + timeExclusive => PROP_RW, + timeInclusive => PROP_RW + ] +}; __PACKAGE__->PassThroughArgs; @@ -13,19 +25,17 @@ ERROR => 2 }; -BEGIN { - public property Name => prop_all; - public property State => prop_all; - public property Exception => prop_all; - public property TimeExclusive => prop_all; - public property TimeInclusive => prop_all; -} - sub CTOR { - my ($this) = @_; + my $this = shift; + + my $fields = @_ == 1 ? $_[0] : {@_}; - $this->TimeInclusive(0) unless defined $this->TimeInclusive; - $this->TimeExclusive(0) unless defined $this->TimeExclusive; + $fields->{timeExclusive} ||= 0; + $fields->{timeInclusive} ||= 0; + + while (my ($k,$v) = each %$fields) { + $this->$k($v); + } } diff -r f7eeafbd33da -r 9335cf010b23 lib/IMPL/Test/TAPListener.pm --- a/lib/IMPL/Test/TAPListener.pm Sun Sep 13 19:30:49 2015 +0300 +++ b/lib/IMPL/Test/TAPListener.pm Mon Sep 14 01:11:53 2015 +0300 @@ -55,10 +55,10 @@ $this->_testNo($n+1); print $out ( - $result->State == IMPL::Test::Result::SUCCESS ? - "ok $n " . join("\n# ", split(/\n/, $result->Name) ) + $result->state == IMPL::Test::Result::SUCCESS ? + "ok $n " . join("\n# ", split(/\n/, $result->name) ) : - (eval { $result->Exception->isa('IMPL::Test::SkipException') } ? "ok $n #SKIP: " : "not ok $n ") . join("\n# ", split(/\n/, $result->Name.": ".$result->Exception || '') ) + (eval { $result->exception->isa('IMPL::Test::SkipException') } ? "ok $n #SKIP: " : "not ok $n ") . join("\n# ", split(/\n/, $result->name.": ".$result->exception || '') ) ),"\n"; } diff -r f7eeafbd33da -r 9335cf010b23 lib/IMPL/Test/Unit.pm --- a/lib/IMPL/Test/Unit.pm Sun Sep 13 19:30:49 2015 +0300 +++ b/lib/IMPL/Test/Unit.pm Mon Sep 14 01:11:53 2015 +0300 @@ -86,26 +86,26 @@ }; return new IMPL::Test::Result( - Name => $this->Name, - State => IMPL::Test::Result::SUCCESS, - TimeExclusive => $elapsed, - TimeInclusive => tv_interval ( $t ) + name => $this->Name, + state => IMPL::Test::Result::SUCCESS, + timeExclusive => $elapsed, + timeInclusive => tv_interval ( $t ) ); } catch IMPL::Test::FailException with { my $e = shift; return new IMPL::Test::Result( - Name => $this->Name, - State => IMPL::Test::Result::FAIL, - Exception => $e, - TimeInclusive => tv_interval ( $t ) + name => $this->Name, + state => IMPL::Test::Result::FAIL, + exception => $e, + timeInclusive => tv_interval ( $t ) ); } otherwise { my $e = shift; return new IMPL::Test::Result( - Name => $this->Name, - State => IMPL::Test::Result::ERROR, - Exception => $e, - TimeInclusive => tv_interval ( $t ) + name => $this->Name, + state => IMPL::Test::Result::ERROR, + exception => $e, + timeInclusive => tv_interval ( $t ) ); } }