File: 02ext.t

package info (click to toggle)
libxml-compile-perl 1.63-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,396 kB
  • sloc: perl: 11,558; makefile: 7
file content (77 lines) | stat: -rw-r--r-- 2,178 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env perl
# Check implementation of type extension administration

use warnings;
use strict;

use File::Spec;

use lib 'lib', 't';
use Test::More tests => 20;
use XML::Compile::Schema;
use XML::Compile::Util qw/pack_type/;
use TestTools;

my $s   = XML::Compile::Schema->new( <<_SCHEMA );
<schema targetNamespace="$TestNS"
        xmlns="$SchemaNS"
        xmlns:me="$TestNS">

<simpleType name="t1">
  <restriction base="int" />
</simpleType>

<simpleType name="t2">
  <restriction base="me:t1">
    <minInclusive value="10" />
  </restriction>
</simpleType>

<complexType name="t3">
  <simpleContent>
    <extension base="me:t2">
      <attribute name="a2_a" type="int" />
    </extension>
  </simpleContent>
</complexType>

</schema>
_SCHEMA

sub does_extend($$)
{   my ($f, $g) = @_;
    $f = pack_type $SchemaNS, $f if $f !~ m/^\{/;
    $g = pack_type $SchemaNS, $g if $g !~ m/^\{/;
    ok($s->doesExtend($f, $g), "$_[0] <- $_[1]");
}

sub does_not_extend($$)
{   my ($f, $g) = @_;
    $f = pack_type $SchemaNS, $f if $f !~ m/^\{/;
    $g = pack_type $SchemaNS, $g if $g !~ m/^\{/;
    ok(!$s->doesExtend($f, $g), "not $_[0] <- $_[1]");
}

does_extend     'anyType',       'anyType';
does_extend     'anySimpleType', 'anyType';
does_not_extend 'anyType',       'anySimpleType';

does_extend     'unsignedByte',  'unsignedShort';
does_extend     'unsignedByte',  'unsignedInt';
does_extend     'unsignedByte',  'unsignedLong';
does_extend     'unsignedByte',  'nonNegativeInteger';
does_extend     'unsignedByte',  'integer';
does_extend     'unsignedByte',  'decimal';
does_extend     'unsignedByte',  'anyAtomicType';
does_extend     'unsignedByte',  'anySimpleType';
does_extend     'unsignedByte',  'anyType';

does_extend	pack_type($TestNS,'t1'), pack_type($TestNS, 't1');
does_extend	pack_type($TestNS,'t1'), 'int';
does_extend	pack_type($TestNS,'t2'), 'int';
does_extend	pack_type($TestNS,'t2'), pack_type($TestNS, 't1');
does_extend	pack_type($TestNS,'t1'), 'anySimpleType';
does_extend	pack_type($TestNS,'t2'), 'anySimpleType';

does_extend	pack_type($TestNS,'t3'), pack_type($TestNS, 't2');
does_extend	pack_type($TestNS,'t3'), pack_type($TestNS, 't1');