Mercurial > pub > Impl
comparison Lib/IMPL/Test.pm @ 165:76515373dac0
Added Class::Template,
Rewritten SQL::Schema
'use parent' directive instead of 'use base'
author | wizard |
---|---|
date | Sat, 23 Apr 2011 23:06:48 +0400 |
parents | f8de52d3c112 |
children | 029c9610528c |
comparison
equal
deleted
inserted
replaced
164:eb3e9861a761 | 165:76515373dac0 |
---|---|
4 | 4 |
5 require IMPL::Test::SkipException; | 5 require IMPL::Test::SkipException; |
6 | 6 |
7 require Exporter; | 7 require Exporter; |
8 our @ISA = qw(Exporter); | 8 our @ISA = qw(Exporter); |
9 our @EXPORT_OK = qw(&test &shared &failed &cmparray &skip &run_plan); | 9 our @EXPORT_OK = qw(&test &shared &failed &cmparray &skip &run_plan &assert); |
10 | 10 |
11 require IMPL::Test::Unit; | 11 require IMPL::Test::Unit; |
12 require IMPL::Test::Plan; | 12 require IMPL::Test::Plan; |
13 require IMPL::Test::TAPListener; | 13 require IMPL::Test::TAPListener; |
14 use IMPL::Class::Member; | 14 use IMPL::Class::Member; |
36 | 36 |
37 sub failed($;@) { | 37 sub failed($;@) { |
38 die new IMPL::Test::FailException(@_); | 38 die new IMPL::Test::FailException(@_); |
39 } | 39 } |
40 | 40 |
41 sub assert { | |
42 my ($condition,@params) = @_; | |
43 | |
44 die new IMPL::Test::FailException(@params ? @params : ("Assertion failed" , _GetSourceLine( (caller)[1,2] )) ) unless $condition; | |
45 } | |
46 | |
41 sub skip($;@) { | 47 sub skip($;@) { |
42 die new IMPL::Test::SkipException(@_); | 48 die new IMPL::Test::SkipException(@_); |
43 } | 49 } |
44 | 50 |
45 sub cmparray { | 51 sub cmparray { |
52 } | 58 } |
53 | 59 |
54 return 1; | 60 return 1; |
55 } | 61 } |
56 | 62 |
63 sub _GetSourceLine { | |
64 my ($file,$line) = @_; | |
65 | |
66 open my $hFile, $file or return "failed to open file: $file: $!"; | |
67 | |
68 my $text; | |
69 $text = <$hFile> for ( 1 .. $line); | |
70 chomp $text; | |
71 $text =~ s/^\s+//; | |
72 return "line $line: $text"; | |
73 } | |
74 | |
57 sub run_plan { | 75 sub run_plan { |
58 my (@units) = @_; | 76 my (@units) = @_; |
59 | 77 |
60 my $plan = new IMPL::Test::Plan(@units); | 78 my $plan = new IMPL::Test::Plan(@units); |
61 | 79 |