chansen / p5-time-moment

Time::Moment represents an exact moment in time.
32 stars 8 forks source link

fixed test so it stringifies both sides #17

Closed spansh closed 9 years ago

spansh commented 9 years ago

There's an issue on perl 5.8.9 (possibly others but cpantesters is down so I can't check, but it doesn't seem to happen on 5.20) whereby the sereal test fails (on modern Test::More, probably due to https://metacpan.org/changes/distribution/Test-Simple#L212)

Calling to_string on both sides fixes that.

it's a little tricky to pin down as this is the test failure I saw:

t/530_sereal.t .......... 1/?
#   Failed test 'first element has right time'
#   at t/530_sereal.t line 33.
#          got: '2012-12-24T15:30:45.123456789+01:00'
#     expected: '2012-12-24T15:30:45.123456789+01:00'
#   Failed test 'second element has right time'
#   at t/530_sereal.t line 36.
#          got: '2012-12-24T15:30:45.987654321+01:00'
#     expected: '2012-12-24T15:30:45.987654321+01:00'

If we inspect those objects further:

$VAR1 = bless( do{\(my $o = '��k��[<')}, 'Time::Moment' );
$VAR2 = '2012-12-24T15:30:45.123456789+01:00';

$VAR1 = bless( do{\(my $o = '��k��h�:<')}, 'Time::Moment' );
$VAR2 = '2012-12-24T15:30:45.987654321+01:00';
chansen commented 9 years ago

Thank you for the pull request! Before applying it, could you please provide the output of Devel::Peek::Dump() instead of Data::Dumper::Dumper()?

spansh commented 9 years ago

Code:

use Devel::Peek;
warn '$decoded->[0]';
Devel::Peek::Dump($decoded->[0]);
warn '$moments[0]->to_string';
Devel::Peek::Dump($moments[0]->to_string);
    is($decoded->[0]->to_string, $moments[0]->to_string, 'first element has right time');
warn '$decoded->[1]';
Devel::Peek::Dump($decoded->[1]);
warn '$moments[1]->to_string';
Devel::Peek::Dump($moments[1]->to_string);
    is($decoded->[1]->to_string, $moments[1]->to_string, 'second element has right time');

Relevant output:

$decoded->[0] at t/530_sereal.t line 34.
SV = RV(0xf5f0b8) at 0x11ef800
  REFCNT = 1
  FLAGS = (ROK)
  RV = 0x11ef810
  SV = PVMG(0x1044808) at 0x11ef810
    REFCNT = 1
    FLAGS = (OBJECT,POK,pPOK)
    IV = 0
    NV = 0
    PV = 0xf4c850 "\245\275k\310\16\0\0\0\25\315[\7<\0\0\0"\0
    CUR = 16
    LEN = 24
    STASH = 0x1154300   "Time::Moment"
$moments[0]->to_string at t/530_sereal.t line 36.
SV = PV(0x11fd650) at 0x11f9550
  REFCNT = 1
  FLAGS = (TEMP,POK,pPOK)
  PV = 0x11dad20 "2012-12-24T15:30:45.123456789+01:00"\0
  CUR = 35
  LEN = 40
$decoded->[1] at t/530_sereal.t line 39.
SV = RV(0xf5f0c8) at 0x11ef820
  REFCNT = 1
  FLAGS = (ROK)
  RV = 0x11ef860
  SV = PVMG(0x1044878) at 0x11ef860
    REFCNT = 1
    FLAGS = (OBJECT,POK,pPOK)
    IV = 0
    NV = 0
    PV = 0xf4c8f0 "\245\275k\310\16\0\0\0\261h\336:<\0\0\0"\0
    CUR = 16
    LEN = 24
    STASH = 0x1154300   "Time::Moment"
$moments[1]->to_string at t/530_sereal.t line 41.
SV = PV(0x11fd650) at 0x11f9550
  REFCNT = 1
  FLAGS = (TEMP,POK,pPOK)
  PV = 0x11dad20 "2012-12-24T15:30:45.987654321+01:00"\0
  CUR = 35
  LEN = 40
chansen commented 9 years ago

Thanks! How should I credit you in the change log?

spansh commented 9 years ago

No credit required, but if you insist my name is fine. My regular cpan email address ID is GHARPER and the email for that is cpan@spansh.co.uk

Thanks

On 9 September 2015 at 12:54, Christian Hansen notifications@github.com wrote:

Thanks! How should I credit you in the change log?

— Reply to this email directly or view it on GitHub https://github.com/chansen/p5-time-moment/pull/17#issuecomment-138886890 .