mirror of https://github.com/astral-sh/ruff
include source_order in display_graph output
This commit is contained in:
parent
7f4893d200
commit
d9429754b9
|
|
@ -1744,7 +1744,13 @@ impl<'db> Node<'db> {
|
||||||
Node::AlwaysTrue => write!(f, "always"),
|
Node::AlwaysTrue => write!(f, "always"),
|
||||||
Node::AlwaysFalse => write!(f, "never"),
|
Node::AlwaysFalse => write!(f, "never"),
|
||||||
Node::Interior(interior) => {
|
Node::Interior(interior) => {
|
||||||
interior.constraint(self.db).display(self.db).fmt(f)?;
|
write!(
|
||||||
|
f,
|
||||||
|
"{} {}/{}",
|
||||||
|
interior.constraint(self.db).display(self.db),
|
||||||
|
interior.source_order(self.db),
|
||||||
|
interior.max_source_order(self.db),
|
||||||
|
)?;
|
||||||
// Calling display_graph recursively here causes rustc to claim that the
|
// Calling display_graph recursively here causes rustc to claim that the
|
||||||
// expect(unused) up above is unfulfilled!
|
// expect(unused) up above is unfulfilled!
|
||||||
write!(
|
write!(
|
||||||
|
|
@ -3797,28 +3803,28 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_display_graph_output() {
|
fn test_display_graph_output() {
|
||||||
let expected = indoc! {r#"
|
let expected = indoc! {r#"
|
||||||
(T = str)
|
(T = str) 3/4
|
||||||
┡━₁ (T = bool)
|
┡━₁ (T = bool) 4/4
|
||||||
│ ┡━₁ (U = str)
|
│ ┡━₁ (U = str) 1/2
|
||||||
│ │ ┡━₁ (U = bool)
|
│ │ ┡━₁ (U = bool) 2/2
|
||||||
│ │ │ ┡━₁ always
|
│ │ │ ┡━₁ always
|
||||||
│ │ │ └─₀ always
|
│ │ │ └─₀ always
|
||||||
│ │ └─₀ (U = bool)
|
│ │ └─₀ (U = bool) 2/2
|
||||||
│ │ ┡━₁ always
|
│ │ ┡━₁ always
|
||||||
│ │ └─₀ never
|
│ │ └─₀ never
|
||||||
│ └─₀ (U = str)
|
│ └─₀ (U = str) 1/2
|
||||||
│ ┡━₁ (U = bool)
|
│ ┡━₁ (U = bool) 2/2
|
||||||
│ │ ┡━₁ always
|
│ │ ┡━₁ always
|
||||||
│ │ └─₀ always
|
│ │ └─₀ always
|
||||||
│ └─₀ (U = bool)
|
│ └─₀ (U = bool) 2/2
|
||||||
│ ┡━₁ always
|
│ ┡━₁ always
|
||||||
│ └─₀ never
|
│ └─₀ never
|
||||||
└─₀ (T = bool)
|
└─₀ (T = bool) 4/4
|
||||||
┡━₁ (U = str)
|
┡━₁ (U = str) 1/2
|
||||||
│ ┡━₁ (U = bool)
|
│ ┡━₁ (U = bool) 2/2
|
||||||
│ │ ┡━₁ always
|
│ │ ┡━₁ always
|
||||||
│ │ └─₀ always
|
│ │ └─₀ always
|
||||||
│ └─₀ (U = bool)
|
│ └─₀ (U = bool) 2/2
|
||||||
│ ┡━₁ always
|
│ ┡━₁ always
|
||||||
│ └─₀ never
|
│ └─₀ never
|
||||||
└─₀ never
|
└─₀ never
|
||||||
|
|
@ -3834,7 +3840,9 @@ mod tests {
|
||||||
let t_bool = ConstraintSet::range(&db, bool_type, t, bool_type);
|
let t_bool = ConstraintSet::range(&db, bool_type, t, bool_type);
|
||||||
let u_str = ConstraintSet::range(&db, str_type, u, str_type);
|
let u_str = ConstraintSet::range(&db, str_type, u, str_type);
|
||||||
let u_bool = ConstraintSet::range(&db, bool_type, u, bool_type);
|
let u_bool = ConstraintSet::range(&db, bool_type, u, bool_type);
|
||||||
let constraints = (t_str.or(&db, || t_bool)).and(&db, || u_str.or(&db, || u_bool));
|
// Construct this in a different order than above to make the source_orders more
|
||||||
|
// interesting.
|
||||||
|
let constraints = (u_str.or(&db, || u_bool)).and(&db, || t_str.or(&db, || t_bool));
|
||||||
let actual = constraints.node.display_graph(&db, &"").to_string();
|
let actual = constraints.node.display_graph(&db, &"").to_string();
|
||||||
assert_eq!(actual, expected);
|
assert_eq!(actual, expected);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue