1#!/usr/bin/perl -w
2use Test::More tests => 13;
3BEGIN {use_ok('Pod::WSDL::Type')}
4use strict;
5use warnings;
6
7my $attrData;
8{
9local $/ = undef;
10$attrData = <DATA>;
11}
12
13eval {
14	my $a1 = new Pod::WSDL::Type();
15};
16
17ok(defined $@, 'new dies, if it does not get a name parameter');
18
19my $a1 = new Pod::WSDL::Type(name => 'my::foo', array => 1, descr => 'blah ...', pod => 'blah blah ...', pod => $attrData);
20
21ok ($a1->name eq 'my::foo', 'Red name argument correctly');
22ok ($a1->wsdlName eq 'MyFoo', 'Made wsdl name correctly');
23ok ($a1->array == 1, 'Red array argument correctly');
24ok ($a1->descr eq 'blah ...', 'Red descr argument correctly');
25ok (@{$a1->attrs} == 6, 'Seem to parse pod correctly');
26ok (($a1->attrs)->[0]->name eq '_ID', '... yes');
27ok (($a1->attrs)->[0]->type eq 'string', '... yes');
28ok (($a1->attrs)->[3]->descr eq 'Additional information', '... indeed');
29
30$a1 = new Pod::WSDL::Type(name => 'My::foo');
31
32ok ($a1->array == 0, 'Default for array works');
33ok ($a1->descr eq '', 'Handling lack of description works');
34
35eval {
36	$a1->name('bar');
37};
38
39{
40	no warnings;
41	ok($@ == undef, 'Renaming type is forbidden');
42}
43
44__DATA__
45	_ATTR _ID       $string             Word's ID
46	_ATTR _citation $string     _NEEDED Word's citation form
47	_ATTR _grammar  $string             Grammatical information
48	_ATTR _addInfo  $string             Additional information
49	_ATTR _language $string     _NEEDED Word's language as 2-letter ISO code
50	_ATTR _user     $Voko::User _NEEDED Word's owner
51