summaryrefslogtreecommitdiff
path: root/t/namespace-magic-scalar-rt144415.t
diff options
context:
space:
mode:
Diffstat (limited to 't/namespace-magic-scalar-rt144415.t')
-rwxr-xr-xt/namespace-magic-scalar-rt144415.t35
1 files changed, 35 insertions, 0 deletions
diff --git a/t/namespace-magic-scalar-rt144415.t b/t/namespace-magic-scalar-rt144415.t
new file mode 100755
index 0000000..27cf0f0
--- /dev/null
+++ b/t/namespace-magic-scalar-rt144415.t
@@ -0,0 +1,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';