-
Notifications
You must be signed in to change notification settings - Fork 83
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
deer
: testing framework
#1701
deer
: testing framework
#1701
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1701 +/- ##
==========================================
- Coverage 53.72% 52.19% -1.53%
==========================================
Files 229 237 +8
Lines 15227 15826 +599
Branches 411 411
==========================================
+ Hits 8180 8261 +81
- Misses 7042 7560 +518
Partials 5 5
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool, Bilal! I left some comments :)
Excited to see it in action
/// | ||
/// assert_tokens(&Bool(true), &[Token::Bool(true)]) | ||
/// ``` | ||
Bool(bool), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why only bool has this full test and the rest dont? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more of a showcase. Building this out, I realized that most of the code is duplicated for these kinds of tests on the primitive types, so the idea was to showcase the examples instead of using the existing primitive Visitor
and Deserialize
implementations that are in the follow-up PR.
use crate::token::Token; | ||
|
||
#[derive(Debug)] | ||
enum Trivia<'a> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask what the origin of this naming is? Seems interesting 🐮
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for sure! This is taken from rust-analyzer
, where whitespace and comments are regarded as trivia. The idea, in this case, is basically:
{"key1": 1, "key2": 2, "key3": 3}
Taking this, the whitespace would be considered trivia. When we then search for a key, the key and value span are both "erased" and converted to trivia, e.g., taking key2
, our object internally turns into:
{"key1": 1, "key3": 3}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Great stuff :)
🌟 What is the purpose of this PR?
Currently, we have no way of testing the built-in types that are to be implemented (#1700). This remedies it by creating a testing framework that works on tokens (similar to
serde_test
). To make reuse easier it is a separate internal-only package calleddeer-desert
(name TBD)🔗 Related links
🚫 Blocked by
🔍 What does this change?
Creates a new internal-only crate for testing deserialize implementations independent of an actual deserializer.
🛡 What tests cover this?
Unit tests will be provided for the testing framework to ensure everything is ok.An example test has been provided, but more tests will follow once std #1700 has progressed further. Otherwise, the
Deserialize
would be implemented multiple times for the "atomic" types.desert
as indeserialize test