From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_graphviz/src/tests.rs | 408 +++++++++++++++++++++++++++++++++++ 1 file changed, 408 insertions(+) create mode 100644 compiler/rustc_graphviz/src/tests.rs (limited to 'compiler/rustc_graphviz/src/tests.rs') diff --git a/compiler/rustc_graphviz/src/tests.rs b/compiler/rustc_graphviz/src/tests.rs new file mode 100644 index 000000000..154bae4cb --- /dev/null +++ b/compiler/rustc_graphviz/src/tests.rs @@ -0,0 +1,408 @@ +use super::LabelText::{self, EscStr, HtmlStr, LabelStr}; +use super::{render, Edges, GraphWalk, Id, Labeller, Nodes, Style}; +use std::io; +use std::io::prelude::*; +use NodeLabels::*; + +/// each node is an index in a vector in the graph. +type Node = usize; +struct Edge { + from: usize, + to: usize, + label: &'static str, + style: Style, +} + +fn edge(from: usize, to: usize, label: &'static str, style: Style) -> Edge { + Edge { from, to, label, style } +} + +struct LabelledGraph { + /// The name for this graph. Used for labeling generated `digraph`. + name: &'static str, + + /// Each node is an index into `node_labels`; these labels are + /// used as the label text for each node. (The node *names*, + /// which are unique identifiers, are derived from their index + /// in this array.) + /// + /// If a node maps to None here, then just use its name as its + /// text. + node_labels: Vec>, + + node_styles: Vec