From 616d20c651a59551f9d3a246b34af51f23bfc98c Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Thu, 4 Feb 2021 21:05:42 +0000 Subject: [PATCH] Bug 27630: Add test to prove different behavior with floats To test: 1. prove t/db_dependent/TestBuilder.t 2. It might or might not pass all tests - if it passes, run it again until you get the following error (always with either the "float" or "double" steps): ok 5 - decimal - Builder builds same precision as DBIx returns. not ok 6 - float - Builder builds same precision as DBIx returns. Failed test 'float - Builder builds same precision as DBIx returns.' at t/db_dependent/TestBuilder.t line 112. got: '51.7080' expected: '51.708' Looks like you failed 1 test of 7. Sponsored-by: The National Library of Finland --- t/db_dependent/TestBuilder.t | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/TestBuilder.t b/t/db_dependent/TestBuilder.t index ddfd7e7a10..7d4ea21b46 100755 --- a/t/db_dependent/TestBuilder.t +++ b/t/db_dependent/TestBuilder.t @@ -84,7 +84,7 @@ subtest 'Build all sources' => sub { subtest 'Test length of some generated fields' => sub { - plan tests => 4; + plan tests => 7; # Test the length of a returned character field my $bookseller = $builder->build({ source => 'Aqbookseller' }); @@ -101,6 +101,23 @@ subtest 'Test length of some generated fields' => sub { sprintf("%.6f", $accountline->{amountoutstanding}), "There can be more decimals when the column size allows it." ); + my $rs = $schema->source('Accountline')->resultset; + my $accountline_dbix = $rs->find($accountline->{accountlines_id}); + is( $accountline->{amountoutstanding}, $accountline_dbix->amountoutstanding, + "decimal - Builder builds same precision as DBIx returns." ); + + my $aqorder = $builder->build({ source => 'Aqorder' }); + $rs = $schema->source('Aqorder')->resultset; + my $aqorder_dbix = $rs->find($aqorder->{ordernumber}); + is( $aqorder->{discount}, $aqorder_dbix->discount, + "float - Builder builds same precision as DBIx returns." ); + + my $statistic = $builder->build({ source => 'Statistic' }); + $rs = $schema->source('Statistic')->resultset; + my $statistic_dbix = $rs->search({ datetime => $statistic->{datetime} })->next; + is( $statistic->{value}, $statistic_dbix->value, + "double precision - Builder builds same precision as DBIx returns." ); + }; -- 2.17.1