[html-formfu] Error using insert_after

Charlie Garrison garrison at zeta.org.au
Mon Jul 13 18:43:57 GMT 2009


Good morning,

On 14/07/09 at 1:54 AM +1000, Charlie Garrison 
<garrison at zeta.org.au> wrote:

>I'm getting an exception when using insert_after to move a 
>newly created element. I'm using the following code to 
>create/insert the new element.

And replying to my own post with failing test case. The problem 
was use of auto_fieldset. After changing it to 0 the problem 
goes away. I'll leave the fix to someone more knowledgeable with HTML::FF.

HTML-FormFu-0.05001$ diff -u t/form/insert_after.t.orig t/form/insert_after.t
--- t/form/insert_after.t.orig  2009-07-14 02:18:34.000000000 +1000
+++ t/form/insert_after.t   2009-07-14 04:37:29.000000000 +1000
@@ -1,7 +1,7 @@
  use strict;
  use warnings;

-use Test::More tests => 7;
+use Test::More tests => 11;

  use HTML::FormFu;

@@ -41,3 +41,28 @@
      ok( $elems->[0] == $e2 );
      ok( $elems->[1] == $e1 );
  }
+
+# use auto_fieldset
+
+{
+    my $form = HTML::FormFu->new;
+
+#  $form->auto_fieldset(0); # this passes all tests
+   $form->auto_fieldset(1); # and this fails with exception 
when using HTML-FormFu-0.05001
+
+    my $e1 = $form->element({ name => 'foo' });
+    my $e2 = $form->element({ name => 'bar' });
+    my $e3 = $form->element({ name => 'baz' });
+
+    $form->insert_after( $e3, $e1 );
+
+    my $elems = $form->get_elements;
+
+    is( scalar(@$elems), 3 );
+
+    ok( $elems->[0] == $e1 );  # foo
+    ok( $elems->[1] == $e3 );  # baz
+    ok( $elems->[2] == $e2 );  # bar
+}
+
+



Charlie

-- 
    Charlie Garrison  <garrison at zeta.org.au>
    PO Box 141, Windsor, NSW 2756, Australia

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
http://www.ietf.org/rfc/rfc1855.txt



More information about the HTML-FormFu mailing list