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

Last change on this file since 92 was 89, checked in by peichman, 19 years ago

minor doc fixes
updated version number
set actual number of tests

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
[89]6## use Test::More qw(no_plan);
7use Test::More tests => 11;
8
[9]9BEGIN { use_ok('Text::FormBuilder'); };
10
11my $p = Text::FormBuilder->new;
12isa_ok($p, 'Text::FormBuilder', 'new parser');
[53]13isa_ok($p, 'Class::ParseText::Base', 'subclass of Class::Parsetext::Base');
14can_ok($p, qw(parse_file parse_array parse_text parse)); # inherited parse_* methods
15
[19]16isa_ok($p->parse_text('')->build->form, 'CGI::FormBuilder',  'generated CGI::FormBuilder object (build->form)');
17isa_ok($p->parse_text('')->form,        'CGI::FormBuilder',  'generated CGI::FormBuilder object (form)');
[9]18
[19]19$p = Text::FormBuilder->parse_text('');
20isa_ok($p, 'Text::FormBuilder', 'new parser (from parse_text as class method)');
21
22$p = Text::FormBuilder->parse(\'');
23isa_ok($p, 'Text::FormBuilder', 'new parser (from parse as class method)');
24
[42]25
26my $simple = <<END;
27name
28email
29phone
30END
31
32my $form = $p->parse(\$simple)->form;
33# we should have three fields
34is(keys %{ $form->fields }, 3, 'correct number of fields');
35
[88]36# create some additional parsers, to make sure we aren't sharing data
37my $p2 = Text::FormBuilder->parse_text($simple);
38is(keys %{ $p2->form->fields }, 3, 'correct number of fields from parse_text');
39
40my $p3 = Text::FormBuilder->parse_array(qw(code title semester instructor));
41is(keys %{ $p3->form->fields }, 4, 'correct number of fields from parse_array');
Note: See TracBrowser for help on using the repository browser.