Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit and property tests for sampling and type unification #10

Merged
merged 10 commits into from
Mar 21, 2024

Conversation

dmoverton
Copy link
Collaborator

No description provided.

@dmoverton dmoverton self-assigned this Mar 21, 2024
@dmoverton dmoverton marked this pull request as draft March 21, 2024 01:09
@dmoverton dmoverton changed the title Unit and property tests for type unification Unit and property tests for sampling and type unification Mar 21, 2024
@dmoverton dmoverton requested a review from hallettj March 21, 2024 04:26
@dmoverton dmoverton marked this pull request as ready for review March 21, 2024 04:27
Copy link
Collaborator

@hallettj hallettj left a comment

Choose a reason for hiding this comment

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

Looks good

@@ -18,3 +18,6 @@ serde_json = { version = "1.0.113", features = ["raw_value"] }
thiserror = "1.0.57"
tokio = { version = "1.36.0", features = ["full"] }
these = "2.0.0"

[dev-dependencies]
proptest = "1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a great idea!

Comment on lines +298 to +318
prop_oneof![
Just(BsonScalarType::Double),
Just(BsonScalarType::Decimal),
Just(BsonScalarType::Int),
Just(BsonScalarType::Long),
Just(BsonScalarType::String),
Just(BsonScalarType::Date),
Just(BsonScalarType::Timestamp),
Just(BsonScalarType::BinData),
Just(BsonScalarType::ObjectId),
Just(BsonScalarType::Bool),
Just(BsonScalarType::Null),
Just(BsonScalarType::Regex),
Just(BsonScalarType::Javascript),
Just(BsonScalarType::JavascriptWithScope),
Just(BsonScalarType::MinKey),
Just(BsonScalarType::MaxKey),
Just(BsonScalarType::Undefined),
Just(BsonScalarType::DbPointer),
Just(BsonScalarType::Symbol),
]
Copy link
Collaborator

Choose a reason for hiding this comment

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

There might be a way to avoid writing out all the enum variants since BsonScalarType implements enum_iterator::Sequence. But I don't know how to do that in proptest. Something like,

let n = arb in (0...BsonScalarType.CARDINALITY);
let scalar_type = BsonScalarType::all().nth(n);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll look into this another time. Wanted to get this merged so we can tag a build to put in the CLI registry.

@dmoverton dmoverton merged commit b95d249 into main Mar 21, 2024
2 checks passed
@dmoverton dmoverton deleted the dmoverton/sampling-tests branch March 21, 2024 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants