4 use Test
::More tests
=> 43;
7 # TEST CASE 1 - 1 variable, from 1 to 4
9 lastvalue1
=> 1, lastvalue2
=> 1, lastvalue3
=> 1,
10 innerloop1
=> 0, innerloop2
=> 0, innerloop3
=> 0,
16 add1
=> 1, add2
=> 0, add3
=> 0,
17 every1
=> 1, every2
=> 0, every3
=> 0,
18 whenmorethan1
=> 4, whenmorethan2
=> 0, whenmorethan3
=> 0,
19 setto1
=> 1, setto2
=> 0, setto3
=> 0,
20 numberingmethod
=> 'X: {X}',
26 my $seq = _next_seq
($subscription, $pattern);
28 $seq = _next_seq
($subscription, $pattern);
30 $seq = _next_seq
($subscription, $pattern);
32 $seq = _next_seq
($subscription, $pattern);
34 $seq = _next_seq
($subscription, $pattern);
37 # TEST CASE 2 - 1 variable, use 'dayname' numbering, from 1 to 7
39 lastvalue1
=> 1, lastvalue2
=> 1, lastvalue3
=> 1,
40 innerloop1
=> 0, innerloop2
=> 0, innerloop3
=> 0,
46 add1
=> 1, add2
=> 0, add3
=> 0,
47 every1
=> 1, every2
=> 0, every3
=> 0,
48 whenmorethan1
=> 7, whenmorethan2
=> 0, whenmorethan3
=> 0,
49 setto1
=> 1, setto2
=> 0, setto3
=> 0,
50 numberingmethod
=> 'X: {X}',
51 numbering1
=> 'dayname',
56 $seq = _next_seq
($subscription, $pattern);
57 is
($seq, 'X: Tuesday');
58 $seq = _next_seq
($subscription, $pattern);
59 is
($seq, 'X: Wednesday');
60 $seq = _next_seq
($subscription, $pattern);
61 is
($seq, 'X: Thursday');
62 $seq = _next_seq
($subscription, $pattern);
63 is
($seq, 'X: Friday');
64 $seq = _next_seq
($subscription, $pattern);
65 is
($seq, 'X: Saturday');
66 $seq = _next_seq
($subscription, $pattern);
67 is
($seq, 'X: Sunday');
68 $seq = _next_seq
($subscription, $pattern);
69 is
($seq, 'X: Monday');
71 # TEST CASE 3 - 1 variable, use 'monthname' numbering, from 0 to 11 by step of 2
73 lastvalue1
=> 0, lastvalue2
=> 1, lastvalue3
=> 1,
74 innerloop1
=> 0, innerloop2
=> 0, innerloop3
=> 0,
77 locale
=> 'C', # locale set to 'C' to ensure we'll have english strings
80 add1
=> 2, add2
=> 0, add3
=> 0,
81 every1
=> 1, every2
=> 0, every3
=> 0,
82 whenmorethan1
=> 11, whenmorethan2
=> 0, whenmorethan3
=> 0,
83 setto1
=> 0, setto2
=> 0, setto3
=> 0,
84 numberingmethod
=> 'X: {X}',
85 numbering1
=> 'monthname',
90 $seq = _next_seq
($subscription, $pattern);
92 $seq = _next_seq
($subscription, $pattern);
94 $seq = _next_seq
($subscription, $pattern);
96 $seq = _next_seq
($subscription, $pattern);
97 is
($seq, 'X: September');
98 $seq = _next_seq
($subscription, $pattern);
99 is
($seq, 'X: November');
100 $seq = _next_seq
($subscription, $pattern);
101 is
($seq, 'X: January');
102 $seq = _next_seq
($subscription, $pattern);
103 is
($seq, 'X: March');
105 # TEST CASE 4 - 1 variable, use 'season' numbering, from 0 to 3
106 # Months starts at 0, this implies subscription's lastvalue1 should be 0,
107 # together with setto1 and whenmorethan1 should be 11
109 lastvalue1
=> 0, lastvalue2
=> 1, lastvalue3
=> 1,
110 innerloop1
=> 0, innerloop2
=> 0, innerloop3
=> 0,
113 locale
=> 'C', # locale set to 'C' to ensure we'll have english strings
116 add1
=> 1, add2
=> 0, add3
=> 0,
117 every1
=> 1, every2
=> 0, every3
=> 0,
118 whenmorethan1
=> 3, whenmorethan2
=> 0, whenmorethan3
=> 0,
119 setto1
=> 0, setto2
=> 0, setto3
=> 0,
120 numberingmethod
=> 'X: {X}',
121 numbering1
=> 'season',
126 $seq = _next_seq
($subscription, $pattern);
127 is
($seq, 'X: Summer');
128 $seq = _next_seq
($subscription, $pattern);
130 $seq = _next_seq
($subscription, $pattern);
131 is
($seq, 'X: Winter');
132 $seq = _next_seq
($subscription, $pattern);
133 is
($seq, 'X: Spring');
134 $seq = _next_seq
($subscription, $pattern);
135 is
($seq, 'X: Summer');
137 # TEST CASE 5 - 2 variables, from 1 to 12, and from 1 to 4
139 lastvalue1
=> 1, lastvalue2
=> 1, lastvalue3
=> 1,
140 innerloop1
=> 0, innerloop2
=> 0, innerloop3
=> 0,
143 locale
=> 'C', # locale set to 'C' to ensure we'll have english strings
146 add1
=> 1, add2
=> 1, add3
=> 0,
147 every1
=> 1, every2
=> 4, every3
=> 0,
148 whenmorethan1
=> 4, whenmorethan2
=> 12, whenmorethan3
=> 0,
149 setto1
=> 1, setto2
=> 1, setto3
=> 0,
150 numberingmethod
=> 'Y: {Y}, X: {X}',
156 $seq = _next_seq
($subscription, $pattern);
157 is
($seq, 'Y: 1, X: 2');
158 $seq = _next_seq
($subscription, $pattern);
159 is
($seq, 'Y: 1, X: 3');
160 $seq = _next_seq
($subscription, $pattern);
161 is
($seq, 'Y: 1, X: 4');
162 $seq = _next_seq
($subscription, $pattern);
163 is
($seq, 'Y: 2, X: 1');
164 $seq = _next_seq
($subscription, $pattern);
165 is
($seq, 'Y: 2, X: 2');
168 $seq = _next_seq
($subscription, $pattern);
170 $seq = _next_seq
($subscription, $pattern);
171 is
($seq, 'Y: 12, X: 2');
172 $seq = _next_seq
($subscription, $pattern);
173 is
($seq, 'Y: 12, X: 3');
174 $seq = _next_seq
($subscription, $pattern);
175 is
($seq, 'Y: 12, X: 4');
176 $seq = _next_seq
($subscription, $pattern);
177 is
($seq, 'Y: 1, X: 1');
179 # TEST CASE 6 - 3 variables, from 1 to 12, from 1 to 8, and from 1 to 4
181 lastvalue1
=> 1, lastvalue2
=> 1, lastvalue3
=> 1,
182 innerloop1
=> 0, innerloop2
=> 0, innerloop3
=> 0,
185 locale
=> 'C', # locale set to 'C' to ensure we'll have english strings
188 add1
=> 1, add2
=> 1, add3
=> 1,
189 every1
=> 1, every2
=> 4, every3
=> 32,
190 whenmorethan1
=> 4, whenmorethan2
=> 8, whenmorethan3
=> 12,
191 setto1
=> 1, setto2
=> 1, setto3
=> 1,
192 numberingmethod
=> 'Z: {Z}, Y: {Y}, X: {X}',
198 $seq = _next_seq
($subscription, $pattern);
199 is
($seq, 'Z: 1, Y: 1, X: 2');
200 $seq = _next_seq
($subscription, $pattern);
201 is
($seq, 'Z: 1, Y: 1, X: 3');
202 $seq = _next_seq
($subscription, $pattern);
203 is
($seq, 'Z: 1, Y: 1, X: 4');
204 $seq = _next_seq
($subscription, $pattern);
205 is
($seq, 'Z: 1, Y: 2, X: 1');
207 $seq = _next_seq
($subscription, $pattern);
209 $seq = _next_seq
($subscription, $pattern);
210 is
($seq, 'Z: 1, Y: 8, X: 2');
211 $seq = _next_seq
($subscription, $pattern);
212 is
($seq, 'Z: 1, Y: 8, X: 3');
213 $seq = _next_seq
($subscription, $pattern);
214 is
($seq, 'Z: 1, Y: 8, X: 4');
215 $seq = _next_seq
($subscription, $pattern);
216 is
($seq, 'Z: 2, Y: 1, X: 1');
218 $seq = _next_seq
($subscription, $pattern);
220 $seq = _next_seq
($subscription, $pattern);
221 is
($seq, 'Z: 12, Y: 8, X: 4');
222 $seq = _next_seq
($subscription, $pattern);
223 is
($seq, 'Z: 1, Y: 1, X: 1');
227 my ($subscription, $pattern) = @_;
229 ($seq, $subscription->{lastvalue1
}, $subscription->{lastvalue2
},
230 $subscription->{lastvalue3
}, $subscription->{innerloop1
},
231 $subscription->{innerloop2
}, $subscription->{innerloop3
}) =
232 GetNextSeq
($subscription, $pattern);