-
Notifications
You must be signed in to change notification settings - Fork 29
Normalize newlines #61
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
Conversation
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.
Thanks for doing this. Below I've recorded some times that will help in the future with having good commit messages.
RE Commits
- Once I give the go ahead, please squash your commits. I say wait so I can see what you change as the review happens
- If you use "Fixes normalize_newlines adapter predicate #45" instead of "Issue normalize_newlines adapter predicate #45", github will automatically close the issue
- Treat commit messages like markdown, e.g. use an extra newline to separate paragraphs
- For content, it is best to focus on the user-impact and any background for your change and less on recording what you changed, the diff tells you that. e.g. Maybe instead of "Added normalize_newlines adapter predicate", it would be "Add NormalizedPredicate adapter"
src/str/normalize.rs
Outdated
use Predicate; | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
pub struct NormalizedTrimPredicate<P> |
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.
Trim
is a word specific to removing whitespace. This isn't doing that right? So maybe just NormalizedPredicate
?
src/str/mod.rs
Outdated
#[cfg(feature = "normalized-line-endings")] | ||
mod normalize; | ||
#[cfg(feature = "normalized-line-endings")] | ||
pub use normalized_line_endings::normalized; |
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 think you mean to pub use self::normalize::NormalizedPredicate
src/str/adapters.rs
Outdated
@@ -111,6 +111,13 @@ where | |||
fn from_utf8(self) -> Utf8Predicate<Self> { | |||
Utf8Predicate { p: self } | |||
} | |||
/// Returns a `NormalizedTrimPredicate` that ensures the data passed | |||
/// to `Self` is trimmed and Normalized. |
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.
There should be example code in here for this new predicate
src/str/adapters.rs
Outdated
@@ -1,9 +1,9 @@ | |||
use std::ffi; | |||
use std::fmt; | |||
use std::str; | |||
|
|||
use Predicate; |
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.
Why was this newline removed? I prefer a style where local use
are kept separate from std
use
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.
Thanks! This is looking great. Just some minor stuff below
src/str/adapters.rs
Outdated
// assert_eq!(true, predicate_fn.eval("Hello World\n")); | ||
// assert_eq!(true, predicate_fn.eval("Hello World\r")); | ||
// assert_eq!(true, predicate_fn.eval("Hello World\r\n")); | ||
// assert_eq!(false, predicate_fn.eval("Goodbye")); |
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.
Don't these need 3 /
s?
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.
Yeah, looks like these aren't be properly recognized. Looking at travis, it looks like this example isn't being run
https://travis-ci.org/assert-rs/predicates-rs/jobs/407899022
src/str/adapters.rs
Outdated
/// | ||
/// ``` | ||
// use predicates::prelude::*; | ||
|
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.
Please have a ///
here rather than a completely blan line
src/str/adapters.rs
Outdated
#[cfg(feature = "normalized_trim")] | ||
fn normalized_trim(self) -> NormalizedTrimPredicate<Self> { | ||
NormalizedTrimPredicate { p: self } | ||
|
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.
Could you remove this extraneous whitespace?
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.
Almost there!
@@ -0,0 +1,28 @@ | |||
use std::fmt; |
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.
forgot to point out that the crate owner wants copyright headers on the files.
/// | ||
/// # Examples | ||
/// | ||
/// ``` |
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.
Still not seeing this example in the test results
https://travis-ci.org/assert-rs/predicates-rs/jobs/408337538
Is it because its missing "rust" on the code fence?
src/str/normalize.rs
Outdated
@@ -13,6 +13,9 @@ use normalize_line_endings::normalized; | |||
use std::iter::FromIterator; | |||
|
|||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | |||
/// Predicate adapter that normalizes the newlines contained in the variable being tested. | |||
/// | |||
/// This is created by `pred.normalized()`. |
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 created by
pred.normalized()
.
You dropped the d
elsewhere, so this should be
This is created by
pred.normalize()
.
0a12c70
to
043fb66
Compare
Great to see the tests passing! Could you squash this down to one commit? Commits should be standalone. In this case, there isn't a clear reasoning to divide up the commits. Also as reminder:
|
043fb66
to
57160a5
Compare
Resolve adapter.rs Added normalize_newlines adapter predicate Created normalize file and added normalize-line-endings as default dependency Created normalize trim predicate Fixes assert-rs#45 Normalize newlines - Insert newline in adapter.rs for readability - Add example code in adapter.rs for usability - Add self to mod.rs - Change to NormalizedPredicate in normalize.rs to avoid ambiguity Normalize newlines syntax clean-up Make comments "///" instead of "//" for consistency Improve readability by making one commented block for function in adapter.rs Delete extraneous whitespace for readability Normalize NewLines Add copyright notice to adapters.rs and normalize.rs Amend doc tests for passing CI Normalize NewLines passes all tests Struct documentation added for NormalizedPredicate Assert tests fixed in adapters.rs (string assertions did not match) change struct description to pred.normalize() for consistency Add Cfg feature to NormalizedPredicate in adapter.rs
57160a5
to
a418eef
Compare
No description provided.