From a1ac9a2e01ffca3fc11b992ba793ba19e4b0d841 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Thu, 4 Feb 2021 19:35:43 +0000 Subject: [PATCH] Bug 27630: Allow more TestBuilder decimal places than 2 To test: 1. prove t/db_dependent/TestBuilder.t 2. Observe success Sponsored-by: The National Library of Finland --- t/lib/TestBuilder.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm index 26de949fb3..162662433f 100644 --- a/t/lib/TestBuilder.pm +++ b/t/lib/TestBuilder.pm @@ -489,11 +489,14 @@ sub _gen_int { sub _gen_real { my ($self, $params) = @_; my $max = 10 ** 38; + my $decimals = 2; if( defined( $params->{info}->{size} ) ) { $max = 10 ** ($params->{info}->{size}->[0] - $params->{info}->{size}->[1]); + $decimals = $params->{info}->{size}->[1]; } + $max = 10 ** 5 if $max > 10 ** 5; - return sprintf("%.2f", rand($max-0.1)); + return sprintf('%.'.$decimals.'f', rand($max-0.1)); } sub _gen_date { -- 2.17.1