Skip to content

Commit

Permalink
dot-explorer: fix subgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Aug 6, 2021
1 parent a4f1bd8 commit a5caab3
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions dot-explorer/src/dot.rs
Expand Up @@ -203,8 +203,8 @@ fn edge_stmt(s: &str) -> IResult<&str, Statement> {
map(
tuple((
alt((
map(ws(node_id), Either::Left),
map(ws(subgraph), Either::Right),
map(ws(node_id), Either::Left),
)),
ws(edge_rhs),
opt(attr_list),
Expand All @@ -219,8 +219,8 @@ fn edge_rhs(s: &str) -> IResult<&str, Either<String, Subgraph>> {
tuple((
alt((ws(tag("->")), ws(tag("--")))),
alt((
map(ws(node_id), Either::Left),
map(ws(subgraph), Either::Right),
map(ws(node_id), Either::Left),
)),
)),
|(_, r)| r,
Expand Down Expand Up @@ -452,6 +452,26 @@ mod tests {
}
))
);
assert_eq!(
graph(r#"digraph { A -> subgraph {B C} }"#),
Ok((
"",
Graph {
name: None,
nodes: {
let mut set = BTreeSet::new();
set.insert("A".to_string());
set.insert("B".to_string());
set.insert("C".to_string());
set
},
edges: vec![
("A".to_string(), "B".to_string(), vec![]),
("A".to_string(), "C".to_string(), vec![])
]
}
))
);
}

#[test]
Expand Down

0 comments on commit a5caab3

Please sign in to comment.