Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: cc45ffd34d
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 90 lines (73 sloc) 1.631 kb
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
#! /usr/local/bin/parrot
# Copyright (C) 2009, Parrot Foundation.

=head1 Entities

=head2 Synopsis

% parrot t/30-entity.t

=cut

.sub 'main' :main
    load_bytecode 'xml.pir'

    .include 'test_more.pir'

    plan(5)

    test_prefined_entity()
    test_character_reference_dec()
    test_character_reference_hex()
    test_internal_entity()
    test_in_attribute()
.end

.sub 'test_prefined_entity'
     $S1 = <<'XML'
<elt>2 &gt; 1</elt>
XML
     $S0 = 'xml_to_xml'($S1)
     is($S0, <<'OUT', 'prefined entity')
<elt>2 &gt; 1</elt>
OUT
.end

.sub 'test_character_reference_dec'
     $S1 = <<'XML'
<elt> &#65; </elt>
XML
     $S0 = 'xml_to_xml'($S1)
     is($S0, <<'OUT', 'character reference (dec)')
<elt> A </elt>
OUT
.end

.sub 'test_character_reference_hex'
     $S1 = <<'XML'
<elt> &#x41; </elt>
XML
     $S0 = 'xml_to_xml'($S1)
     is($S0, <<'OUT', 'character reference (hex)')
<elt> A </elt>
OUT
.end

.sub 'test_internal_entity'
     $S1 = <<'XML'
<?xml version='1.0'?><!DOCTYPE status [
    <!ENTITY Pub-Status "This is a pre-release of the specification">
] >
<status>&Pub-Status;</status>
XML
     $S0 = 'xml_to_xml'($S1)
     is($S0, <<'OUT', 'internal entity')
<?xml version="1.0"?>
<!DOCTYPE status [
  <!ENTITY Pub-Status "This is a pre-release of the specification">
]>
<status>&Pub-Status;</status>
OUT
.end

.sub 'test_in_attribute'
     $S1 = <<'XML'
<elt a="&#x31; &gt; &#48;"> &lt; </elt>
XML
     $S0 = 'xml_to_xml'($S1)
     is($S0, <<'OUT', 'in attribute')
<elt a="1 &gt; 0"> &lt; </elt>
OUT
.end


# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:

Something went wrong with that request. Please try again.