Skip Menu |

This queue is for tickets about the WWW-HtmlUnit CPAN distribution.

Report information
The Basics
Id: 88055
Status: open
Priority: 0/
Queue: WWW-HtmlUnit

People
Owner: Nobody in particular
Requestors: james2vegas [...] aim.com
vijay2 [...] cox.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.21
Fixed in: (no value)



Subject: t/02_hello_sweet.t fails on ArrayList auto-convert
t/02_hello_sweet.t ... 1/3 Not an ARRAY reference at t/02_hello_sweet.t line 18, <GEN8> line 28.
Show quoted text
# Looks like you planned 3 tests but ran 1.
# Looks like your test exited with 255 just after 1.

The code:

Show quoted text
# Let's try out the ArrayList auto-convert
my $h1_tags = $agent->getElementsByTagName('h1');
my @x = @{ $h1_tags };

fails
On 2013-08-23 08:30:59, JWRIGHT wrote: Show quoted text
> t/02_hello_sweet.t ... 1/3 Not an ARRAY reference at t/02_hello_sweet.t line > 18, <GEN8> line 28. > # Looks like you planned 3 tests but ran 1. > # Looks like your test exited with 255 just after 1. > > The code: > > # Let's try out the ArrayList auto-convert > my $h1_tags = $agent->getElementsByTagName('h1'); > my @x = @{ $h1_tags }; > > fails
I see also this test failure, but not in all my perl installations. For example, an unthreaded perl 5.23.6 shows this failure, but a threaded one does not. Also there's no failure with a unthreaded 5.23.5.
Subject: Fix for Bug rt.cpan.org #88055
Date: Thu, 6 Apr 2017 22:30:09 -0700
To: bug-WWW-HtmlUnit [...] rt.cpan.org
From: Vijay Anand <vijay2 [...] cox.net>
The following replacement code fixes this bug: "Not an ARRAY reference at t/02_hello_sweet.t line 18, <GEN8> line 2" Replace the contents of t/02_hello_sweet.t with: ----------------------------- #!/usr/bin/perl use strict; use WWW::HtmlUnit::Sweet; use Test::More tests => 3; my $agent = WWW::HtmlUnit::Sweet->new( url => 'file:t/02_hello_sweet.html' ); my $result = $agent->asXml; like $result, qr/<h1>\s*Hello!\s*<\/h1>/, 'Found printed Hello'; # Let's try out the ArrayList auto-convert my $h1_tags = $agent->getElementsByTagName('h1'); my $count_tags = $h1_tags->getLength(); is $count_tags, 1, 'Found one thing in the h1 tag list'; isa_ok $h1_tags->item(0), 'WWW::HtmlUnit::com::gargoylesoftware::htmlunit::html::HtmlHeading1';