Subject: | math is wrong |
Hello John,
in version 0.01 bytes with numeric value 255 are never produced. I have
attached fixes for this bug and some other minor stuff. They apply
cleanly against 0.01 with the command
git apply *.patch
(The order of the patches here on RT is probably going to displayed
wrong, just read them according to the prefixed number.)
Subject: | 0004-lower-minimum-perl-version-as-per-perlver-tool.patch |
From 3fabc68641917e7c7503f7e210f6f71e3ed5b969 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Lars=20D=C9=AA=E1=B4=87=E1=B4=84=E1=B4=8B=E1=B4=8F=E1=B4=A1=20=E8=BF=AA=E6=8B=89=E6=96=AF?= <daxim@cpan.org>
Date: Thu, 28 May 2009 15:00:04 +0200
Subject: [PATCH 4/4] lower minimum perl version as per perlver tool
---
Makefile.PL | 4 ++--
lib/Bytes/Random.pm | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Makefile.PL b/Makefile.PL
index 7bd0fb5..57e9ccc 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -1,7 +1,7 @@
-use 5.010000;
+use 5.006000;
use inc::Module::Install;
name 'Bytes-Random';
all_from 'lib/Bytes/Random.pm';
-perl_version '5.010000';
+perl_version '5.006000';
test_requires 'Statistics::Basic' => 0;
WriteAll;
diff --git a/lib/Bytes/Random.pm b/lib/Bytes/Random.pm
index 0452ba8..d54b24c 100644
--- a/lib/Bytes/Random.pm
+++ b/lib/Bytes/Random.pm
@@ -1,7 +1,7 @@
package Bytes::Random;
-use 5.008000;
+use 5.006000;
use strict;
use warnings;
use bytes;
--
1.6.3
Subject: | 0002-pod-fix.patch |
From 4472132d60a639a6070c73980948b60d1328e698 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Lars=20D=C9=AA=E1=B4=87=E1=B4=84=E1=B4=8B=E1=B4=8F=E1=B4=A1=20=E8=BF=AA=E6=8B=89=E6=96=AF?= <daxim@cpan.org>
Date: Thu, 28 May 2009 15:00:02 +0200
Subject: [PATCH 2/4] pod fix
---
lib/Bytes/Random.pm | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/Bytes/Random.pm b/lib/Bytes/Random.pm
index 46ab13f..0452ba8 100644
--- a/lib/Bytes/Random.pm
+++ b/lib/Bytes/Random.pm
@@ -61,7 +61,7 @@ Returns a string containing as many random bytes as was requested.
=head1 AUTHOR
-John Drago, E<lt>jdrago_999@yahoo.com<gt>
+John Drago, E<lt>jdrago_999@yahoo.comE<gt>
=head1 COPYRIGHT AND LICENSE
--
1.6.3
Subject: | 0001-math-fix.patch |
From 2f989dc58fe84f1749e40a1ac194c8d6aa4ac1c7 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Lars=20D=C9=AA=E1=B4=87=E1=B4=84=E1=B4=8B=E1=B4=8F=E1=B4=A1=20=E8=BF=AA=E6=8B=89=E6=96=AF?= <daxim@cpan.org>
Date: Thu, 28 May 2009 15:00:01 +0200
Subject: [PATCH 1/4] math fix
---
lib/Bytes/Random.pm | 2 +-
t/Bytes-Random.t | 19 ++++++++++++++++++-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/lib/Bytes/Random.pm b/lib/Bytes/Random.pm
index 6ba7a9f..46ab13f 100644
--- a/lib/Bytes/Random.pm
+++ b/lib/Bytes/Random.pm
@@ -26,7 +26,7 @@ sub random_bytes
my @out = ( );
for( 1..$number )
{
- my $rand = int( rand() * 255 );
+ my $rand = int( rand() * 256 );
push @out, chr( $rand );
}# end for()
diff --git a/t/Bytes-Random.t b/t/Bytes-Random.t
index bdf1df2..aa969f8 100644
--- a/t/Bytes-Random.t
+++ b/t/Bytes-Random.t
@@ -5,7 +5,8 @@
# change 'tests => 1' to 'tests => last_test_to_print';
-use Test::More tests => 41;
+use Test::More tests => 41 + 0x100 + 1;
+use Statistics::Basic qw(stddev);
BEGIN { use_ok('Bytes::Random') };
#########################
@@ -22,3 +23,19 @@ for( 1..40 )
}# end for()
+{
+ my $amount = 1e6;
+ my %dispersion;
+ $dispersion{ord random_bytes(1)}++ for 1..$amount;
+ my @slots = 0..0xff;
+
+ for my $slot (@slots) {
+ ok exists $dispersion{$slot},
+ "could produce bytes of numeric value $slot";
+ }
+
+ my $s = stddev(map {defined $_ ? $_ : 0} @dispersion{@slots})->query;
+ ok 2 > log($s) / log(10),
+ "$amount values are roughly evenly distributed "
+ . "(standard deviation was $s, should be about 60)";
+}
--
1.6.3
Subject: | 0003-switch-to-Module-Install-now-able-to-declare-test-de.patch |
From be09ab95243973c39632a18ff92c6f31b37d1b87 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Lars=20D=C9=AA=E1=B4=87=E1=B4=84=E1=B4=8B=E1=B4=8F=E1=B4=A1=20=E8=BF=AA=E6=8B=89=E6=96=AF?= <daxim@cpan.org>
Date: Thu, 28 May 2009 15:00:03 +0200
Subject: [PATCH 3/4] switch to Module::Install, now able to declare test deps
---
META.yml | 19 -------------------
Makefile.PL | 17 ++++++-----------
2 files changed, 6 insertions(+), 30 deletions(-)
delete mode 100644 META.yml
diff --git a/META.yml b/META.yml
deleted file mode 100644
index d3abb3e..0000000
--- a/META.yml
+++ /dev/null
@@ -1,19 +0,0 @@
---- #YAML:1.0
-name: Bytes-Random
-version: 0.01
-abstract: Perl extension to generate random bytes.
-author:
- - John <john@>
-license: unknown
-distribution_type: module
-configure_requires:
- ExtUtils::MakeMaker: 0
-requires: {}
-no_index:
- directory:
- - t
- - inc
-generated_by: ExtUtils::MakeMaker version 6.48
-meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.4.html
- version: 1.4
diff --git a/Makefile.PL b/Makefile.PL
index 344c3fa..7bd0fb5 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -1,12 +1,7 @@
use 5.010000;
-use ExtUtils::MakeMaker;
-# See lib/ExtUtils/MakeMaker.pm for details of how to influence
-# the contents of the Makefile that is written.
-WriteMakefile(
- NAME => 'Bytes::Random',
- VERSION_FROM => 'lib/Bytes/Random.pm', # finds $VERSION
- PREREQ_PM => {}, # e.g., Module::Name => 1.1
- ($] >= 5.005 ? ## Add these new keywords supported since 5.005
- (ABSTRACT_FROM => 'lib/Bytes/Random.pm', # retrieve abstract from module
- AUTHOR => 'John <john@>') : ()),
-);
+use inc::Module::Install;
+name 'Bytes-Random';
+all_from 'lib/Bytes/Random.pm';
+perl_version '5.010000';
+test_requires 'Statistics::Basic' => 0;
+WriteAll;
--
1.6.3