# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### We start with some black magic to print on failure. # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) BEGIN { $| = 1; print "1..5\n"; } END {print "not ok 1\n" unless $loaded;} use XML::Grove; use XML::Parser::PerlSAX; use XML::Grove::Builder; use XML::Grove::AsString; use XML::Grove::AsCanonXML; $loaded = 1; print "ok 1\n"; ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code): # TEST: grove building $grove_builder = XML::Grove::Builder->new; $p = new XML::Parser::PerlSAX Handler => $grove_builder; $g = $p->parse (<<'EOF'); ORD"> ]> The Old Testament ... The First Book of the Kings Commonly called The Third Book of the Kings ... Jezebel threatens Elijah And &Ahab; told &Jezebel; all that &Elijah; had done, and withal how he had slain all the prophets with the sword. Then &Jezebel; sent a messenger unto &Elijah;, saying, So let the gods do to me, and more also, if I make not thy life as the life of one of them by to morrow about this time. And when he saw that, he arose, and went for his life, and came to &Beersheba;, which belongeth to &Judah;, and left his servant there. &ParaMark; But he himself went a day's journey into the wilderness, and came and sat down under a juniper tree: and he requested for himself that he might die; and said, It is enough; now, O &God;, take away my life; for I am not better than my fathers. for himself, or for his life An angel ministers to him And as he lay and slept under a juniper tree, behold, then an angel touched him, and said unto him, Arise and eat. ... ... ... ... EOF print "ok 2\n"; # TEST: as_cannon_xml $expected = <<'EOF'; The Old Testament ... The First Book of the Kings Commonly called The Third Book of the Kings ... Jezebel threatens Elijah And Āʹhăb told Jĕzʹe-bĕl all that E˔-līʹjah had done, and withal how he had slain all the prophets with the sword. Then Jĕzʹe-bĕl sent a messenger unto E˔-līʹjah, saying, So let the gods do to me, and more also, if I make not thy life as the life of one of them by to morrow about this time. And when he saw that, he arose, and went for his life, and came to Bēʹer-shēʹbȧ, which belongeth to Jūʹdah, and left his servant there. ¶ But he himself went a day's journey into the wilderness, and came and sat down under a juniper tree: and he requested for himself that he might die; and said, It is enough; now, O LORD, take away my life; for I am not better than my fathers. for himself, or for his life An angel ministers to him And as he lay and slept under a juniper tree, behold, then an angel touched him, and said unto him, Arise and eat. ... ... ... ... EOF chop ($expected); $got = $g->as_canon_xml; print (($got eq $expected) ? "ok 3\n" : "not ok 3\n"); # TEST: as_string $expected = <<'EOF'; The Old Testament ... The First Book of the Kings Commonly called The Third Book of the Kings ... Jezebel threatens Elijah And Āʹhăb told Jĕzʹe-bĕl all that E˔-līʹjah had done, and withal how he had slain all the prophets with the sword. Then Jĕzʹe-bĕl sent a messenger unto E˔-līʹjah, saying, So let the gods do to me, and more also, if I make not thy life as the life of one of them by to morrow about this time. And when he saw that, he arose, and went for his life, and came to Bēʹer-shēʹbȧ, which belongeth to Jūʹdah, and left his servant there. ¶ But he himself went a day's journey into the wilderness, and came and sat down under a juniper tree: and he requested for himself that he might die; and said, It is enough; now, O LORD, take away my life; for I am not better than my fathers. for himself, or for his life An angel ministers to him And as he lay and slept under a juniper tree, behold, then an angel touched him, and said unto him, Arise and eat. ... ... ... ... EOF $got = $g->as_string; print (($got eq $expected) ? "ok 4\n" : "not ok 4\n"); # TEST: attr_as_string $got = $g->root->{Contents}[1]{Contents}[4]->attr_as_string ('id'); print (($got eq 'OneKings') ? "ok 5\n" : "not ok 5\n");