annotate Lib/IMPL/Test/BadUnit.pm @ 393:69a1f1508696

minor security refactoring
author cin
date Fri, 14 Feb 2014 16:41:12 +0400
parents 4267a2ac3d46
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
1 package IMPL::Test::BadUnit;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
4
166
4267a2ac3d46 Added Class::Template,
wizard
parents: 49
diff changeset
5 use parent qw(IMPL::Test::Unit);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
6 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
7
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
8 BEGIN {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
9 public property UnitName => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
10 public property Message => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
11 public property Error => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
12 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
13
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
14 our %CTOR = (
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
15 'IMPL::Test::Unit' => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
16 if (@_>1) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
17 # Unit construction
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
18 my ($unit,$message,$error) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
19 return new IMPL::Test::Unit::TestInfo(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
20 BadUnitTest => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
21 die new IMPL::Test::FailException($message,$unit,eval {$error->isa('IMPL::Exception')} ? $error->toString(1) : $error)
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
22 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
23 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
24 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
25 # test construction
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
26 return @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
27 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
28 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
29 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
30
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
31 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
32 my ($this,$name,$message,$error) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
33
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
34 $this->UnitName($name);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
35 $this->Message($message);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
36 $this->Error($error);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
37 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
38
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
39 sub save {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
40 my ($this,$ctx) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
41
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
42 defined ($this->$_()) and $ctx->AddVar($_ => $this->$_()) foreach qw(UnitName Message);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
43 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
44
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
45 sub restore {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
46 my ($class,$data,$inst) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
47
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
48 my %args = @$data;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
50 $inst ||= $class->surrogate;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
51 $inst->callCTOR(@args{qw(UnitName Message)});
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
52 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
53
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
54 sub List {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
55 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
56 my $error = $this->Error;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
57 return new IMPL::Test::Unit::TestInfo(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
58 BadUnitTest => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
59 die new IMPL::Test::FailException($this->Message,$this->UnitName,eval {$error->isa('IMPL::Exception')} ? $error->toString(1) : $error)
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
60 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
61 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
62 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
63
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
64
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 31
diff changeset
65 1;