perl-XML-LibXML / t / 62overload.t

# -*- cperl -*-

use strict;
use warnings;

use Test::More tests => 12;

use XML::LibXML;

my $e1 = XML::LibXML::Element->new('test1');
$e1->setAttribute('attr' => 'value1');

my $e2 = XML::LibXML::Element->new('test2');
$e2->setAttribute('attr' => 'value2');

my $h1 = \%{ $e1 };
my $h2 = \%{ $e2 };

isnt $h1,$h2, 'different references';

is $h1->{attr}, 'value1', 'affr for el 1';
is $h2->{attr}, 'value2', 'affr for el 2';

is "$e1", '<test1 attr="value1"/>', 'stringify for el 1';
is "$e2", '<test2 attr="value2"/>', 'stringify for el 2';

cmp_ok 0+$e1, '>', 1, 'num for el 1';
cmp_ok 0+$e2, '>', 1, 'num for el 2';

isnt 0+$e1,0+$e2, 'num for e1 and e2 differs';

my $e3 = $e1;

ok $e3 eq $e1, 'eq';
ok $e3 == $e1, '==';

ok $e1 ne $e2, 'ne';
ok $e1 != $e2, '!=';
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.