| 1 | package mainscip-perl cpan XML-Hash-XS 0.64 main/; |
| 2 | use strictscip-perl cpan XML-Hash-XS 0.64 strict/; |
| 3 | use warningsscip-perl cpan XML-Hash-XS 0.64 warnings/; |
| 4 | |
| 5 | use Test::Morescip-perl cpan XML-Hash-XS 0.64 Test/More/ tests => 15; |
| 6 | |
| 7 | use XML::Hash::XSscip-perl cpan XML-Hash-XS 0.64 XML/Hash/XS/ 'xml2hash'; |
| 8 | $XML::Hash::XS::keep_rootscip-perl cpan XML-Hash-XS 0.64 XML/Hash/XS/$keep_root. = 0; |
| 9 | |
| 10 | { |
| 11 | isscip-perl cpan XML-Hash-XS 0.64 main/is(). |
| 12 | xml2hashscip-perl cpan XML-Hash-XS 0.64 main/xml2hash().("<!DOCTYPE root><root>OK</root>"), |
| 13 | "OK", |
| 14 | 'simple', |
| 15 | ; |
| 16 | } |
| 17 | |
| 18 | { |
| 19 | isscip-perl cpan XML-Hash-XS 0.64 main/is(). |
| 20 | xml2hashscip-perl cpan XML-Hash-XS 0.64 main/xml2hash().("<!DOCTYPE\n\r\t root \n\r\t><root>OK</root>"), |
| 21 | "OK", |
| 22 | 'with extra spaces', |
| 23 | ; |
| 24 | } |
| 25 | |
| 26 | { |
| 27 | isscip-perl cpan XML-Hash-XS 0.64 main/is(). |
| 28 | xml2hashscip-perl cpan XML-Hash-XS 0.64 main/xml2hash().("<!-- comment --><!DOCTYPE root><!-- comment --><root>OK</root>"), |
| 29 | "OK", |
| 30 | 'with comments', |
| 31 | ; |
| 32 | } |
| 33 | |
| 34 | { |
| 35 | isscip-perl cpan XML-Hash-XS 0.64 main/is(). |
| 36 | xml2hashscip-perl cpan XML-Hash-XS 0.64 main/xml2hash().("<!DOCTYPE root SYSTEM \"dtd\"><root>OK</root>"), |
| 37 | "OK", |
| 38 | 'with external system DTD', |
| 39 | ; |
| 40 | } |
| 41 | |
| 42 | { |
| 43 | isscip-perl cpan XML-Hash-XS 0.64 main/is(). |
| 44 | xml2hashscip-perl cpan XML-Hash-XS 0.64 main/xml2hash().("<!DOCTYPE root SYSTEM 'dtd'><root>OK</root>"), |
| 45 | "OK", |
| 46 | 'with external system DTD', |
| 47 | ; |
| 48 | } |
| 49 | |
| 50 | { |
| 51 | isscip-perl cpan XML-Hash-XS 0.64 main/is(). |
| 52 | xml2hashscip-perl cpan XML-Hash-XS 0.64 main/xml2hash().('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"' . |
| 53 | ' "http://www.w3.org/TR/REC-html40/loose.dtd"><root>OK</root>'), |
| 54 | "OK", |
| 55 | 'with external public DTD', |
| 56 | ; |
| 57 | } |
| 58 | |
| 59 | { |
| 60 | isscip-perl cpan XML-Hash-XS 0.64 main/is(). |
| 61 | xml2hashscip-perl cpan XML-Hash-XS 0.64 main/xml2hash().(<<'XML'), |
| 62 | <!DOCTYPE root [ |
| 63 | <!ELEMENT document |
| 64 | (title*,subjectID,subjectname,prerequisite?, |
| 65 | classes,assessment,syllabus,textbooks*)> |
| 66 | <!ELEMENT prerequisite (subjectID,subjectname)> |
| 67 | <!ELEMENT textbooks (author,booktitle)> |
| 68 | <!ELEMENT title (#PCDATA)> |
| 69 | <!ELEMENT subjectID (#PCDATA)> |
| 70 | <!ELEMENT subjectname (#PCDATA)> |
| 71 | <!ELEMENT classes (#PCDATA)> |
| 72 | <!ELEMENT assessment (#PCDATA)> |
| 73 | <!ATTLIST assessment assessment_type (exam | assignment) #IMPLIED> |
| 74 | <!ELEMENT syllabus (#PCDATA)> |
| 75 | <!ELEMENT author (#PCDATA)> |
| 76 | <!ELEMENT booktitle (#PCDATA)> |
| 77 | ]> |
| 78 | <root>OK</root> |
| 79 | XML |
| 80 | "OK", |
| 81 | 'with internal subset', |
| 82 | ; |
| 83 | } |
| 84 | |
| 85 | { |
| 86 | eval { xml2hashscip-perl cpan XML-Hash-XS 0.64 main/xml2hash().("<!DOCTYPE><root>123</root>") }; |
| 87 | okscip-perl cpan XML-Hash-XS 0.64 main/ok().($@scip-perl cpan XML-Hash-XS 0.64 main/`$@`., 'missing root element type'); |
| 88 | } |
| 89 | |
| 90 | { |
| 91 | eval { xml2hashscip-perl cpan XML-Hash-XS 0.64 main/xml2hash().("<!DOCTYPE root><!DOCTYPE root><root>123</root>") }; |
| 92 | okscip-perl cpan XML-Hash-XS 0.64 main/ok().($@scip-perl cpan XML-Hash-XS 0.64 main/`$@`., 'duplicate doctype'); |
| 93 | } |
| 94 | |
| 95 | { |
| 96 | eval { xml2hashscip-perl cpan XML-Hash-XS 0.64 main/xml2hash().("<root><!DOCTYPE root></root>") }; |
| 97 | okscip-perl cpan XML-Hash-XS 0.64 main/ok().($@scip-perl cpan XML-Hash-XS 0.64 main/`$@`., 'misplaced doctype'); |
| 98 | } |
| 99 | |
| 100 | { |
| 101 | eval { xml2hashscip-perl cpan XML-Hash-XS 0.64 main/xml2hash().("<!DOCTYPE root SYSTEM><root>123</root>") }; |
| 102 | okscip-perl cpan XML-Hash-XS 0.64 main/ok().($@scip-perl cpan XML-Hash-XS 0.64 main/`$@`., 'wrong external system DTD'); |
| 103 | } |
| 104 | |
| 105 | { |
| 106 | eval { xml2hashscip-perl cpan XML-Hash-XS 0.64 main/xml2hash().('<!DOCTYPE root PUBLIC><root>123</root>') }; |
| 107 | okscip-perl cpan XML-Hash-XS 0.64 main/ok().($@scip-perl cpan XML-Hash-XS 0.64 main/`$@`., 'wrong external public DTD'); |
| 108 | } |
| 109 | |
| 110 | { |
| 111 | eval { xml2hashscip-perl cpan XML-Hash-XS 0.64 main/xml2hash().('<!DOCTYPE root PUBLIC "name"><root>123</root>') }; |
| 112 | okscip-perl cpan XML-Hash-XS 0.64 main/ok().($@scip-perl cpan XML-Hash-XS 0.64 main/`$@`., 'wrong external public DTD2'); |
| 113 | } |
| 114 | |
| 115 | { |
| 116 | eval { xml2hashscip-perl cpan XML-Hash-XS 0.64 main/xml2hash().('<!DOCTYPE root [><root>123</root>') }; |
| 117 | okscip-perl cpan XML-Hash-XS 0.64 main/ok().($@scip-perl cpan XML-Hash-XS 0.64 main/`$@`., 'wrong internal subset'); |
| 118 | } |
| 119 | |
| 120 | { |
| 121 | eval { xml2hashscip-perl cpan XML-Hash-XS 0.64 main/xml2hash().('<!DOCTYPE root []]><root>123</root>') }; |
| 122 | okscip-perl cpan XML-Hash-XS 0.64 main/ok().($@scip-perl cpan XML-Hash-XS 0.64 main/`$@`., 'wrong internal subset'); |
| 123 | } |