6 |
sub ok ($;$); |
sub ok ($;$); |
7 |
my $e = new Message::Markup::XML (type => '#element', local_name => 'test', |
my $e = new Message::Markup::XML (type => '#element', local_name => 'test', |
8 |
namespace_uri => 'http://something.test/'); |
namespace_uri => 'http://something.test/'); |
9 |
|
use Carp q(verbose); |
10 |
my @reg_p2n = ( |
my @reg_p2n = ( |
11 |
{ |
{ |
12 |
prefix => q(test1), |
prefix => q(test1), |
196 |
}, |
}, |
197 |
{ |
{ |
198 |
qname => q":bar", |
qname => q":bar", |
199 |
|
join_qname => q"bar", |
200 |
prefix => q"", |
prefix => q"", |
201 |
lname => q"bar", |
lname => q"bar", |
202 |
result => 0, |
result => 0, |
203 |
|
join_result => 1, |
204 |
opt => {check_qname => 1, check_prefix => 1, |
opt => {check_qname => 1, check_prefix => 1, |
205 |
check_local_name => 1}, |
check_local_name => 1}, |
206 |
}, |
}, |
353 |
+ scalar (@qname) * 2 |
+ scalar (@qname) * 2 |
354 |
+ scalar (@gen_pfx) * 2 |
+ scalar (@gen_pfx) * 2 |
355 |
+ scalar (@expand) * 2); |
+ scalar (@expand) * 2); |
356 |
|
eval q{ |
357 |
|
sub ok ($;$) { |
358 |
|
my ($cond, $desc) = @_; |
359 |
|
if ($cond) { |
360 |
|
Test::Simple::ok (1); |
361 |
|
} else { |
362 |
|
Test::Simple::ok (0, $desc); |
363 |
|
} |
364 |
|
}}; |
365 |
|
|
366 |
for (@reg_p2n) { |
for (@reg_p2n) { |
367 |
my $chk = Message::Markup::XML::QName::register_prefix_to_name |
my $chk = Message::Markup::XML::QName::register_prefix_to_name |
368 |
($e, $_->{prefix} => $_->{name}, %{$_->{opt}||{}}); |
($e, $_->{prefix} => $_->{name}, %{$_->{opt}||{}}); |
369 |
ok ($chk->{success} == $_->{result}, $chk->{reason}); |
ok ($chk->{success} == $_->{result}, 'Register pfx->URI: '.$chk->{reason}); |
370 |
} |
} |
371 |
|
|
372 |
for (@get_p2n) { |
for (@get_p2n) { |
393 |
if ($_->{result}) { |
if ($_->{result}) { |
394 |
ok $chk->{prefix}.':'.($chk->{local_name_star} ? '*' : $chk->{local_name}) |
ok $chk->{prefix}.':'.($chk->{local_name_star} ? '*' : $chk->{local_name}) |
395 |
eq $_->{prefix} . ':' . $_->{lname}, |
eq $_->{prefix} . ':' . $_->{lname}, |
396 |
"$chk->{prefix}:$chk->{local_name}($chk->{local_name_star})"; |
"Split 1: $_->{qname} => $chk->{prefix}:$chk->{local_name}($chk->{local_name_star})"; |
397 |
} else { |
} else { |
398 |
ok $chk->{success} == $_->{result}, |
ok $chk->{success} == $_->{result}, |
399 |
"$chk->{prefix}:$chk->{local_name}($chk->{local_name_star})"; |
"Split 0: $_->{qname} => $chk->{prefix}:$chk->{local_name}($chk->{local_name_star})"; |
400 |
} |
} |
401 |
|
|
402 |
$chk = Message::Markup::XML::QName::join_qname |
$chk = Message::Markup::XML::QName::join_qname |
403 |
($_->{prefix}, $_->{lname}, %{$_->{opt}||{}}); |
($_->{prefix}, $_->{lname}, %{$_->{opt}||{}}); |
404 |
if ($_->{result}) { |
if ((defined $_->{join_result} and $_->{join_result}) or $_->{result}) { |
405 |
ok $chk->{qname} eq $_->{qname}, $chk->{qname}; |
ok $chk->{qname} eq ($_->{join_qname} || $_->{qname}), "Join 1: $_->{prefix}, $_->{lname} => $chk->{qname}"; |
406 |
} else { |
} else { |
407 |
ok $chk->{success} == $_->{result}, $chk->{qname}; |
ok $chk->{success} == ((defined $_->{join_result} and $_->{join_result}) or $_->{result}), |
408 |
|
"Join 0: $chk->{success}; $_->{prefix}, $_->{lname} => $chk->{qname}"; |
409 |
} |
} |
410 |
} |
} |
411 |
|
|
416 |
if ($pfx eq $_->{prefix}) { |
if ($pfx eq $_->{prefix}) { |
417 |
my $chk = Message::Markup::XML::QName::register_prefix_to_name |
my $chk = Message::Markup::XML::QName::register_prefix_to_name |
418 |
($e, $pfx => $_->{name}); |
($e, $pfx => $_->{name}); |
419 |
ok $chk->{success}, $chk->{reason}; |
ok $chk->{success}, 'Generate pfx: '.$chk->{reason}; |
420 |
} else { |
} else { |
421 |
ok $pfx eq $_->{prefix}, ":$pfx: (expected :$_->{prefix}:"; |
ok $pfx eq $_->{prefix}, "Generate pfx: :$pfx: (expected :$_->{prefix}:"; |
422 |
} |
} |
423 |
} |
} |
424 |
|
|
428 |
%{$_->{opt}||{}}, |
%{$_->{opt}||{}}, |
429 |
make_new_prefix => 1); |
make_new_prefix => 1); |
430 |
ok $chk->{success} && ($chk->{prefix} eq ($_->{n2p} || $_->{prefix})), |
ok $chk->{success} && ($chk->{prefix} eq ($_->{n2p} || $_->{prefix})), |
431 |
"$chk->{prefix} (@{[$_->{n2p} || $_->{prefix}]} is expected; $chk->{reason})"; |
"URI->Pfx: $chk->{prefix} (@{[$_->{n2p} || $_->{prefix}]} is expected; $chk->{reason})"; |
432 |
} |
} |
433 |
|
|
434 |
for (@expand) { |
for (@expand) { |
441 |
($e, $_->{qname}, %{$_->{opt}||{}}); |
($e, $_->{qname}, %{$_->{opt}||{}}); |
442 |
ok $chk->{success} && ($_->{xname}->[0] eq $chk->{name} |
ok $chk->{success} && ($_->{xname}->[0] eq $chk->{name} |
443 |
&& $_->{xname}->[1] eq $chk->{local_name}), |
&& $_->{xname}->[1] eq $chk->{local_name}), |
444 |
qq(<$chk->{name}> (should be <$_->{xname}->[0]>), "$chk->{local_name}" (should be "$_->{xname}->[1]") (prefix "$chk->{prefix}"; $chk->{reason})); |
qq(QName->expand: <$chk->{name}> (should be <$_->{xname}->[0]>), "$chk->{local_name}" (should be "$_->{xname}->[1]") (prefix "$chk->{prefix}"; $chk->{reason})); |
445 |
} |
} |
446 |
|
|
447 |
for (@expand) { |
for (@expand) { |
452 |
} |
} |
453 |
my $chk = Message::Markup::XML::QName::expanded_name_to_qname |
my $chk = Message::Markup::XML::QName::expanded_name_to_qname |
454 |
($e, $_->{xname}->[0], $_->{xname}->[1], %{$_->{opt}||{}}); |
($e, $_->{xname}->[0], $_->{xname}->[1], %{$_->{opt}||{}}); |
455 |
ok $chk->{success} && ($_->{qname} eq $chk->{qname}), $chk->{reason}; |
ok $chk->{success} && ($_->{qname} eq $chk->{qname}), 'Expand->QName: '.$chk->{reason}; |
456 |
} |
} |
457 |
|
|
458 |
print $e; |
print $e; |