Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/winnow-datetime-assert/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## 0.2.0 - 2024-05-04
* Changed parser signatures to meet winnow 0.7 standards
* Removed dependency on galvanic-test which was accidentally left over from some initial design experiments.
* Removed paste dependency which is no longer used.

## 0.1.0 - 2024-12-29

Initial release

* Best efforts to fully cover common specs
8 changes: 3 additions & 5 deletions crates/winnow-datetime-assert/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "winnow_datetime_assert"
version = "0.1.0"
version = "0.2.0"
description = "Testing/Benchmarking winnow-datetime parsers"
keywords = [ "iso8601", "date-time", "parser", "winnow" ]
categories = [ "parser-implementations", "date-and-time" ]
Expand All @@ -13,11 +13,9 @@ readme = "README.md"
edition = "2021"

[dependencies]
winnow_datetime = { path = "../winnow-datetime", version = "0.1.0", features = ["serde"] }
winnow_datetime = { path = "../winnow-datetime", version = "0.2.0", features = ["serde"] }
libtest-mimic = "0.8.1"
galvanic-test = "0.2.0"
winnow = "0.6.20"
paste = "1.0.15"
winnow = "0.7"
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.9.34-deprecated"

Expand Down
36 changes: 29 additions & 7 deletions crates/winnow-datetime-assert/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,41 @@ macro_rules! define_format_tests {
(covered, uncovered)
});

fn parse_input(input: &str) -> Result<$piece_type, String> {
match terminated($parser, eof).parse_next(&mut input.as_bytes()) {
Ok(p) => Ok(p),
Err(e) => Err(format!("Failed to parse {}: {}", input, e)),
}
fn parse_input<'i, Input>(input: &mut Input) -> Result<$piece_type, String>
where
Input: StreamIsPartial
+ Stream
+ Compare<&'i str>
+ AsBStr
+ Clone
+ std::fmt::Display,
<Input as Stream>::Slice: AsBStr,
<Input as Stream>::Token: AsChar + Clone,
{
let o = $parser::<Input, InputError<Input>>(input).map_err(|e| {
format!(
"Failed to parse datetime: {}: {}",
String::from_utf8_lossy(input.as_bstr()),
e.to_string()
)
})?;
let _ = eof::<Input, InputError<Input>>(input).map_err(|e| {
format!(
"Remaining input parsing datetime: {}: {}",
String::from_utf8_lossy(input.as_bstr()),
e.to_string()
)
})?;

Ok(o)
}

// Generate a trial for each assertion
for assertion in covered {
let name = format!("parses - {}", assertion.format);
trials.push(Trial::test(name, move || {
// Parse the input
let result = parse_input(&assertion.input);
let result = parse_input(&mut assertion.input.as_str());

// If covered, the result must match the expected value
if result != Ok(assertion.expected) {
Expand All @@ -162,7 +184,7 @@ macro_rules! define_format_tests {
let name = format!("rejects - {}", assertion.format);
trials.push(Trial::test(name, move || {
// Parse the input
let result = parse_input(&assertion.input);
let result = parse_input(&mut assertion.input.as_str());

// If not covered, the result must be an error
if result.is_ok() {
Expand Down
5 changes: 5 additions & 0 deletions crates/winnow-datetime/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 0.2.0 - 2015-05-04
* Changed `Stream` helper type to `PartialInput` since this name conflicts with the winnow naming scheme and causes confusion.
* Bumped winnow version to 0.7 and changed parser singatures to match standard winnow parsers

## 0.1.0 - 2014-12-29 - Initial Release
4 changes: 2 additions & 2 deletions crates/winnow-datetime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "winnow_datetime"
version = "0.1.0"
version = "0.2.0"
description = "Parsing dates using winnow"
keywords = [ "iso8601", "date-time", "parser", "winnow" ]
categories = [ "parser-implementations", "date-and-time" ]
Expand All @@ -13,7 +13,7 @@ readme = "README.md"
edition = "2021"

[dependencies]
winnow = "0.6.20"
winnow = "0.7"
chrono = { version = "0.4", default-features = false, optional = true }
time = { version = "0.3.37", default-features = false, optional = true }
num-traits = { version = "0.2", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/winnow-datetime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ pub use types::Time;
use winnow::Partial;

/// Type for holding partial data for parsers
pub type Stream<'i> = Partial<&'i [u8]>;
pub type PartialInput<'i> = Partial<&'i [u8]>;
Loading
Loading