diff lib/IMPL/Test/TAPListener.pm @ 407:c6e90e02dd17 ref20150831

renamed Lib->lib
author cin
date Fri, 04 Sep 2015 19:40:23 +0300
parents
children 9335cf010b23
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/IMPL/Test/TAPListener.pm	Fri Sep 04 19:40:23 2015 +0300
@@ -0,0 +1,70 @@
+package IMPL::Test::TAPListener;
+use strict;
+use warnings;
+
+use parent qw(IMPL::Object IMPL::Object::Serializable);
+use IMPL::Class::Property;
+use IMPL::Test::Result;
+
+BEGIN {
+    private property _Output => prop_all;
+    private property _testNo => prop_all;
+}
+
+sub CTOR {
+    my ($this,$out) = @_;
+    
+    $this->_Output($out || *STDOUT);
+    $this->_testNo(1);
+}
+
+sub RunPlan {
+    my ($this,$plan) = @_;
+    
+    my $out = $this->_Output;
+    
+    print $out "1..",$plan->Count,"\n";
+}
+
+sub EndPlan {
+    
+}
+
+sub RunUnit {
+    my ($this,$unit) = @_;
+    
+    my $out = $this->_Output;
+    
+    print $out "#\n",join("\n",map "# $_", split /\n/, "Running unit: " . $unit->UnitName, ),"\n#\n";
+}
+
+sub EndUnit {
+    
+}
+
+sub RunTest {
+    
+}
+
+sub EndTest {
+    my ($this,$test,$result) = @_;
+    
+    my $out = $this->_Output;
+    my $n = $this->_testNo;
+    
+    $this->_testNo($n+1);
+    
+    print $out (
+            $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 || '') )
+        ),"\n";
+        
+}
+
+sub save {
+    
+}
+
+1;