Changeset 2161 for libswish3/trunk/bindings/perl/t
- Timestamp:
- 09/20/08 01:05:54 (4 months ago)
- Files:
-
- libswish3/trunk/bindings/perl/t/06constants.t (modified) (1 diff)
- libswish3/trunk/bindings/perl/t/10tokenize.t (modified) (1 diff)
- libswish3/trunk/bindings/perl/t/15-analyzer.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libswish3/trunk/bindings/perl/t/06constants.t
r2019 r2161 5 5 is( SWISH_MIME, 'MIME', SWISH_MIME ); 6 6 is( SWISH_PROP, 'PropertyNames', SWISH_PROP ); 7 is( scalar(SWISH_ WORD_FIELDS), 6, 'SWISH_WORD_FIELDS' );7 is( scalar(SWISH_TOKEN_FIELDS), 6, 'SWISH_TOKEN_FIELDS' ); libswish3/trunk/bindings/perl/t/10tokenize.t
r2151 r2161 4 4 5 5 ok( my $s3 = SWISH::3->new, "new s3" ); 6 ok( my $ wlist= $s3->tokenize(6 ok( my $tokens = $s3->tokenize( 7 7 "now is the time, ain't it? or when else might it be!", 8 14, 5,'foo', 'bar'8 'foo', 'bar' 9 9 ), 10 10 "wordlist" 11 11 ); 12 12 13 ok( $ wlist->isa('SWISH::3::WordList'), 'isa wordlist' );13 ok( $tokens->isa('SWISH::3::TokenIterator'), 'isa TokenIterator' ); 14 14 15 while ( my $swishword = $wlist->next ) { 15 #$s3->describe($tokens); 16 16 17 my $word = $swishword->word; 17 while ( my $token = $tokens->next ) { 18 19 #$s3->describe($token); 20 21 my $word = $token->value; 18 22 if ( $word eq 'now' ) { 19 is( $ swishword->position, 6, "now position" );23 is( $token->pos, 1, "now position" ); 20 24 } 21 25 if ( $word eq 'time' ) { 22 is( $ swishword->position, 9, "time position" );26 is( $token->pos, 4, "time position" ); 23 27 } 24 28 if ( $word eq 'be' ) { 25 is( $ swishword->position, 17, "be position" );29 is( $token->pos, 12, "be position" ); 26 30 } 27 31 28 32 #diag( '=' x 60 ); 29 for my $w (SWISH_ WORD_FIELDS) {33 for my $w (SWISH_TOKEN_FIELDS) { 30 34 31 #diag( sprintf( "%15s: %s\n", $w, $ swishword->$w ) );35 #diag( sprintf( "%15s: %s\n", $w, $token->$w ) ); 32 36 33 37 } 34 38 } 35 39 36 #undef $analyzer;37 40 #undef $wlist; 38 41 #undef $s3; libswish3/trunk/bindings/perl/t/15-analyzer.t
r2151 r2161 1 use Test::More tests => 5;1 use Test::More tests => 3; 2 2 3 3 use SWISH::3; … … 7 7 #ok( my $analyzer = $s3->analyzer, "get analyzer" ); 8 8 9 eval { my $handler = $s3->analyzer->get_token_handler };10 11 ok( $@, "get token handler: $@" );12 13 9 like( 'foo', $s3->analyzer->get_regex, 'get regex' ); 14 15 ok( !$s3->analyzer->set_token_handler( sub { $_[0]->debug } ),16 "set token handler" );17 10 18 11 ok( $s3->tokenize('foo bar baz'), "tokenize" );
