Skip to content

Commit

Permalink
Merge pull request #37 from de-vri-es/update-deps
Browse files Browse the repository at this point in the history
Update dependencies.
  • Loading branch information
de-vri-es authored Aug 27, 2024
2 parents 12dea23 + 95569ae commit 79466b9
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
main:
* Update `syn` to `v2.0.76`.
* Update `yansi` to `v1.0.1`.

v0.3.14 - 2024-03-04:
* Fix support for Rust 1.65.

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ categories = ["development-tools::debugging", "development-tools::testing"]

[dependencies]
assert2-macros = { version = "=0.3.14", path = "assert2-macros" }
yansi = "0.5.0"
yansi = "1.0.1"
is-terminal = "0.4.3"
diff = "0.1.13"

Expand Down
2 changes: 1 addition & 1 deletion assert2-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ proc-macro = true
[dependencies]
proc-macro2 = "1.0.14"
quote = "1.0.2"
syn = { version = "1.0.13", features = ["full", "visit", "visit-mut"] }
syn = { version = "2.0.76", features = ["full", "visit", "visit-mut"] }

[build-dependencies]
rustc_version = "0.4.0"
2 changes: 1 addition & 1 deletion assert2-macros/src/let_assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl syn::parse::Parse for Args {
let _comma = input.parse::<syn::token::Comma>()?;
let macro_name = input.parse()?;
let _comma = input.parse::<syn::token::Comma>()?;
let pattern = input.parse()?;
let pattern = syn::Pat::parse_multi_with_leading_vert(input)?;
let _eq_token = input.parse::<syn::token::Eq>()?;
let expression = input.parse()?;

Expand Down
30 changes: 15 additions & 15 deletions src/__assert2_impl/print/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ impl<'a> MultiLineDiff<'a> {
for diff in &self.line_diffs {
match *diff {
LineDiff::LeftOnly(left) => {
writeln!(buffer, "{}", Paint::cyan(format_args!("< {left}"))).unwrap();
writeln!(buffer, "{}", Paint::cyan(&format_args!("< {left}"))).unwrap();
},
LineDiff::RightOnly(right) => {
writeln!(buffer, "{}", Paint::yellow(format_args!("> {right}"))).unwrap();
writeln!(buffer, "{}", Paint::yellow(&format_args!("> {right}"))).unwrap();
},
LineDiff::Different(left, right) => {
let diff = SingleLineDiff::new(left, right);
write!(buffer, "{} ", diff.left_highlights.normal.paint("<")).unwrap();
write!(buffer, "{} ", "<".paint(diff.left_highlights.normal)).unwrap();
diff.write_left(buffer);
write!(buffer, "\n{} ", diff.right_highlights.normal.paint(">")).unwrap();
write!(buffer, "\n{} ", ">".paint(diff.right_highlights.normal)).unwrap();
diff.write_right(buffer);
buffer.push('\n');
},
LineDiff::Equal(text, _) => {
writeln!(buffer, " {}", Paint::default(text).dimmed()).unwrap();
LineDiff::Equal(text) => {
writeln!(buffer, " {}", text.primary().on_primary().dim()).unwrap();
},
}
}
Expand All @@ -52,7 +52,7 @@ enum LineDiff<'a> {
// There is a left and a right line, but they are different.
Different(&'a str, &'a str),
// There is a left and a right line, and they are equal.
Equal(&'a str, &'a str),
Equal(&'a str),
}

impl<'a> LineDiff<'a> {
Expand Down Expand Up @@ -89,14 +89,14 @@ impl<'a> LineDiff<'a> {
// In other cases, just continue to the default behaviour of adding a `RightOnly` entry.
Self::LeftOnly(_) => (),
Self::RightOnly(_) => (),
Self::Equal(_, _) => (),
Self::Equal(_) => (),
}
}
output.push(LineDiff::RightOnly(r));
seen_left = 0;
},
diff::Result::Both(l, r) => {
output.push(Self::Equal(l, r));
diff::Result::Both(l, _r) => {
output.push(Self::Equal(l));
seen_left = 0;
}
}
Expand Down Expand Up @@ -217,8 +217,8 @@ struct Highlighter {
impl Highlighter {
/// Create a new highlighter with the given color.
fn new(color: yansi::Color) -> Self {
let normal = yansi::Style::new(color);
let highlight = yansi::Style::new(yansi::Color::Black).bg(color).bold();
let normal = yansi::Style::new().fg(color);
let highlight = yansi::Style::new().fg(yansi::Color::Black).bg(color).bold();
Self {
ranges: Vec::new(),
total_highlighted: 0,
Expand Down Expand Up @@ -248,13 +248,13 @@ impl Highlighter {
fn write_highlighted(&self, buffer: &mut String, data: &str) {
let not_highlighted = data.len() - self.total_highlighted;
if not_highlighted < div_ceil(self.total_highlighted, 2) {
write!(buffer, "{}", self.normal.paint(data)).unwrap();
write!(buffer, "{}", data.paint(self.normal)).unwrap();
} else {
for (highlight, range) in self.ranges.iter().cloned() {
let piece = if highlight {
self.highlight.paint(&data[range])
data[range].paint(self.highlight)
} else {
self.normal.paint(&data[range])
data[range].paint(self.normal)
};
write!(buffer, "{}", piece).unwrap();
}
Expand Down
14 changes: 7 additions & 7 deletions src/__assert2_impl/print/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ impl<'a, T: CheckExpression> FailedCheck<'a, T> {
pub fn print(&self) {
let mut print_message = String::new();
writeln!(&mut print_message, "{msg} at {file}:{line}:{column}:",
msg = Paint::red("Assertion failed").bold(),
file = Paint::default(self.file).bold(),
msg = "Assertion failed".red().bold(),
file = self.file.bold(),
line = self.line,
column = self.column,
).unwrap();
Expand All @@ -73,7 +73,7 @@ impl<'a, T: CheckExpression> FailedCheck<'a, T> {
writeln!(&mut print_message, ).unwrap();
if let Some(msg) = self.custom_msg {
writeln!(&mut print_message, "with message:").unwrap();
writeln!(&mut print_message, " {}", Paint::default(msg).bold()).unwrap();
writeln!(&mut print_message, " {}", msg.bold()).unwrap();
}
writeln!(&mut print_message).unwrap();

Expand Down Expand Up @@ -106,9 +106,9 @@ impl<Left: Debug, Right: Debug> CheckExpression for BinaryOp<'_, Left, Right> {
diff.write_right(print_message);
if left == right {
if self.operator == "==" {
write!(print_message, "\n{}", Paint::red("Note: Left and right compared as unequal, but the Debug output of left and right is identical!")).unwrap();
write!(print_message, "\n{}", "Note: Left and right compared as unequal, but the Debug output of left and right is identical!".red()).unwrap();
} else {
write!(print_message, "\n{}", Paint::default("Note: Debug output of left and right is identical.").bold()).unwrap();
write!(print_message, "\n{}", "Note: Debug output of left and right is identical.".bold()).unwrap();
}
}
return
Expand All @@ -132,7 +132,7 @@ impl CheckExpression for BooleanExpr<'_> {

fn write_expansion(&self, print_message: &mut String) {
writeln!(print_message, "with expansion:").unwrap();
write!(print_message, " {:?}", Paint::cyan(false)).unwrap();
write!(print_message, " {:?}", false.cyan()).unwrap();
}
}

Expand All @@ -152,7 +152,7 @@ impl<Value: Debug> CheckExpression for MatchExpr<'_, Value> {
fn write_expansion(&self, print_message: &mut String) {
writeln!(print_message, "with expansion:").unwrap();
let [value] = AssertOptions::get().expand.expand_all([&self.value]);
let message = Paint::yellow(value).to_string();
let message = value.yellow().to_string();
for line in message.lines() {
writeln!(print_message, " {line}").unwrap();
}
Expand Down
4 changes: 2 additions & 2 deletions src/__assert2_impl/print/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ impl AssertOptions {
Ok(mut style) => {
let style = style.get_or_insert_with(AssertOptions::from_env);
if style.color {
yansi::Paint::enable()
yansi::whenever(yansi::Condition::ALWAYS)
} else {
yansi::Paint::disable()
yansi::whenever(yansi::Condition::NEVER)
}
return *style;
}
Expand Down

0 comments on commit 79466b9

Please sign in to comment.