On Sun, Mar 24, 2013 at 09:08:33PM +0100, H.Merijn Brand wrote:
> PASSes on all my boxes but one
>
> The failing box has JSON::XS installed (temporary to check Schmorp's
> claims, for which I so far found no proof)
>
> The formatted output - I might have an output patch applied to make the
> output style meet our requirements - causes this mismatch.
Am I right in thinking that the goal of the JSON::XS test is to check
whether JSON::XS puts quotes around values?
I'd suggest adding s/\s+//g, plus a comment, to make that explicit.
Tim.
> I don't mind when the verdict is: we cannot expect people to alter
> whitespacing in module output, but having cpanprefs not only makes that
> easy, but make installing a lot of modules suddenly become more logical
> as I can "fix" the decisions the author made that I do not agree with.
>
> Personally I don't think prettied output checks in tests should ever
> test on whitespace (including newlines) unless the output is completely
> generated by the module itself or guaranteed by the module or its
> documentation to not add or remove whitespace.
>
> The change to prevent this specific case is maybe somthing like
> --8<---
> --- a/t/90sql_type_cast.t 2013-03-24 21:00:02.167352360 +0100
> +++ b/t/90sql_type_cast.t 2013-03-24 21:05:07.251376420 +0100
> @@ -116,7 +116,7 @@ foreach my $test(@tests) {
> skip 'DiscardString not supported in PurePerl', 1
> if $pp && ($test->[3] & DBIstcf_DISCARD_STRING);
>
> - my $json = JSON::XS->new->encode([$val]);
> + (my $json = JSON::XS->new->encode([$val])) =~ s/\s+]$/]/;;
> #diag(neat($val), ",", $json);
> is($json, $test->[5], "json $test->[0]");
> };
> -->8---
>
> but it doesn't catch changes that generate extra spaces output as
> like " [ 99 ] "
>
> For me, the tests will pass again next week, as JSON::XS will be banned
> to trash again
>
> t/87gofer_cache.t ............... ok
> t/90sql_type_cast.t ............. 1/45
> # Failed test 'json undef'
> # at t/90sql_type_cast.t line 121.
> # got: '[null ]'
> # expected: '[null]'
>
> # Failed test 'json invalid sql type'
> # at t/90sql_type_cast.t line 121.
> # got: '["99" ]'
> # expected: '["99"]'
>
> # Failed test 'json non numeric cast to int'
> # at t/90sql_type_cast.t line 121.
> # got: '["aa" ]'
> # expected: '["aa"]'
>
> # Failed test 'json non numeric cast to int (strict)'
> # at t/90sql_type_cast.t line 121.
> # got: '["aa" ]'
> # expected: '["aa"]'
>
> # Failed test 'json small int cast to int'
> # at t/90sql_type_cast.t line 121.
> # got: '["99" ]'
> # expected: '["99"]'
>
> # Failed test 'json 2 byte max signed int cast to int'
> # at t/90sql_type_cast.t line 121.
> # got: '["32767" ]'
> # expected: '["32767"]'
>
> # Failed test 'json 2 byte max unsigned int cast to int'
> # at t/90sql_type_cast.t line 121.
> # got: '["65535" ]'
> --
> H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/
> using perl5.00307 .. 5.17 porting perl5 on HP-UX, AIX, and openSUSE
> http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/
> http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/