changeset 410:9335cf010b23 ref20150831

refactoring
author cin
date Mon, 14 Sep 2015 01:11:53 +0300
parents f7eeafbd33da
children ee36115f6a34
files lib/IMPL/Test/Plan.pm lib/IMPL/Test/Result.pm lib/IMPL/Test/TAPListener.pm lib/IMPL/Test/Unit.pm
diffstat 4 files changed, 41 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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);
+    }
 }
 
 
--- 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";
         
 }
--- 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 )
         );
     }
 }