~ubuntu-branches/ubuntu/jaunty/libsmart-comments-perl/jaunty

« back to all changes in this revision

Viewing changes to t/insist.t

  • Committer: Bazaar Package Importer
  • Author(s): Niko Tyni
  • Date: 2006-02-23 21:04:24 UTC
  • Revision ID: james.westby@ubuntu.com-20060223210424-whjyxstf09uvk53u
Tags: upstream-1.0.2
ImportĀ upstreamĀ versionĀ 1.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
use Smart::Comments;
 
2
use Test::More 'no_plan';
 
3
 
 
4
close *STDERR;
 
5
my $STDERR = q{};
 
6
open *STDERR, '>', \$STDERR;
 
7
 
 
8
my $x = 0;
 
9
### insist: $x < 1
 
10
 
 
11
ok length $STDERR == 0           => 'True insist is silent';
 
12
 
 
13
$ASSERTION = << 'END_ASSERT';
 
14
 
 
15
# $x < 0 was not true at FILE line 22.
 
16
#     $x was: 0
 
17
END_ASSERT
 
18
 
 
19
$ASSERTION =~ s/#/###/g;
 
20
 
 
21
eval {
 
22
### insist: $x < 0
 
23
};
 
24
 
 
25
ok $@                            => 'False insist is deadly';
 
26
ok $@ eq "\n"                    => 'False insist is deadly silent';
 
27
 
 
28
$STDERR =~ s/ at \S+ line / at FILE line /;
 
29
 
 
30
ok length $STDERR != 0           => 'False insist is loud';
 
31
is $STDERR, $ASSERTION           => 'False insist is loudly correct';
 
32
 
 
33
close *STDERR;
 
34
$STDERR = q{};
 
35
open *STDERR, '>', \$STDERR;
 
36
 
 
37
my $y = [];
 
38
   $x = 10;
 
39
 
 
40
my $ASSERTION2 = << 'END_ASSERTION2';
 
41
 
 
42
# $y < $x was not true at FILE line 50.
 
43
#     $y was: []
 
44
#     $x was: 10
 
45
END_ASSERTION2
 
46
 
 
47
$ASSERTION2 =~ s/#/###/g;
 
48
 
 
49
eval {
 
50
### insist: $y < $x
 
51
};
 
52
 
 
53
ok $@                            => 'False two-part insist is deadly';
 
54
ok $@ eq "\n"                    => 'False two-part insist is deadly silent';
 
55
 
 
56
$STDERR =~ s/ at \S+ line / at FILE line /;
 
57
 
 
58
ok length $STDERR != 0           => 'False two-part insist is loud';
 
59
is $STDERR, $ASSERTION2          => 'False two-part insist is loudly correct';