lib/XML/Schema/Type/Union.pm

filter: Statementstmt 100% 33 / 33 Branchbran 87.5% 7 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 6 / 6 Podpod 50.0% 1 / 2 totaltotal 92.3% 48 / 52 CC 6 SCAR 11.0
CC
6
Cov
95%
validate_instance
5.0
init
2.0
BEGIN
1.0
CRAP 3.0
« lib/XML/Schema/Test.pm ↑ Summary lib/XML/Schema/Element.pm »
1 #============================================================= -*-perl-*-
2 #
3 # XML::Schema::Type::Union
4 #
5 # DESCRIPTION
6 # Module implementing the XML Schema union datatype.
7 #
8 # AUTHOR
9 # Andy Wardley <abw@kfs.org>
10 #
11 # COPYRIGHT
12 # Copyright (C) 2001 Canon Research Centre Europe Ltd.
13 # All Rights Reserved.
14 #
15 # This module is free software; you can redistribute it and/or
16 # modify it under the same terms as Perl itself.
17 #
18 # REVISION
19 # $Id: Union.pm,v 1.1.1.1 2001/08/29 14:30:17 abw Exp $
20 #
21 #========================================================================
22  
23 package XML::Schema::Type::Union;
24  
25 28 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 28 ▶use XML::Schema::Type::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 28 ▶use base qw( XML::Schema::Type::Simple );
Subroutine BEGIN: called CC=1 SCAR=0.0
28 28 ▶use vars qw( $VERSION $DEBUG $ERROR @MANDATORY );
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 28 $VERSION = sprintf("%d.%02d", q$Revision: 1.1.1.1 $ =~ /(\d+)\.(\d+)/);
31 28 ▶$DEBUG = 0 unless defined $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $XML::Schema::Type::Union::DEBUG 28 0 28
32 28 $ERROR = '';
33  
34 28 @MANDATORY = qw( memberTypes );
35  
36 2 ▶sub init {
Subroutine init: called CC=2 SCAR=6.9
Pod documented
37 2 my ($self, $config) = @_;
38 2 ▶ $self->SUPER::init($config)
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init($config) or return 1 1 2
39 || return;
40 1 $self->{ _VARIETY } = 'union';
41 1 return $self;
42 }
43  
44 7 ▶sub validate_instance {
Subroutine validate_instance: called CC=5 SCAR=16.1
Pod undocumented
45 7 my ($self, $infoset) = @_;
46  
47 7 ▶ $self->SUPER::validate_instance($infoset)
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::validate_instance($infoset) or return 6 1 7
48 || return;
49  
50 6 my $value = $infoset->{ text };
51 6 my ($newval, @errors);
52  
53 my $members = $self->{ memberTypes }
54 6 ▶ || return $self->error('union has no memberTypes');
Condition50%1/2
$self->{'memberTypes'} || (return $self->error('union has no memberTypes'))
l!l
60
MC/DC0%0/1
$self->{'memberTypes'} || (return $self->error('union has no memberTypes'))
$self->{'memberTypes'}
Truth table50%1/2
A
A= $self->{'memberTypes'}
Aresult
11
00
55  
56 6 foreach my $member (@$members) {
57 14 $newval = $member->instance($value);
58 14 ▶ if ($newval) {
Branch: 1 branch
BranchTrueFalseTotal
if ($newval) 4 10 14
59 4 $infoset->{ value } = $newval;
60 4 return 1;
61 }
62 10 push(@errors, $member->name() . ': ' . $member->error());
63 }
64 2 return $self->error("invalid union: ", join(', ', @errors));
65 }
66  
67 28 1;
68  
69 __END__
« lib/XML/Schema/Test.pm ↑ Summary lib/XML/Schema/Element.pm »