-
Notifications
You must be signed in to change notification settings - Fork 874
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
Clean the code in field.rs
and add more tests
#2345
Conversation
Signed-off-by: remzi <13716567376yh@gmail.com>
@@ -698,41 +684,25 @@ impl Field { | |||
/// * self.metadata is a superset of other.metadata | |||
/// * all other fields are equal |
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.
I am not sure whether this is reasonable. For example,
let child_field1 = ...;
let child_field2 = ...;
let field1 = Struct(&child_field1);
let mut field2 = Struct(&child_field2);
field2.try_merge(field1).unwrap();
assert_eq!(false, field2.contains(field1))
As field2
has merged field1
into itself, I expect the field2
to contain field1
.
However, you will find that the answer is false
because field1
contains child_field1
but field2
contains child_field1
and child_field2
.
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.
I am not sure either -- can you possibly add this as a test (so that at least the behavior is documented and if we change it in the future we will also have to change the test)?
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.
Added.
@alamb Please help to review if you have time. 😁 |
field.rs
and add more testsField::contains
and add more tests
Field::contains
and add more testsfield.rs
and add more tests
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.
LGTM -- thanks @HaoYang670
} | ||
|
||
#[test] | ||
fn test_contains_nullable() { |
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.
Good check
} | ||
if is_new_field { | ||
nested_fields.push(from_field.clone()); | ||
match nested_fields |
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.
I agree this is easier to read 👍
@@ -698,41 +684,25 @@ impl Field { | |||
/// * self.metadata is a superset of other.metadata | |||
/// * all other fields are equal |
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.
I am not sure either -- can you possibly add this as a test (so that at least the behavior is documented and if we change it in the future we will also have to change the test)?
Good concern. I will add. Please don't merge this now. Thank you. |
marking as draft so we don't accidentally merge this until it is updated |
Signed-off-by: remzi <13716567376yh@gmail.com>
Benchmark runs are scheduled for baseline = 195d9c5 and contender = d4ad4b7. d4ad4b7 is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Signed-off-by: remzi 13716567376yh@gmail.com
Which issue does this PR close?
None.
Rationale for this change
What changes are included in this PR?
fn _field
,fn to_json
,fn try_merge
andfn contains
fn contains
Are there any user-facing changes?
No.