File Coverage

blib/lib/Gtk2/Ex/TreeModel/ImplBits.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             # Copyright 2010, 2011, 2012 Kevin Ryde
2              
3             # This file is part of Gtk2-Ex-WidgetBits.
4             #
5             # Gtk2-Ex-WidgetBits is free software; you can redistribute it and/or modify
6             # it under the terms of the GNU General Public License as published by the
7             # Free Software Foundation; either version 3, or (at your option) any later
8             # version.
9             #
10             # Gtk2-Ex-WidgetBits is distributed in the hope that it will be useful, but
11             # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12             # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13             # for more details.
14             #
15             # You should have received a copy of the GNU General Public License along
16             # with Gtk2-Ex-WidgetBits. If not, see .
17              
18              
19             package Gtk2::Ex::TreeModel::ImplBits;
20 2     2   1944 use 5.008;
  2         7  
  2         97  
21 2     2   11 use strict;
  2         4  
  2         70  
22 2     2   10 use warnings;
  2         3  
  2         58  
23 2     2   2187 use Gtk2;
  0            
  0            
24              
25             use Exporter;
26             our @ISA = ('Exporter');
27             our @EXPORT_OK = ('random_stamp');
28              
29             our $VERSION = 48;
30              
31             sub random_stamp {
32             my ($model) = @_;
33             if (my $stamp = $model->{'stamp'}) {
34             # 1 to 2^31-1, inclusive, and skipping existing $stamp value
35             my $new_stamp = 1 + int(rand(2**31 - 2));
36             $model->{'stamp'} = $new_stamp + ($new_stamp >= $stamp);
37             } else {
38             # 1 to 2^31-1, inclusive
39             $model->{'stamp'} = 1 + int(rand(2**31 - 1));
40             }
41             }
42              
43             1;
44             __END__