File: 55facet_dura.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 (55 lines) | stat: -rw-r--r-- 1,238 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/env perl
# test facets on duration, shares some with numeric facets

use warnings;
use strict;

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

use XML::Compile::Schema;
use XML::Compile::Tester;
use XML::Compile::Util qw/pack_type/;

use Test::More tests => 21;

set_compile_defaults
    elements_qualified => 'NONE';

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

<!-- Question by Anthony Yen, 2016-01-14 -->
<element name="test1">
  <simpleType>
    <restriction base="duration">
      <minInclusive value="P1970Y01M01D"/>
    </restriction>
  </simpleType>
</element>

</schema>
__SCHEMA__

ok(defined $schema);

set_compile_defaults
    include_namespaces    => 0
  , elements_qualified    => 'NONE'
  , use_default_namespace => 0;

# a bit more
test_rw($schema, test1 => '<test1>P1970Y02M01D</test1>'
  , 'P1970Y02M01D');

# a bit less
my $error = error_r($schema, test1 => '<test1>P1970Y</test1>');
is($error, "too small minInclusive duration P1970Y, min P1970Y01M01D at {http://test-types}test1#facet");

# exact
test_rw($schema, test1 => '<test1>P1970Y01M01D</test1>'
  , 'P1970Y01M01D');