zatlas1 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all
I have a very old codebase (5.10.0) and moving to 5.38.2 (don't ask :)
I encountered incompatibilities as my t/test fails many times.
Suspected incompatibilities:
use Class::MethodMaker
Date::Manip
use Test::More.

How could I find the old documentation or description of potential incompatibilities
Thank You
ZA
  • Comment on Overcoming 5.10.0 vs 5.38.2 incompatibilities

Replies are listed 'Best First'.
Re: Overcoming 5.10.0 vs 5.38.2 incompatibilities
by SankoR (Prior) on Mar 11, 2024 at 20:01 UTC
    Going through all the different perldeltas or individual changelogs for each module over the last 16 years would still leave you with a lot of work to do so it's good you have tests. I strongly prefer tests that can expose incompatibilities between versions over the philosophical stance of a lot of Perl devs I've bumped into.

    Both are in the CORE as of 5.38.2, but it's probably still too early to replace Class::MethodMaker with the new perlclass syntax. Test2::V0 is stable and feature complete enough to replace Test::More though. You also listed Date::Manip which shouldn't be causing you too much trouble; it's still under active development and works as advertised under 5.38.x.

      I am aware that it is almost hopeless to sift through the perldelta files. I did send some code snippets and hope (really hope) that somebody may spot the issue or ask for the offending code. This is how I go through the expected values:
      diag ("\n"); for my $delta ($delta_time, $delta_date){ for my $field (qw (seconds minutes hours days months years)) { for my $type ('','total_') { my $func = "${type}${field}"; for my $prec ('','trunc') { diag ("comapring ".$delta->$func($prec)." to ".$test_value +s[$test_index]." at ".$test_index." func=".$func." prec=".$prec." typ +e=".$type." field=".$field); ok($delta->$func($prec) == $test_values[$test_index++],"$func +($prec) ($delta_text[$delta_index])") #or diag("Expected " . $test_values[$test_index++] . " got +" . $delta->$func($prec)); or diag("Expected " . $test_values[$test_index] . " got " . +$delta->$func($prec)); } } } $delta_index++; }
      I do not see in the code where Date::Manip methods are used
        I do not see in the code where Date::Manip methods are used

        I have added some comments to your code so that you understand what the script does, especially with regards to the above:

        for my $delta ($delta_time, $delta_date){ # the above are likely to be Date::Manip[::*] objects - which ones???? for my $field (qw (seconds minutes hours days months years)) { for my $type ('','total_') { my $func = "${type}${field}"; # this is the method name to be called via the $delta objects for my $prec ('','trunc') { # this is the a parameter to above method, one is empty on +e is 'trunc' diag ("comapring ".$delta->$func($prec)." to ".$test_value +s[$test_index]." at ".$test_index." func=".$func." prec=".$prec." typ +e=".$type." field=".$field); ok($delta->$func($prec) == $test_values[$test_index++],"$func +($prec) ($delta_text[$delta_index])") # it calls e.g. this: $delta->total_seconds('trunc') # and it compares the returned result with an item from an ar +ray # of expected results $test_values[$test_index]

        just do some plain 'ol debugging using common sense and forget about the deltas for the moment.

        For example, from your failed tests:

        # comapring 571645.000000 to 571645 at 7 func=total_minutes prec=trunc + type=total_ field=minutes # comapring 9527.417778 to 23.417778 at 8 func=hours prec= type= field +=hours # Failed test 'hours() (with time)' # at t/test.t line 97. # Expected 23 got 9527.417778 # comapring 9527 to 23 at 9 func=hours prec=trunc type= field=hours # Failed test 'hours(trunc) (with time)' # at t/test.t line 97. # Expected 9527.417778 got 9527 # comapring 9527.417778 to 9527.417778 at 10 func=total_hours prec= ty +pe=total_ field=hours

        it seems that you have 2 issues : the easy one: 9527.417778 got 9527. The other is that probably your expected results got mixed up at  Expected 23 got 9527.417778 especially since 34298704/60 = 571645 and 571645/60 = 9527.4166 you mixed your minutes somewhere along the road...

        bw, bliako

        Edit: actually for the 1st issue (Expected 9527.417778 got 9527) the deltas may help you. It is likely that at some stage there was a revision in D::M to return only the integer part. In general, when you compare floating point numbers you should not do an exact test but a range test: ok(abs($expected-$got)<1E-09, "yep, they are the same up to 1E-09") (although it would not be helpful in your case).

      Test2::V) does not appear to have the equivalent of use_ok. And once I use it, The 'new' in Class::MethodMaker appears to be broken
        Yeah, testing kinda moved past use_ok. As Test2::Bundle::More states, "These are not necessary. Use use and require directly." It's a show stopping fatal error if the module you're testing can't be used at all so wrapping it in an eval to make it non-fatal and then writing more code to bail out if that test failed because the following tests would also likely fail as well was kinda iffy.

        Back on topic, just so we have a starting place to figure out why you're getting unexpected values, try something like this to get the version of Date::Manip installed on your live environment (which is hopefully still up and running and not also the dev machine upgraded to 5.38.x...):

        perl -MDate::Manip -e 'warn $Date::Manip::VERSION'
        There's been a lot of time delta related changes in https://metacpan.org/dist/Date-Manip/changes since perl 5.10 was released. Hopefully we can narrow the range down a little with a version number. Class::MethodMaker might as well be magic the way it generates methods around other OOP modules so that'll be the last thing I'd try to dig into.

        ++SankoR has shown a quote regarding use_ok from Test2::Bundle::More. You'd do well to read all of that page; in particular the sections "KEY DIFFERENCES FROM Test::More" and "THESE FUNCTIONS AND VARIABLES HAVE BEEN REMOVED".

        You don't show any code using use_ok. The code examples from Test::More::use_ok generally have this form:

        BEGIN { use_ok('Some::Module') }

        You could change whatever lines you have like that to

        use ok 'Some::Module';

        Note there's no underscore between use and ok. This will work under Test2::V0. See the core module ok for more on that.

        "... moving to 5.38.2 (don't ask :)"

        I'd expect Perl v5.40.0 to be released in the next couple of months or so. Test2::Suite should become a core module in that version: see "perldelta (for 5.39.4): New Modules and Pragmata". You obviously have a lot of work to do with this conversion: I won't ask why v5.38.2 but maybe v5.40.0 might be a better target as you won't need to download and install various Test2::* modules from CPAN.

        — Ken

Re: Overcoming 5.10.0 vs 5.38.2 incompatibilities
by Corion (Patriarch) on Mar 11, 2024 at 19:56 UTC

    You will have to read all of the perldelta files in https://metacpan.org/dist/perl.

    Most likely you can speed up the process by telling us exactly what fails and how that manifests itself.

      Firstly, thank you for pointing me to the delta documentation. The target module purpose is to calculate date/time differences
      #1 how does the difference manifest itself Original in 5.10.0 (I added the line that says "comparing..." 1..60 ok 1 - use xxx::DateDelta; # # comapring 4.000000 to 4.000000 at 0 func=seconds prec= type= field=s +econds ok 2 - seconds() (with time) # comapring 4 to 4 at 1 func=seconds prec=trunc type= field=seconds ok 3 - seconds(trunc) (with time) # comapring 34298704.000000 to 34298704.000000 at 2 func=total_seconds + prec= type=total_ field=seconds ... 1..60 ok 1 - use AMG::DateDelta; # # comapring 4.000000 to 4.000000 at 0 func=seconds prec= type= field=s +econds ok 2 - seconds() (with time) # comapring 4 to 4 at 1 func=seconds prec=trunc type= field=seconds ok 3 - seconds(trunc) (with time) # comapring 34298704.000000 to 34298704.000000 at 2 func=total_seconds + prec= type=total_ field=seconds ok 4 - total_seconds() (with time) # comapring 34298704 to 34298704 at 3 func=total_seconds prec=trunc ty +pe=total_ field=seconds ok 5 - total_seconds(trunc) (with time) # comapring 25.066667 to 25.066667 at 4 func=minutes prec= type= field +=minutes
      But when I run on 538.2 I get
      t/test.t .. 1/60 # # comapring 4.000000 to 4.000000 at 0 func=seconds prec= type= field=s +econds # comapring 4 to 4 at 1 func=seconds prec=trunc type= field=seconds ... # comapring 571645.066667 to 571645.066667 at 6 func=total_minutes pre +c= type=total_ field=minutes # comapring 571645.000000 to 571645 at 7 func=total_minutes prec=trunc + type=total_ field=minutes # comapring 9527.417778 to 23.417778 at 8 func=hours prec= type= field +=hours # Failed test 'hours() (with time)' # at t/test.t line 97. # Expected 23 got 9527.417778 # comapring 9527 to 23 at 9 func=hours prec=trunc type= field=hours # Failed test 'hours(trunc) (with time)' # at t/test.t line 97. # Expected 9527.417778 got 9527 # comapring 9527.417778 to 9527.417778 at 10 func=total_hours prec= ty +pe=total_ field=hours /\/\/\/
      creating the class:
      use Class::MethodMaker new_with_init => 'new', get_set => [ qw ( _delta_date _delta_time )], boolean => [ qw ( _use_time_flag ) ]
      and the function for hours looks like:
      sub hours { my $self = shift; my $name = (caller(0))[3]; return $self->_format_time((defined($_[0]) && $_[0] eq 'trunc') ? '%hv' : '%hd') }

        Are you really saying you didn't get ok 1 - use xxx::DateDelta; and ok 2 - seconds() (with time)? Also, you forgot to provide the code.

        To help us help you, please put in the effort to create at least one SSCCE that we can run ... or explain clearly why you're unable/unwilling to do that.

        👁️🍾👍🦟