Branch: refs/heads/blead
  Home:   https://github.com/Perl/perl5
  Commit: 53379bfd2fda838c2871b2d7a303224e0724baa0
      
https://github.com/Perl/perl5/commit/53379bfd2fda838c2871b2d7a303224e0724baa0
  Author: David Mitchell <[email protected]>
  Date:   2019-11-18 (Mon, 18 Nov 2019)

  Changed paths:
    M cpan/Memoize/t/expmod_t.t

  Log Message:
  -----------
  Memoize: rewrite expmod_t.t

This test script checks that cache entries expire correctly. However, it
occasionally causes smoke failures, since it's sensitive to timing and
so very slow machines may trip it up.

This commit rewrites the test script so that (hopefully) it will be
immune to timing issues.

It just repeatedly calls the memoized function, each time recording the
time just before and after, which gives a bracketed time range within
which we know the function was called. Then the previous range and the
current range can be analysed to determine whether a new or cached value
was returned, and in either case whether this was within or beyond any possible
expiry time.

Note that I removed the use Time::HiRes, as there seems to be a bug with
Memoize::Expire whereby the returned cached value gets stringified,
which can cause rounding errors if the original value was an NV.
Sticking with integers makes life easier.

Reply via email to