The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
#!perl
use strict;
use Test::More tests => 7;
use File::Spec;

BEGIN
{
    use_ok("Tie::Senna");
}

my $index_name = 'test.db';
my $path       = File::Spec->catfile('t', $index_name);

while (<$path.*>) {
    unlink $_;
}

my $index = Senna::Index->create($path);
my $c;

my %hash;
my %storage;
tie(%hash, 'Tie::Senna', index => $index, storage => \%storage);

isa_ok(tied(%hash), 'Tie::Senna');

$hash{"ÆüËܸ죱"} = "ÆüËܸ줤¤ì¤Á¤ã¤¦¤¾";
$hash{"ÆüËܸ죲"} = "ÆüËܸ줤¤ì¤Á¤ã¤Ã¤¿¤¾¡Á";

my $tied = tied(%hash);
ok($tied);

$c = $tied->search("ÆüËܸì");
isa_ok($c, 'Senna::Cursor');
is($c->hits, 2);

foreach my $r ($tied->search("ÆüËܸì")) {
    ok(exists $hash{$r->key});
}

$index->remove;

1;