Mercurial > pub > Impl
comparison Lib/IMPL/Test.pm @ 194:4d0e1962161c
Replaced tabs with spaces
IMPL::Web::View - fixed document model, new features (control classes, document constructor parameters)
author | cin |
---|---|
date | Tue, 10 Apr 2012 20:08:29 +0400 |
parents | 029c9610528c |
children | 6253872024a4 |
comparison
equal
deleted
inserted
replaced
193:8e8401c0aea4 | 194:4d0e1962161c |
---|---|
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 { | 41 sub assert { |
42 my ($condition,@params) = @_; | 42 my ($condition,@params) = @_; |
43 | 43 |
44 die new IMPL::Test::FailException(@params ? @params : ("Assertion failed" , _GetSourceLine( (caller)[1,2] )) ) unless $condition; | 44 die new IMPL::Test::FailException(@params ? @params : ("Assertion failed" , _GetSourceLine( (caller)[1,2] )) ) unless $condition; |
45 } | 45 } |
46 | 46 |
47 sub skip($;@) { | 47 sub skip($;@) { |
48 die new IMPL::Test::SkipException(@_); | 48 die new IMPL::Test::SkipException(@_); |
49 } | 49 } |
50 | 50 |
51 sub cmparray { | 51 sub cmparray { |
52 my ($a,$b) = @_; | 52 my ($a,$b) = @_; |
53 | 53 |
59 | 59 |
60 return 1; | 60 return 1; |
61 } | 61 } |
62 | 62 |
63 sub _GetSourceLine { | 63 sub _GetSourceLine { |
64 my ($file,$line) = @_; | 64 my ($file,$line) = @_; |
65 | 65 |
66 open my $hFile, $file or return "failed to open file: $file: $!"; | 66 open my $hFile, $file or return "failed to open file: $file: $!"; |
67 | 67 |
68 my $text; | 68 my $text; |
69 $text = <$hFile> for ( 1 .. $line); | 69 $text = <$hFile> for ( 1 .. $line); |
70 chomp $text; | 70 chomp $text; |
71 $text =~ s/^\s+//; | 71 $text =~ s/^\s+//; |
72 return "line $line: $text"; | 72 return "line $line: $text"; |
73 } | 73 } |
74 | 74 |
75 sub GetCallerSourceLine { | 75 sub GetCallerSourceLine { |
76 my $line = shift || 0; | 76 my $line = shift || 0; |
77 return _GetSourceLine( (caller($line + 1))[1,2] ) | 77 return _GetSourceLine( (caller($line + 1))[1,2] ) |
78 } | 78 } |
79 | 79 |
80 sub run_plan { | 80 sub run_plan { |
81 my (@units) = @_; | 81 my (@units) = @_; |
82 | 82 |
83 my $plan = new IMPL::Test::Plan(@units); | 83 my $plan = new IMPL::Test::Plan(@units); |
84 | 84 |
85 $plan->Prepare; | 85 $plan->Prepare; |
86 $plan->AddListener(new IMPL::Test::TAPListener); | 86 $plan->AddListener(new IMPL::Test::TAPListener); |
87 $plan->Run; | 87 $plan->Run; |
88 } | 88 } |
89 1; | 89 1; |