Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

PERL-747: Extended JSON #5

Closed
wants to merge 45 commits into from

Conversation

phaylon
Copy link
Contributor

@phaylon phaylon commented Aug 31, 2018

Implements Extended JSON and adds the new BSON corpus tests.

Copy link
Contributor

@xdg xdg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked over the test code, but here are my comments so far on the library code.

lib/BSON.pm Outdated Show resolved Hide resolved
lib/BSON.pm Outdated Show resolved Hide resolved
lib/BSON.pm Outdated Show resolved Hide resolved
lib/BSON.pm Outdated Show resolved Hide resolved
lib/BSON.pm Show resolved Hide resolved
lib/BSON/DBRef.pm Outdated Show resolved Hide resolved
lib/BSON/Double.pm Outdated Show resolved Hide resolved
Copy link
Contributor

@xdg xdg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are comments on the test code.

@@ -4,11 +4,13 @@ use warnings;
use Test::More 0.96;
use Test::Deep qw/!blessed/;

use JSON::PP ();
use JSON::XS ();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sort of defeats the purpose of using JSON::MaybeXS and adds a hard test dependency on JSON::XS, but I don't see it used at all. Is this is leftover from some earlier attempt to fix the ordering problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've actually now switched it to Cpanel::JSON::XS. The XS/PP usage is because we require PP for the ability to created an IxHash, but we need XS for proper svtype detection. The leftover usage of MaybeXS was from earlier, and I'm now using the XS variant explicitly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you talk this over with @shadowcat-mst please? Keeping BSON pure-Perl capable -- even in testing -- is pretty important; part of its reason for being, even. If there's no way to avoid XS for testing, then it needs to be conditional.

t/lib/CorpusTest.pm Outdated Show resolved Hide resolved
t/lib/CorpusTest.pm Outdated Show resolved Hide resolved
t/lib/CorpusTest.pm Outdated Show resolved Hide resolved
t/lib/CorpusTest.pm Outdated Show resolved Hide resolved
$E = _normalize( $E, "$desc: normalizing E" );
$cE = _normalize( $cE, "$desc: normalizing cE" );

_bson_to_bson( $codec, $B, $cB, "$desc: B->cB" );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this test and the one on 93 got lost.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the former versions of these used bson and canonical_bson I'm unsure how they would map to the new data fields. I've added a BSON roundtrip test for canonical/converted now, but I'm unsure if this is sufficient.

t/lib/CorpusTest.pm Outdated Show resolved Hide resolved
t/lib/CorpusTest.pm Outdated Show resolved Hide resolved
t/lib/CorpusTest.pm Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Sep 10, 2018

Coverage Status

Coverage decreased (-2.7%) to 84.048% when pulling b4504e3 on shadow-dot-cat:phaylon/PERL-747 into 6f441c0 on mongodb:master.

Copy link
Contributor

@xdg xdg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good; my major comment is a structural one about the tests.

->allow_blessed
->convert_blessed;

my $JSON_XS = Cpanel::JSON::XS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable appears unused.

$codec,
$canonical_bson,
defined($converted_bson) ? $converted_bson : $canonical_bson,
'cB/B -> cB',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: cB -> cB

);
}
# deprecated and non-deprecated
sub _validity_tests_all {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still find these very hard to reconcile against the bson-corpus spec. Could you please try reorganizing to more directly follow the structure in the spec? (e.g. "For cB input...", "For cEJ input..."?

Copy link
Contributor

@xdg xdg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks. I'll confirm tests and merge or reply with comments.

@xdg
Copy link
Contributor

xdg commented Sep 12, 2018

Squashed and merged as c863549

@xdg xdg closed this Sep 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants