1use Test;
2BEGIN { $| = 1; plan(tests => 10); chdir 't' if -d 't'; }
3use blib;
4
5## garbage testing
6
7use Mail::Procmailrc;
8
9my $rcfile;
10my @rcfile;
11my $pmrc = new Mail::Procmailrc;
12
13$rcfile =<<'_RCFILE_';
14## nice recipe
15:0B:
16
17## some conditions here
18* foo
19* bar
20
21## file away
22/dev/foobar
23_RCFILE_
24
25ok( $pmrc->parse( $rcfile ) );
26ok( $pmrc->dump, <<'_RCFILE_' );
27## nice recipe
28:0B:
29## some conditions here
30* foo
31* bar
32/dev/foobar
33_RCFILE_
34
35ok( $pmrc->rc->[1]->action, '/dev/foobar' );
36
37$rcfile =<<'_RCFILE_';
38this won't parse!
39at all!
40not in a million years
41this is garbage
42 sdlfkja sdf:0 sldkjaf sdf
43_RCFILE_
44
45ok( $pmrc->parse( $rcfile ) );
46ok( $pmrc->dump, '' );
47
48$rcfile =<<'_RCFILE_';
49this won't parse!
50at all!
51not in a million years
52this is garbage
53 sdlfkja sdf:0 sldkjaf sdf
54:0
55## nothing happens
56* my name is larry
57/dev/null
58more garbage is here!
59 sdlfkjas dfliua sdf;
60
61_RCFILE_
62
63ok( $pmrc->parse( $rcfile ) );
64ok( $pmrc->dump, <<'_RCFILE_' );
65:0
66## nothing happens
67* my name is larry
68/dev/null
69_RCFILE_
70
71
72###########################
73## test for undefs in object
74
75$rcfile =<<'_RCFILE_';
76:0
77## test
78* testing
79testing
80
81## just a comment
82## another comment
83_RCFILE_
84
85ok( $pmrc->parse($rcfile) );
86ok( $pmrc->dump, $rcfile );
87for my $o ( @{$pmrc->rc} ) {
88    next unless $o->stringify =~ /^\#\# just a comment/;
89    undef $o;
90}
91
92ok( $pmrc->dump, <<'_RCFILE_' );
93:0
94## test
95* testing
96testing
97
98## another comment
99_RCFILE_
100
101
102###########################
103##
104
105exit;
106