Skip Menu |

This queue is for tickets about the Plucene CPAN distribution.

Report information
The Basics
Id: 17372
Status: new
Priority: 0/
Queue: Plucene

People
Owner: Nobody in particular
Requestors: plucene [...] wormbytes.ca
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 1.24
Fixed in: (no value)



Subject: Fully tested all the static Document::Field constructors
Nowhere in the old test suite was the UnIndexed constructor used (at least not according the Devel::Cover's report.) This unit-test does create one object of each type (Keyword, Text, UnStored, and UnIndexed.)
Subject: 20060130-document-field.patch
# HG changeset patch # User Robert James Kaes <rjk@wormbytes.ca> # Node ID 70c89ccd908f6454382110bc7af7666bb678f14a # Parent de0e94fcab03762ba26d6041c704c1a926e1d098 [Unit-test] Fully tested all the static Document::Field constructors. Nowhere in the old test suite was the UnIndexed constructor used (at least not according the Devel::Cover's report.) This unit-test does create one object of each type (Keyword, Text, UnStored, and UnIndexed.) diff -r de0e94fcab03 -r 70c89ccd908f t/document_field.t --- /dev/null Thu Jan 1 00:00:00 1970 +0000 +++ b/t/document_field.t Thu Jan 26 14:35:03 2006 -0500 @@ -0,0 +1,59 @@ +#!/usr/bin/perl +# +# Unit test the Plucene::Document::Field object +# +# Author: Robert James Kaes <rjk@wormbytes.ca> +# + +use strict; +use warnings; + +use Test::More tests => 25; + +require_ok('Plucene::Document::Field'); + +# Holds the field type, and then the expected values of: +# is_stored, is_indexed, and is_tokenized +my @field_types = ( + [ 'Keyword', 1, 1, 0 ], + [ 'UnIndexed', 1, 0, 0 ], + [ 'Text', 1, 1, 1 ], + [ 'UnStored', 0, 1, 1 ], +); + +foreach my $field_type (@field_types) { + my ($type, $is_stored, $is_indexed, $is_tokenized) = @{ $field_type }; + + my $field_class = 'Plucene::Document::Field'; + my $sub_ref = make_document_field_object($field_class, $type); + + my $field = $sub_ref->( + $field_class, + lc($type . '_name'), # name + lc($type . '_string'), # string + ); + + # Now test the newly built field object + isa_ok($field, $field_class); + is($field->name, lc($type . '_name'), 'checking name'); + is($field->string, lc($type . '_string'), 'checking string'); + cmp_ok($field->is_stored, '==', $is_stored, 'checking is_stored'); + cmp_ok($field->is_indexed, '==', $is_indexed, 'checking is_indexed'); + cmp_ok($field->is_tokenized, '==', $is_tokenized, + 'checking is_tokenized'); +} + +exit; + + +sub make_document_field_object { + my ($field_class, $type) = @_; + + # Override strict refs so that + no strict 'refs'; + my $sub_ref = \&{ $field_class . '::' . $type }; + + return $sub_ref; +} + +# vim: filetype=perl