source: text-formbuilder/trunk/t/Text-FormBuilder.t @ 63

Last change on this file since 63 was 53, checked in by peichman, 20 years ago

separated basic parser using code out into a separate Class::ParseText::Base base class; updated docs, manifest, and changelog

File size: 1.5 KB
RevLine 
[1]1# Before `make install' is performed this script should be runnable with
2# `make test'. After `make install' it should work as `perl Text-FormBuilder.t'
3
4#########################
5
6# change 'tests => 1' to 'tests => last_test_to_print';
7
[42]8use Test::More qw(no_plan); #tests => 6;
[9]9BEGIN { use_ok('Text::FormBuilder'); };
10
[1]11#########################
12
13# Insert your test code below, the Test::More module is use()ed here so read
14# its man page ( perldoc Test::More ) for help writing this test script.
15
[9]16my $p = Text::FormBuilder->new;
17isa_ok($p, 'Text::FormBuilder', 'new parser');
[53]18isa_ok($p, 'Class::ParseText::Base', 'subclass of Class::Parsetext::Base');
19can_ok($p, qw(parse_file parse_array parse_text parse)); # inherited parse_* methods
20
[19]21isa_ok($p->parse_text('')->build->form, 'CGI::FormBuilder',  'generated CGI::FormBuilder object (build->form)');
22isa_ok($p->parse_text('')->form,        'CGI::FormBuilder',  'generated CGI::FormBuilder object (form)');
[9]23
[19]24$p = Text::FormBuilder->parse_text('');
25isa_ok($p, 'Text::FormBuilder', 'new parser (from parse_text as class method)');
26
27$p = Text::FormBuilder->parse(\'');
28isa_ok($p, 'Text::FormBuilder', 'new parser (from parse as class method)');
29
[42]30
31my $simple = <<END;
32name
33email
34phone
35END
36
37my $form = $p->parse(\$simple)->form;
38# we should have three fields
39is(keys %{ $form->fields }, 3, 'correct number of fields');
40
[43]41## my $p2 = Text::FormBuilder->parse_array([qw(code title semester instructor)]);
42## is(keys %{ $p2->form->fields }, 4, 'correct number of fields from parse_array');
43## $p2->write;
Note: See TracBrowser for help on using the repository browser.