File: swish.t

package info (click to toggle)
libcql-parser-perl 1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid
  • size: 324 kB
  • sloc: perl: 2,388; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,390 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use strict;
use warnings;
use Test::More qw( no_plan );
use Test::Exception;

use_ok( 'CQL::Parser' );
my $parser = CQL::Parser->new();

my $node = $parser->parse( "origami" );
is( $node->toSwish(), 'origami', 'simple word search' );

$node = $parser->parse( "lexic*" );
is( $node->toSwish(), "lexic*", "right hand truncation" );

$node = $parser->parse( qq("library of congress") );
is( $node->toSwish(), qq("library of congress"), "phrase search" );

$node = $parser->parse( qq(librarians and "information scientists") );
is( $node->toSwish(), qq(librarians and "information scientists"), 
    'boolean intersection' );

$node = $parser->parse( qq(origami or "paper folding") );
is( $node->toSwish(), qq(origami or "paper folding"), 'boolean union' );

$node = $parser->parse( qq(Thanksgiving not Christmas) );
is( $node->toSwish(), qq(Thanksgiving not Christmas), 'boolean negation' );

$node = $parser->parse( qq(dc.creator="Thomas Jefferson") );
is( $node->toSwish(), qq(dc.creator = "Thomas Jefferson"), 'field searching' );

$node = $parser->parse( qq(("paper folding" or origami) and japanese) );
is( $node->toSwish(), qq(("paper folding" or origami) and japanese), 
    'nesting with parens' );

$node = $parser->parse( "title exact fish" );
throws_ok 
    { $node->toSwish() }
    qr/Swish doesn't support relations other than = and not/,
    'toSwish() fails on exact searches';