From d71fa8e4f5d31b1e0404acfedc3e2036d633bd05 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 the "float" step): 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 6. Sponsored-by: The National Library of Finland --- t/db_dependent/TestBuilder.t | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/TestBuilder.t b/t/db_dependent/TestBuilder.t index ddfd7e7a10..aa21b801e1 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 => 6; # Test the length of a returned character field my $bookseller = $builder->build({ source => 'Aqbookseller' }); @@ -101,6 +101,17 @@ 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." ); + }; -- 2.17.1