Bug #439
closedBug 27630 - TestBuilder real number precision to use column's size
Description
t::lib::TestBuilder::_gen_real() always returns 2 decimal places no matter the column's size definition.
TestBuilder.pm _gen_real()
printf("%.2f", rand($max-0.1));
Our database has decimal type columns with higher than 2 decimal places. This makes comparing structures with Test::More::is_deeply impossible when the other object is built by TestBuilder, and the other fetched from database, as seen here:
- Structures begin differing at:
- $got->[0]{amount} = '90203.710000'
- $expected->[0]{amount} = '90203.71'
Updated by Lari Taskula about 4 years ago
- Status changed from New to In Progress
- % Done changed from 0 to 100
Updated by Lari Taskula about 4 years ago
Reopening, found another issue with float.
Updated by Lari Taskula about 4 years ago
- Blocks Feature #421: Bug 20028 - Export all patron related personal data in one package added
Updated by Lari Taskula about 4 years ago
Created attachment 116342 [details] [review]
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
Updated by Lari Taskula about 4 years ago
- Status changed from In Progress to Rejected
- % Done changed from 50 to 100
Marking this as rejected. Using TestBuilder's build_object() is enough for now.