3 # This file is part of Acme::Tie::Eleet.
4 # Copyright (c) 2001-2007 Jerome Quelin, all rights reserved.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the same terms as Perl itself.
15 #-----------------------------------#
17 #-----------------------------------#
21 # use POSIX qw(tmpnam);
24 # BEGIN { plan tests => 16 };
25 BEGIN { plan tests => 8 };
28 require Acme::Tie::Eleet;
34 # my $file = tmpnam();
47 #------------------------------#
49 #------------------------------#
51 # # Wrong spacer (pattern non numeric).
53 # open OUT, ">$file" or die "Unable to create temporary file: $!";
54 # tie *OUT, 'Acme::Tie::Eleet', *OUT, @opts, spacer=>"aa";
56 # ok($@, qr/^spacer: wrong pattern /);
58 # # Random: no spacing (0).
59 # open OUT, ">$file" or die "Unable to create temporary file: $!";
60 # tie *OUT, 'Acme::Tie::Eleet', *OUT, @opts, spacer=>0;
63 # open IN, "<$file" or die "Unable to open temporary file: $!";
65 # ok($line, qr/^e ?l ?e ?e ?t ?/);
67 # # Random: spacing (75).
68 # open OUT, ">$file" or die "Unable to create temporary file: $!";
69 # tie *OUT, 'Acme::Tie::Eleet', *OUT, @opts, spacer=>75;
72 # open IN, "<$file" or die "Unable to open temporary file: $!";
74 # ok($line, qr/^e ?l ?e ?e ?t ?/);
76 # # Random: max spacing (100).
77 # open OUT, ">$file" or die "Unable to create temporary file: $!";
78 # tie *OUT, 'Acme::Tie::Eleet', *OUT, @opts, spacer=>100;
81 # open IN, "<$file" or die "Unable to open temporary file: $!";
83 # ok($line, qr/^e l e e t /);
85 # # Pattern: illegal pattern (0/0).
87 # open OUT, ">$file" or die "Unable to create temporary file: $!";
88 # tie *OUT, 'Acme::Tie::Eleet', *OUT, @opts, spacer=>"0/0";
90 # ok($@, qr!^spacer: illegal pattern 0/0!);
92 # # Pattern: no spacing (0/1).
93 # open OUT, ">$file" or die "Unable to create temporary file: $!";
94 # tie *OUT, 'Acme::Tie::Eleet', *OUT, @opts, spacer=>"0/1";
97 # open IN, "<$file" or die "Unable to open temporary file: $!";
99 # ok($line, qr/^eleet/);
101 # # Pattern: one on two (1/1).
102 # open OUT, ">$file" or die "Unable to create temporary file: $!";
103 # tie *OUT, 'Acme::Tie::Eleet', *OUT, @opts, spacer=>"1/1";
104 # print OUT "eleeteleet";
106 # open IN, "<$file" or die "Unable to open temporary file: $!";
108 # ok($line, qr/^e le et el ee t/);
110 # # Pattern: max spacing (1/0).
111 # open OUT, ">$file" or die "Unable to create temporary file: $!";
112 # tie *OUT, 'Acme::Tie::Eleet', *OUT, @opts, spacer=>"1/0";
115 # open IN, "<$file" or die "Unable to open temporary file: $!";
117 # ok($line, qr/^e l e e t /);
122 #------------------------------#
124 #------------------------------#
126 # Wrong spacer (pattern non numeric).
128 tie $line, 'Acme::Tie::Eleet', @opts, spacer=>"aa";
130 ok($@, qr/^spacer: wrong pattern /);
133 # Random: no spacing (0).
134 tie $line, 'Acme::Tie::Eleet', @opts, spacer=>0;
136 ok($line, qr/^e ?l ?e ?e ?t ?/);
139 # Random: spacing (75).
140 tie $line, 'Acme::Tie::Eleet', @opts, spacer=>75;
142 ok($line, qr/^e ?l ?e ?e ?t ?/);
145 # Random: max spacing (100).
146 tie $line, 'Acme::Tie::Eleet', @opts, spacer=>100;
148 ok($line, qr/^e l e e t /);
151 # Pattern: illegal pattern (0/0).
153 tie $line, 'Acme::Tie::Eleet', @opts, spacer=>"0/0";
155 ok($@, qr!^spacer: illegal pattern 0/0!);
158 # Pattern: no spacing (0/1).
159 tie $line, 'Acme::Tie::Eleet', @opts, spacer=>"0/1";
161 ok($line, qr/^eleet/);
164 # Pattern: one on two (1/1).
165 tie $line, 'Acme::Tie::Eleet', @opts, spacer=>"1/1";
166 $line = "eleeteleet";
167 ok($line, qr/^e le et el ee t/);
170 # Pattern: max spacing (1/0).
171 tie $line, 'Acme::Tie::Eleet', @opts, spacer=>"1/0";
173 ok($line, qr/^e l e e t /);