1#!/usr/bin/perl -w 2use Test::More tests => 14; 3BEGIN {use_ok('Pod::WSDL::Attr')} 4use strict; 5use warnings; 6 7eval { 8 my $a1 = new Pod::WSDL::Attr(); 9}; 10 11ok(defined $@, 'new dies, if it does not get a string'); 12 13eval { 14 my $a1 = new Pod::WSDL::Attr('myAttr $string _NEEDED blah blah ...'); 15}; 16 17ok(defined $@, 'new dies, if it does not get a string beginning with _ATTR'); 18 19eval { 20 my $a1 = new Pod::WSDL::Attr('_ATTR myAttr string _NEEDED blah blah ...'); 21}; 22 23ok(defined $@, 'new dies, if array/scalar type is not specified'); 24 25my $a1 = new Pod::WSDL::Attr('_ATTR myAttr $string _NEEDED blah blah ...'); 26 27ok($a1->name eq 'myAttr', 'Read name correctly from input'); 28ok($a1->type eq 'string', 'Read type correctly from input'); 29ok($a1->array == 0, 'Read scalar type correctly from input'); 30ok($a1->descr eq 'blah blah ...', 'Read descr correctly from input'); 31no warnings; 32ok($a1->nillable == undef, 'Read _NEEDED correctly from input'); 33use warnings; 34 35$a1 = new Pod::WSDL::Attr(' _ATTR myAttr $string _NEEDED blah blah ...'); 36ok($a1->name eq 'myAttr', 'Handles whitespace before _ATTR correctly.'); 37 38$a1 = new Pod::WSDL::Attr('_ATTR myAttr @string _NEEDED blah blah ...'); 39ok($a1->array == 1, 'Read array type correctly from input'); 40 41$a1 = new Pod::WSDL::Attr('_ATTR myAttr @string blah blah etc ...'); 42ok($a1->nillable eq 'true' && $a1->descr eq 'blah blah etc ...', 'Read descr correctly from input without needed'); 43 44$a1 = new Pod::WSDL::Attr('_ATTR myAttr @string _NEEDED'); 45ok($a1->descr eq '', 'No description is handled correctly'); 46 47eval { 48 $a1->name('foo'); 49}; 50 51{ 52 no warnings; 53 ok($@ == undef, 'Renaming attr is forbidden.'); 54} 55