File: opt.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (42 lines) | stat: -rw-r--r-- 1,231 bytes parent folder | download | duplicates (2)
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
#!./perl -w
use strict;

use Test::More;
use Config;
use File::Temp 'tempdir';
use File::Spec;

BEGIN {
    plan(skip_all => "GDBM_File was not built")
	unless $Config{extensions} =~ /\bGDBM_File\b/;

    # https://rt.perl.org/Public/Bug/Display.html?id=117967
    plan(skip_all => "GDBM_File is flaky in $^O")
        if $^O =~ /darwin/;

    plan(tests => 9);
    use_ok('GDBM_File');
}

my $wd = tempdir(CLEANUP => 1);
my $dbname = File::Spec->catfile($wd, 'Op_dbmx');
my %h;
my $db = tie(%h, 'GDBM_File', $dbname, GDBM_WRCREAT, 0640);
isa_ok($db, 'GDBM_File');
SKIP: {
     my $name = eval { $db->dbname } or do {
         skip "gdbm_setopt GET calls not implemented", 7
             if $@ =~ /GDBM_File::dbname not implemented/;
     };
     is($db->dbname, $dbname, 'get dbname');
     is(eval { $db->dbname("a"); }, undef, 'dbname - bad usage');
     is($db->flags, GDBM_WRCREAT, 'get flags');
     is($db->sync_mode, 0, 'get sync_mode');
     is($db->sync_mode(1), 1, 'set sync_mode');
     is($db->sync_mode, 1, 'get sync_mode');
   SKIP: {
         my ($maj, $min) = GDBM_File->GDBM_version;
         skip "gdbm too old", 1 if $maj != 1 || $maj == 1 && $min < 9;
         isnt($db->mmapsize, 0, "get mmapsize");
     }
}