summaryrefslogtreecommitdiff
path: root/t/namespace-magic-scalar-rt144415.t
blob: 27cf0f05aa2eb3a8e2af97e615e51eef34f9d137 (plain)
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
use strict;
use warnings;

use Test::More tests => 3;

use XML::LibXML;

sub test_one {
    local $Test::Builder::Level = $Test::Builder::Level + 1;

    my ($ns, $name) = @_;
    my $doc = XML::LibXML::Document->new;
    my $foo = $doc->createElement('foo');
    $foo->appendChild(
        # we need to access the aliased SV directly, assigning it to a
        # different variable hides the problem
        $doc->createElementNS( $$ns, 'bar' ),
    );

    return is(
        $foo->toString,
        qq[<foo><bar xmlns="$$ns"/></foo>],
        "$name: namespace should be in force",
    );
}

my $ns1 = \'urn:a';
my $ns2 = \substr($$ns1, 0);

# TEST
test_one $ns1, 'plain scalar';
# TEST
test_one $ns2, 'magic scalar';
# TEST
test_one \"$$ns2", 'copy of magic scalar';