File: 44stres.t

package info (click to toggle)
libxml-compile-perl 1.64-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,304 kB
  • sloc: perl: 11,616; makefile: 7
file content (109 lines) | stat: -rw-r--r-- 2,140 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env perl
# test simple type restriction

use warnings;
use strict;

use lib 'lib','t';
use TestTools;

use XML::Compile::Schema;
use XML::Compile::Tester;

use Test::More tests => 76;

set_compile_defaults
    elements_qualified => 'NONE';

my $schema   = 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>

<simpleType name="t3">
  <restriction base="me:t2">
    <maxInclusive value="20" />
  </restriction>
</simpleType>

<element name="test1" type="me:t1" />

<element name="test2" type="me:t2" />

<element name="test3" type="me:t3" />

</schema>
__SCHEMA__

ok(defined $schema);

#
# In range
#

test_rw($schema, "test1" => <<__XML, 12);
<test1>12</test1>
__XML

test_rw($schema, "test2" => <<__XML, 13);
<test2>13</test2>
__XML

test_rw($schema, "test3" => <<__XML, 14);
<test3>14</test3>
__XML

#
# too small
#

test_rw($schema, "test1" => <<__XML, 5);
<test1>5</test1>
__XML

my $error = error_r($schema, test2 => <<__XML);
<test2>6</test2>
__XML
is($error, 'too small inclusive 6, min 10 at {http://test-types}test2#facet');

$error = error_w($schema, test2 => 6);
is($error, "too small inclusive 6, min 10 at {http://test-types}test2#facet");

# inherited restriction
$error = error_r($schema, test3 => <<__XML);
<test3>6</test3>
__XML
is($error, 'too small inclusive 6, min 10 at {http://test-types}test3#facet');

$error = error_w($schema, test3 => 6);
is($error, "too small inclusive 6, min 10 at {http://test-types}test3#facet");

#
# too large
#

test_rw($schema, "test1" => <<__XML, 55);
<test1>55</test1>
__XML

test_rw($schema, "test2" => <<__XML, 56);
<test2>56</test2>
__XML

$error = error_r($schema, test3 => <<__XML);
<test3>57</test3>
__XML
is($error, 'too large inclusive 57, max 20 at {http://test-types}test3#facet');

$error = error_w($schema, test3 => 57);
is($error, "too large inclusive 57, max 20 at {http://test-types}test3#facet");