view Lib/IMPL/Test/TAPListener.pm @ 49:16ada169ca75

migrating to the Eclipse IDE
author wizard@linux-odin.local
date Fri, 26 Feb 2010 10:49:21 +0300
parents 03e58a454b20
children e568c7c8b743
line wrap: on
line source

package IMPL::Test::TAPListener;
use strict;
use warnings;

use base 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) )
                :
            "not ok $n " . (eval { $result->Exception->isa('IMPL::Test::SkipException') } ? '# SKIP ' : '') . join("\n# ", split(/\n/, $result->Name."\n".$result->Exception || '') )
        ),"\n";
        
}

sub save {
    
}

1;