Bugzilla – Attachment 150280 Details for
Bug 24310
Use Text::Lorem instead of String::Random in Test::Builder
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24310: Use Text::Lorem instead of String::Random (new dependency)
Bug-24310-Use-TextLorem-instead-of-StringRandom-ne.patch (text/plain), 1.66 KB, created by
Jonathan Druart
on 2023-04-27 05:48:40 UTC
(
hide
)
Description:
Bug 24310: Use Text::Lorem instead of String::Random (new dependency)
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-04-27 05:48:40 UTC
Size:
1.66 KB
patch
obsolete
>From b244a74fe1a9c7d40a63f915f2fed401e46a693a Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sat, 21 Dec 2019 12:13:41 +0100 >Subject: [PATCH] Bug 24310: Use Text::Lorem instead of String::Random (new > dependency) > >--- > t/lib/TestBuilder.pm | 20 ++++---------------- > 1 file changed, 4 insertions(+), 16 deletions(-) > >diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm >index 7e70f29c9e4..c46ed4c7e02 100644 >--- a/t/lib/TestBuilder.pm >+++ b/t/lib/TestBuilder.pm >@@ -11,8 +11,8 @@ use Koha::DateUtils qw( dt_from_string ); > use Bytes::Random::Secure; > use Carp qw( carp ); > use Module::Load qw( load ); >-use String::Random; > use Array::Utils qw( array_minus ); >+use Text::Lorem; > > use constant { > SIZE_BARCODE => 20, # Not perfect but avoid to fetch the value when creating a new item >@@ -538,22 +538,10 @@ sub _gen_datetime { > > sub _gen_text { > my ($self, $params) = @_; >- # From perldoc String::Random >+ my $text = Text::Lorem->new(); >+ my $words = $text->words(int(rand(10))); > my $size = $params->{info}{size} // 10; >- $size -= alt_rand(0.5 * $size); >- my $regex = $size > 1 >- ? '[A-Za-z][A-Za-z0-9_]{'.($size-1).'}' >- : '[A-Za-z]'; >- my $random = String::Random->new( rand_gen => \&alt_rand ); >- # rand_gen is only supported from 0.27 onward >- return $random->randregex($regex); >-} >- >-sub alt_rand { #Alternative randomizer >- my ($max) = @_; >- my $random = Bytes::Random::Secure->new( NonBlocking => 1 ); >- my $r = $random->irand / 2**32; >- return int( $r * $max ); >+ return length($words) > $size ? substr( $words, 1, $size ) : $words; > } > > sub _gen_set_enum { >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24310
:
96647
|
96648
|
150279
| 150280