comparison Lib/IMPL/Test/BadUnit.pm @ 0:03e58a454b20

Создан репозитарий
author Sergey
date Tue, 14 Jul 2009 12:54:37 +0400
parents
children d59526f6310e
comparison
equal deleted inserted replaced
-1:000000000000 0:03e58a454b20
1 package IMPL::Test::BadUnit;
2 use strict;
3 use warnings;
4
5 use base qw(IMPL::Test::Unit);
6 use IMPL::Class::Property;
7
8 BEGIN {
9 public property UnitName => prop_all;
10 public property Message => prop_all;
11 public property Error => prop_all;
12 }
13
14 our %CTOR = (
15 'IMPL::Test::Unit' => sub {
16 my ($unit,$message,$error) = @_;
17 return new IMPL::Test::Unit::TestInfo(
18 BadUnitTest => sub {
19 die new IMPL::Test::FailException($message,$unit,eval {$error->isa('IMPL::Exception')} ? $error->toString(1) : $error)
20 }
21 );
22 }
23 );
24
25 sub CTOR {
26 my ($this,$name,$message,$error) = @_;
27
28 $this->UnitName($name);
29 $this->Message($message);
30 $this->Error($error);
31 }
32
33 sub save {
34 my ($this,$ctx) = @_;
35
36 defined ($this->$_()) and $ctx->AddVar($_ => $this->$_()) foreach qw(UnitName Message);
37 }
38
39 sub restore {
40 my ($class,$data,$inst) = @_;
41
42 my %args = @$data;
43
44 $inst ||= $class->surrogate;
45 $inst->callCTOR(@args{qw(UnitName Message)});
46 }
47
48
49 1;