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

feat: add string comparison support #99

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

eddycharly
Copy link
Collaborator

Add string comparison support.

Fixes #96

Signed-off-by: Charles-Edouard Brétéché <[email protected]>
Copy link

codecov bot commented Jun 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.81%. Comparing base (e430401) to head (9f8a53f).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #99      +/-   ##
==========================================
+ Coverage   88.51%   90.81%   +2.29%     
==========================================
  Files          15       15              
  Lines        2594     2220     -374     
==========================================
- Hits         2296     2016     -280     
+ Misses        204      112      -92     
+ Partials       94       92       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@eddycharly eddycharly marked this pull request as ready for review June 27, 2024 22:19
@eddycharly
Copy link
Collaborator Author

@springcomp do we have a test suite for that ?

Signed-off-by: Charles-Edouard Brétéché <[email protected]>
}
// TODO: don't we want to return an error here ?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@springcomp WDYT about returning an error here ?

Copy link
Contributor

Choose a reason for hiding this comment

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

My understanding is that this is already covered in the original code by returning nil, nil.
As this is a non-standard extension, I think we should return that as well if types do not match.

I like the attempt to cast as numbers and compare that.
This means that comparing number-like strings will produce the correct output.

Please, be aware that comparing strings may still exhibit confusing output.
For instance the following two strings will not be considered equal:

  • élément (é LATIN SMALL LETTER E WITH ACUTE ACCENT (U+00E9), …
  • élément (e LATIN SMALL LETTER E (U+0065), ◌́ COMBINING ACUTE ACCENT (U+0301), …

}
// TODO: don't we want to return an error here ?
Copy link
Contributor

Choose a reason for hiding this comment

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

My understanding is that this is already covered in the original code by returning nil, nil.
As this is a non-standard extension, I think we should return that as well if types do not match.

I like the attempt to cast as numbers and compare that.
This means that comparing number-like strings will produce the correct output.

Please, be aware that comparing strings may still exhibit confusing output.
For instance the following two strings will not be considered equal:

  • élément (é LATIN SMALL LETTER E WITH ACUTE ACCENT (U+00E9), …
  • élément (e LATIN SMALL LETTER E (U+0065), ◌́ COMBINING ACUTE ACCENT (U+0301), …

@eddycharly
Copy link
Collaborator Author

I think it's a good first step but we definitely need a conformance test suite IMHO.

As this is a non-standard extension

What do you mean by non-standard ?

@springcomp
Copy link
Contributor

What do you mean by non-standard ?

In the specification, ordering operators are only specified for numbers.
Comparing any other consistently-typed items, or even heterogeneously-typed items, is currently unspecified.

A library is free (and more than welcome) to include non-standard features or improvement of course.
We just need to be wary to not go in a direction that would need an overhaul in the future if new specifications come in for the same subject.

@springcomp
Copy link
Contributor

@eddycharly I think this is in good share.
Is there anything you still need for this PR to be merged ?

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.

Issue with filtering by comparison
2 participants