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
=> 1, add3
=> 0,
47 every1
=> 1, every2
=> 1, every3
=> 0,
48 whenmorethan1
=> 7, whenmorethan2
=> 7, whenmorethan3
=> 0,
49 setto1
=> 1, setto2
=> 1, setto3
=> 0,
50 numberingmethod
=> 'dayname: {X} | dayabrv: {Y}',
51 numbering1
=> 'dayname',
52 numbering2
=> 'dayabrv',
56 $seq = _next_seq
($subscription, $pattern);
57 is
($seq, 'dayname: Tuesday | dayabrv: Tue');
58 $seq = _next_seq
($subscription, $pattern);
59 is
($seq, 'dayname: Wednesday | dayabrv: Wed');
60 $seq = _next_seq
($subscription, $pattern);
61 is
($seq, 'dayname: Thursday | dayabrv: Thu');
62 $seq = _next_seq
($subscription, $pattern);
63 is
($seq, 'dayname: Friday | dayabrv: Fri');
64 $seq = _next_seq
($subscription, $pattern);
65 is
($seq, 'dayname: Saturday | dayabrv: Sat');
66 $seq = _next_seq
($subscription, $pattern);
67 is
($seq, 'dayname: Sunday | dayabrv: Sun');
68 $seq = _next_seq
($subscription, $pattern);
69 is
($seq, 'dayname: Monday | dayabrv: Mon');
71 # TEST CASE 3 - 1 variable, use 'monthname' numbering, from 0 to 11 by step of 2
73 lastvalue1
=> 0, lastvalue2
=> 0, lastvalue3
=> 0,
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
=> 2, add3
=> 0,
81 every1
=> 1, every2
=> 1, every3
=> 0,
82 whenmorethan1
=> 11, whenmorethan2
=> 11, whenmorethan3
=> 0,
83 setto1
=> 0, setto2
=> 0, setto3
=> 0,
84 numberingmethod
=> 'monthname: {X} | monthabrv: {Y}',
85 numbering1
=> 'monthname',
86 numbering2
=> 'monthabrv',
90 $seq = _next_seq
($subscription, $pattern);
91 is
($seq, 'monthname: March | monthabrv: Mar');
92 $seq = _next_seq
($subscription, $pattern);
93 is
($seq, 'monthname: May | monthabrv: May');
94 $seq = _next_seq
($subscription, $pattern);
95 is
($seq, 'monthname: July | monthabrv: Jul');
96 $seq = _next_seq
($subscription, $pattern);
97 is
($seq, 'monthname: September | monthabrv: Sep');
98 $seq = _next_seq
($subscription, $pattern);
99 is
($seq, 'monthname: November | monthabrv: Nov');
100 $seq = _next_seq
($subscription, $pattern);
101 is
($seq, 'monthname: January | monthabrv: Jan');
102 $seq = _next_seq
($subscription, $pattern);
103 is
($seq, 'monthname: March | monthabrv: Mar');
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
=> 0, lastvalue3
=> 0,
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
=> 1, add3
=> 0,
117 every1
=> 1, every2
=> 1, every3
=> 0,
118 whenmorethan1
=> 3, whenmorethan2
=> 3, whenmorethan3
=> 0,
119 setto1
=> 0, setto2
=> 0, setto3
=> 0,
120 numberingmethod
=> 'season: {X} | seasonabrv: {Y}',
121 numbering1
=> 'season',
122 numbering2
=> 'seasonabrv',
126 $seq = _next_seq
($subscription, $pattern);
127 is
($seq, 'season: Summer | seasonabrv: Sum');
128 $seq = _next_seq
($subscription, $pattern);
129 is
($seq, 'season: Fall | seasonabrv: Fal');
130 $seq = _next_seq
($subscription, $pattern);
131 is
($seq, 'season: Winter | seasonabrv: Win');
132 $seq = _next_seq
($subscription, $pattern);
133 is
($seq, 'season: Spring | seasonabrv: Spr');
134 $seq = _next_seq
($subscription, $pattern);
135 is
($seq, 'season: Summer | seasonabrv: Sum');
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);