2 |
|
|
3 |
use strict; |
use strict; |
4 |
|
|
5 |
use Test::More tests => 43; |
use Test::More tests => 56; |
6 |
use Test::Exception; |
use Test::Exception; |
7 |
use Cwd qw/abs_path/; |
use Cwd qw/abs_path/; |
8 |
use blib; |
use blib; |
171 |
), |
), |
172 |
'eq', 'lookup 1 i lookup 2', 'join lookup regex rec2'); |
'eq', 'lookup 1 i lookup 2', 'join lookup regex rec2'); |
173 |
|
|
174 |
|
# check join_with operations |
175 |
|
|
176 |
|
sub test_join_with_2 { |
177 |
|
my ($a,$b,$e) = @_; |
178 |
|
|
179 |
|
cmp_ok( |
180 |
|
join_with(" <1> ", |
181 |
|
rec('201',$a), |
182 |
|
rec('201',$b), |
183 |
|
), |
184 |
|
'eq', $e, "join_with $a <1> $b = $e"); |
185 |
|
} |
186 |
|
|
187 |
|
test_join_with_2('_','_',''); |
188 |
|
test_join_with_2('x','_','201x'); |
189 |
|
test_join_with_2('_','x','201x'); |
190 |
|
test_join_with_2('x','y','201x <1> 201y'); |
191 |
|
|
192 |
|
sub test_join_with_3 { |
193 |
|
my ($a,$b,$c,$e) = @_; |
194 |
|
|
195 |
|
cmp_ok( |
196 |
|
join_with(" <1> ", rec('201',$a), |
197 |
|
join_with(" <2> ", rec('201',$b), |
198 |
|
rec('201',$c), |
199 |
|
) |
200 |
|
), |
201 |
|
'eq', $e, "join_with $a <1> $b <2> $c = $e"); |
202 |
|
}; |
203 |
|
|
204 |
|
test_join_with_3('_','_','_',''); |
205 |
|
test_join_with_3('x','_','_','201x'); |
206 |
|
test_join_with_3('_','x','_','201x'); |
207 |
|
test_join_with_3('_','_','x','201x'); |
208 |
|
test_join_with_3('x','y','_','201x <1> 201y'); |
209 |
|
test_join_with_3('x','_','y','201x <1> 201y'); |
210 |
|
test_join_with_3('_','x','y','201x <2> 201y'); |
211 |
|
test_join_with_3('x','_','y','201x <1> 201y'); |
212 |
|
test_join_with_3('x','y','x','201x <1> 201y <2> 201x'); |
213 |
|
|
214 |
|
# test lookups |
215 |
|
|
216 |
set_lookup( $lookup2 ); |
set_lookup( $lookup2 ); |
217 |
|
|
218 |
is_deeply( \[ lookup( prefix( '00', rec('902') ) ) ], \[ 'lookup' ], 'lookup prefix' ); |
is_deeply( \[ lookup( prefix( '00', rec('902') ) ) ], \[ 'lookup' ], 'lookup prefix' ); |