summaryrefslogtreecommitdiff
path: root/fml/lib/IO/t/sequence.pl
blob: 77fb7df4c3042e98d3212f4cbcf5f32140fa6196 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env perl
#-*- perl -*-
#
#  Copyright (C) 2004 Ken'ichi Fukamachi
#   All rights reserved. This program is free software; you can
#   redistribute it and/or modify it under the same terms as Perl itself.
#
# $FML: lock.pl,v 1.1 2004/04/10 07:40:02 fukachan Exp $
#

use strict;
use Carp;

my $debug = 0;
my $i     = 0;
my $file  = "/tmp/io.adapter.$$";
my $map   = "file:$file";
my %log   = ();
my %pid   = ();
my $fail  = 0;
my $reason = '';

### MAIN ###
print "${file}->sequence_increment() ... ";

use IO::Adapter;

for my $i (0 .. 5) {
    my $obj = new IO::Adapter $map;
    my $id  = $obj->sequence_increment();

    unless ($id == ($i + 1)) {
	$reason .= "wrong sequence returned";
	$reason .= "\t\n";
	$fail++;
    }

    if ($obj->error()) {
	$reason .= $obj->error();
	$reason .= "\t\n";
	$fail++;
    }
}

show_result();


#
# 2. replace
#
$fail   = 0;
$reason = '';

print "${file}->seqeunce_replace()   ... ";
my $obj = new IO::Adapter $map;
$obj->sequence_replace(10);
if ($obj->error()) {
    $reason .= $obj->error();
    $reason .= "\t\n";
    $fail++;
}

show_result();

exit 0;


sub show_result
{
    print $fail ? "fail\n" : "ok\n";
    if ($fail) {
	print "\t", $reason, "\n";
    }

    if ($debug) {
	my $obj = new IO::Adapter $map;
	$obj->open();
	print "debug = ", $obj->getline(), "\n";
    }
}