rgl 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/ChangeLog +19 -10
  2. data/Gemfile +3 -0
  3. data/{README → README.rdoc} +70 -98
  4. data/Rakefile +44 -150
  5. data/examples/canvas.rb +63 -64
  6. data/examples/examples.rb +42 -42
  7. data/examples/graph.dot +46 -0
  8. data/examples/images/example.jpg +0 -0
  9. data/examples/images/module_graph.jpg +0 -0
  10. data/examples/images/rgl_modules.png +0 -0
  11. data/examples/{insel-der-tausend-gefahren.rb → insel_der_tausend_gefahren.rb} +18 -19
  12. data/examples/north.rb +2 -2
  13. data/examples/north2.rb +11 -11
  14. data/examples/rdep-rgl.rb +218 -222
  15. data/lib/rgl/adjacency.rb +78 -74
  16. data/lib/rgl/base.rb +160 -78
  17. data/lib/rgl/bellman_ford.rb +115 -0
  18. data/lib/rgl/bidirectional.rb +17 -10
  19. data/lib/rgl/bipartite.rb +87 -0
  20. data/lib/rgl/condensation.rb +13 -4
  21. data/lib/rgl/connected_components.rb +38 -30
  22. data/lib/rgl/dijkstra.rb +158 -0
  23. data/lib/rgl/dijkstra_visitor.rb +42 -0
  24. data/lib/rgl/dot.rb +40 -32
  25. data/lib/rgl/edge_properties_map.rb +55 -0
  26. data/lib/rgl/edmonds_karp.rb +136 -0
  27. data/lib/rgl/enumerable_ext.rb +4 -1
  28. data/lib/rgl/graph_iterator.rb +15 -0
  29. data/lib/rgl/graph_visitor.rb +138 -0
  30. data/lib/rgl/graph_wrapper.rb +15 -0
  31. data/lib/rgl/graphxml.rb +20 -10
  32. data/lib/rgl/implicit.rb +68 -66
  33. data/lib/rgl/mutable.rb +37 -31
  34. data/lib/rgl/path_builder.rb +40 -0
  35. data/lib/rgl/prim.rb +52 -0
  36. data/lib/rgl/rdot.rb +411 -374
  37. data/lib/rgl/topsort.rb +23 -16
  38. data/lib/rgl/transitivity.rb +29 -27
  39. data/lib/rgl/traversal.rb +67 -205
  40. data/rakelib/dep_graph.rake +4 -3
  41. data/test/bellman_ford_test.rb +187 -0
  42. data/test/bipartite_test.rb +47 -0
  43. data/test/components_test.rb +80 -0
  44. data/test/cycles_test.rb +60 -0
  45. data/test/dijkstra_test.rb +148 -0
  46. data/test/directed_graph_test.rb +118 -0
  47. data/test/dot_test.rb +26 -0
  48. data/test/edge_properties_map_test.rb +63 -0
  49. data/test/edge_test.rb +35 -0
  50. data/test/edmonds_karp_test.rb +105 -0
  51. data/{tests/TestGraph.rb → test/graph_test.rb} +6 -6
  52. data/test/graph_xml_test.rb +57 -0
  53. data/test/implicit_test.rb +53 -0
  54. data/test/prim_test.rb +98 -0
  55. data/{tests/TestRdot.rb → test/rdot_test.rb} +309 -308
  56. data/{tests → test}/test_helper.rb +4 -1
  57. data/{tests/TestTransitivity.rb → test/transitivity_test.rb} +43 -43
  58. data/test/traversal_test.rb +221 -0
  59. data/test/undirected_graph_test.rb +103 -0
  60. metadata +226 -145
  61. data/examples/example.jpg +0 -0
  62. data/examples/module_graph.jpg +0 -0
  63. data/install.rb +0 -49
  64. data/tests/TestComponents.rb +0 -65
  65. data/tests/TestCycles.rb +0 -61
  66. data/tests/TestDirectedGraph.rb +0 -125
  67. data/tests/TestDot.rb +0 -18
  68. data/tests/TestEdge.rb +0 -34
  69. data/tests/TestGraphXML.rb +0 -57
  70. data/tests/TestImplicit.rb +0 -52
  71. data/tests/TestTraversal.rb +0 -220
  72. data/tests/TestUnDirectedGraph.rb +0 -102
@@ -0,0 +1,98 @@
1
+ require 'test_helper'
2
+
3
+ require 'rgl/prim'
4
+ require 'rgl/adjacency'
5
+
6
+ include RGL
7
+
8
+ class TestPrim < Test::Unit::TestCase
9
+
10
+ def setup
11
+ @graph = AdjacencyGraph[1,2, 1,3, 2,3, 2,4, 3,4]
12
+
13
+ @edge_weights = {
14
+ [1, 2] => 10,
15
+ [1, 3] => 1,
16
+ [2, 3] => 1,
17
+ [2, 4] => 1,
18
+ [3, 4] => 10
19
+ }
20
+
21
+ @edge_weights_lambda = lambda { |edge| @edge_weights[edge] }
22
+ end
23
+
24
+ def test_minimum_spanning_tree
25
+ assert(minimum_spanning_tree.is_a?(AdjacencyGraph))
26
+ end
27
+
28
+ def test_minimum_spanning_tree_edges
29
+ assert_equal([[1, 3], [2, 3], [2, 4]], minimum_spanning_tree_edges)
30
+ end
31
+
32
+ def test_minimum_spanning_tree_for_disconnected_graph
33
+ @graph.add_edge(5, 6)
34
+ @graph.add_edge(6, 7)
35
+ @edge_weights.merge!([5, 6] => 1, [6, 7] => 2)
36
+
37
+ assert_equal([[1, 3], [2, 3], [2, 4]], minimum_spanning_tree_edges(@edge_weights, 1))
38
+ assert_equal([[5, 6], [6, 7]], minimum_spanning_tree_edges(@edge_weights, 5))
39
+ end
40
+
41
+ def test_visitor
42
+ visitor = DijkstraVisitor.new(@graph)
43
+
44
+ events = []
45
+
46
+ %w[examine_vertex examine_edge edge_relaxed edge_not_relaxed finish_vertex].each do |event|
47
+ visitor.send("set_#{event}_event_handler") { |*args| events << { event.to_sym => args } }
48
+ end
49
+
50
+ @graph.prim_minimum_spanning_tree(@edge_weights, 1, visitor)
51
+
52
+ assert_equal(
53
+ [
54
+ { :examine_vertex => [1] },
55
+ { :examine_edge => [1, 2] },
56
+ { :edge_relaxed => [1, 2] },
57
+ { :examine_edge => [1, 3] },
58
+ { :edge_relaxed => [1, 3] },
59
+ { :finish_vertex => [1] },
60
+ { :examine_vertex => [3] },
61
+ { :examine_edge => [3, 2] },
62
+ { :edge_relaxed => [3, 2] },
63
+ { :examine_edge => [3, 4] },
64
+ { :edge_relaxed => [3, 4] },
65
+ { :finish_vertex => [3] },
66
+ { :examine_vertex => [2] },
67
+ { :examine_edge => [2, 4] },
68
+ { :edge_relaxed => [2, 4] },
69
+ { :finish_vertex => [2] },
70
+ { :examine_vertex => [4] },
71
+ { :finish_vertex => [4] },
72
+ ],
73
+ events
74
+ )
75
+ end
76
+
77
+ def test_negative_weights
78
+ @edge_weights[[1, 3]] = -2
79
+ @edge_weights[[2, 3]] = -2
80
+
81
+ assert_equal([[1, 3], [2, 3], [2, 4]], minimum_spanning_tree_edges)
82
+ end
83
+
84
+ private
85
+
86
+ def minimum_spanning_tree_edges(edge_weights = @edge_weights, start_vertex = nil)
87
+ sorted_edges(@graph.prim_minimum_spanning_tree(edge_weights, start_vertex))
88
+ end
89
+
90
+ def minimum_spanning_tree(edge_weights = @edge_weights)
91
+ @graph.prim_minimum_spanning_tree(edge_weights)
92
+ end
93
+
94
+ def sorted_edges(graph)
95
+ graph.edges.map { |e| [e.source, e.target].sort }.sort
96
+ end
97
+
98
+ end
@@ -1,4 +1,5 @@
1
- require 'test/unit'
1
+ require 'test_helper'
2
+
2
3
  require 'rgl/rdot'
3
4
 
4
5
  include RGL
@@ -44,7 +45,7 @@ class TestDotPort < Test::Unit::TestCase
44
45
  end
45
46
 
46
47
  def test_name_label_and_nested_ports
47
- port = DOT::Port.new('test_name', 'test_label')
48
+ port = DOT::Port.new('test_name', 'test_label')
48
49
  port.ports = [DOT::Port.new(nil, 'a'), DOT::Port.new(nil, 'b')]
49
50
  assert_equal('{a | b}', port.to_s)
50
51
  end
@@ -55,51 +56,51 @@ class TestDotNode < Test::Unit::TestCase
55
56
 
56
57
  def test_no_name
57
58
  node = DOT::Node.new()
58
- dot = node.to_s
59
+ dot = node.to_s
59
60
  assert_nil(dot)
60
61
  end
61
62
 
62
63
  # bug 16125
63
64
  def test_1prop_0comma
64
- node = DOT::Node.new({"label"=>"the_label"})
65
- dot = node.to_s
65
+ node = DOT::Node.new({ "label" => "the_label" })
66
+ dot = node.to_s
66
67
  assert_no_match(dot, /,/)
67
68
  end
68
69
 
69
70
  def test_2prop_1comma
70
- node = DOT::Node.new({"label"=>"the_label", "shape"=>"ellipse"})
71
- dot = node.to_s
71
+ node = DOT::Node.new({ "label" => "the_label", "shape" => "ellipse" })
72
+ dot = node.to_s
72
73
  assert_match(dot, /\[[^,]*,[^,]*\]/)
73
74
  end
74
75
 
75
76
  def test_name_without_label
76
- node = DOT::Node.new({"name"=>"test_name"})
77
- dot = node.to_s
77
+ node = DOT::Node.new({ "name" => "test_name" })
78
+ dot = node.to_s
78
79
  assert_no_match(dot, /label/)
79
80
  end
80
81
 
81
82
  def test_no_label
82
- node = DOT::Node.new({"shape"=>"ellipse"})
83
- dot = node.to_s
83
+ node = DOT::Node.new({ "shape" => "ellipse" })
84
+ dot = node.to_s
84
85
  assert_no_match(dot, /label/)
85
86
  end
86
87
 
87
88
  def test_Mrecord_no_label_no_ports
88
- node = DOT::Node.new({"name" => "test_name", "shape"=>"Mrecord"})
89
- dot = node.to_s
89
+ node = DOT::Node.new({ "name" => "test_name", "shape" => "Mrecord" })
90
+ dot = node.to_s
90
91
  assert_match(dot, /shape\s*=\s*Mrecord/)
91
92
  assert_no_match(dot, /label/)
92
93
  end
93
94
 
94
95
  def test_Mrecord_label_no_ports
95
- node = DOT::Node.new({"name" => "test_name", "label" => "test_label", "shape"=>"Mrecord"})
96
- dot = node.to_s
96
+ node = DOT::Node.new({ "name" => "test_name", "label" => "test_label", "shape" => "Mrecord" })
97
+ dot = node.to_s
97
98
  assert_match(dot, /shape\s*=\s*Mrecord/)
98
99
  assert_match(dot, /label\s*=\s*test_label/)
99
100
  end
100
101
 
101
102
  def test_Mrecord_label_with_ports
102
- node = DOT::Node.new({"name" => "test_name", "label" => "test_label", "shape"=>"Mrecord"})
103
+ node = DOT::Node.new({ "name" => "test_name", "label" => "test_label", "shape" => "Mrecord" })
103
104
  node.ports << DOT::Port.new(nil, "a")
104
105
  node.ports << DOT::Port.new(nil, "b")
105
106
  dot = node.to_s
@@ -108,7 +109,7 @@ class TestDotNode < Test::Unit::TestCase
108
109
  end
109
110
 
110
111
  def test_Mrecord_no_label_with_ports
111
- node = DOT::Node.new({"name" => "test_name", "shape"=>"Mrecord"})
112
+ node = DOT::Node.new({ "name" => "test_name", "shape" => "Mrecord" })
112
113
  node.ports << DOT::Port.new(nil, "a")
113
114
  node.ports << DOT::Port.new(nil, "b")
114
115
  dot = node.to_s
@@ -117,21 +118,21 @@ class TestDotNode < Test::Unit::TestCase
117
118
  end
118
119
 
119
120
  def test_record_no_label_no_ports
120
- node = DOT::Node.new({"name" => "test_name", "shape"=>"record"})
121
- dot = node.to_s
121
+ node = DOT::Node.new({ "name" => "test_name", "shape" => "record" })
122
+ dot = node.to_s
122
123
  assert_match(dot, /shape\s*=\s*record/)
123
124
  assert_no_match(dot, /label/)
124
125
  end
125
126
 
126
127
  def test_record_label_no_ports
127
- node = DOT::Node.new({"name" => "test_name", "label" => "test_label", "shape"=>"record"})
128
- dot = node.to_s
128
+ node = DOT::Node.new({ "name" => "test_name", "label" => "test_label", "shape" => "record" })
129
+ dot = node.to_s
129
130
  assert_match(dot, /shape\s*=\s*record/)
130
131
  assert_match(dot, /label\s*=\s*test_label/)
131
132
  end
132
133
 
133
134
  def test_record_label_with_ports
134
- node = DOT::Node.new({"name" => "test_name", "label" => "test_label", "shape"=>"record"})
135
+ node = DOT::Node.new({ "name" => "test_name", "label" => "test_label", "shape" => "record" })
135
136
  node.ports << DOT::Port.new(nil, "a")
136
137
  node.ports << DOT::Port.new(nil, "b")
137
138
  dot = node.to_s
@@ -140,7 +141,7 @@ class TestDotNode < Test::Unit::TestCase
140
141
  end
141
142
 
142
143
  def test_record_no_label_with_ports
143
- node = DOT::Node.new({"name" => "test_name", "shape"=>"record"})
144
+ node = DOT::Node.new({ "name" => "test_name", "shape" => "record" })
144
145
  node.ports << DOT::Port.new(nil, "a")
145
146
  node.ports << DOT::Port.new(nil, "b")
146
147
  dot = node.to_s
@@ -149,7 +150,7 @@ class TestDotNode < Test::Unit::TestCase
149
150
  end
150
151
 
151
152
  def test_no_shape_no_label_no_ports
152
- node = DOT::Node.new({"name" => "test_name"})
153
+ node = DOT::Node.new({ "name" => "test_name" })
153
154
  node.ports << DOT::Port.new(nil, "a")
154
155
  node.ports << DOT::Port.new(nil, "b")
155
156
  dot = node.to_s
@@ -158,7 +159,7 @@ class TestDotNode < Test::Unit::TestCase
158
159
  end
159
160
 
160
161
  def test_no_shape_no_label_with_ports
161
- node = DOT::Node.new({"name" => "test_name"})
162
+ node = DOT::Node.new({ "name" => "test_name" })
162
163
  node.ports << DOT::Port.new(nil, "a")
163
164
  node.ports << DOT::Port.new(nil, "b")
164
165
  dot = node.to_s
@@ -167,140 +168,140 @@ class TestDotNode < Test::Unit::TestCase
167
168
  end
168
169
 
169
170
  def test_name_quoting
170
- node = DOT::Node.new({"name" => "Name with spaces"})
171
- dot = node.to_s
171
+ node = DOT::Node.new({ "name" => "Name with spaces" })
172
+ dot = node.to_s
172
173
  assert_match(dot, /^"Name with spaces"$/)
173
174
 
174
- node = DOT::Node.new({"name" => "Name with \"quotes\""})
175
- dot = node.to_s
175
+ node = DOT::Node.new({ "name" => "Name with \"quotes\"" })
176
+ dot = node.to_s
176
177
  assert_match(dot, /^"Name with \\"quotes\\""$/)
177
178
 
178
- node = DOT::Node.new({"name" => "Name with \\backslashes\\"})
179
- dot = node.to_s
179
+ node = DOT::Node.new({ "name" => "Name with \\backslashes\\" })
180
+ dot = node.to_s
180
181
  assert_match(dot, /^"Name with \\\\backslashes\\\\"$/)
181
182
 
182
- node = DOT::Node.new({"name" => "Name with\nembedded\nnewlines"})
183
- dot = node.to_s
183
+ node = DOT::Node.new({ "name" => "Name with\nembedded\nnewlines" })
184
+ dot = node.to_s
184
185
  assert_match(dot, /\A.*"Name with\nembedded\nnewlines".*\Z/m)
185
186
 
186
- node = DOT::Node.new({"name" => "Name_with_trailing_newline\n"})
187
- dot = node.to_s
187
+ node = DOT::Node.new({ "name" => "Name_with_trailing_newline\n" })
188
+ dot = node.to_s
188
189
  assert_match(dot, /\A.*"Name_with_trailing_newline\n".*\Z/m)
189
190
 
190
- node = DOT::Node.new({"name" => "123.456"})
191
- dot = node.to_s
191
+ node = DOT::Node.new({ "name" => "123.456" })
192
+ dot = node.to_s
192
193
  assert_match(dot, /^123.456$/)
193
194
 
194
- node = DOT::Node.new({"name" => ".456"})
195
- dot = node.to_s
195
+ node = DOT::Node.new({ "name" => ".456" })
196
+ dot = node.to_s
196
197
  assert_match(dot, /^.456$/)
197
198
 
198
- node = DOT::Node.new({"name" => "-.456"})
199
- dot = node.to_s
199
+ node = DOT::Node.new({ "name" => "-.456" })
200
+ dot = node.to_s
200
201
  assert_match(dot, /^-.456$/)
201
202
 
202
- node = DOT::Node.new({"name" => "-456"})
203
- dot = node.to_s
203
+ node = DOT::Node.new({ "name" => "-456" })
204
+ dot = node.to_s
204
205
  assert_match(dot, /^-456$/)
205
206
 
206
- node = DOT::Node.new({"name" => "-123.456"})
207
- dot = node.to_s
207
+ node = DOT::Node.new({ "name" => "-123.456" })
208
+ dot = node.to_s
208
209
  assert_match(dot, /^-123.456$/)
209
210
 
210
- node = DOT::Node.new({"name" => "<html><head><title>test</title></head>\n<body>text</body></html>"})
211
- dot = node.to_s
211
+ node = DOT::Node.new({ "name" => "<html><head><title>test</title></head>\n<body>text</body></html>" })
212
+ dot = node.to_s
212
213
  assert_match(dot, /^<html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html>$/)
213
214
  end
214
215
 
215
216
  def test_label_quoting
216
- node = DOT::Node.new({"name" => "test_name", "label" => "Label with spaces"})
217
- dot = node.to_s
217
+ node = DOT::Node.new({ "name" => "test_name", "label" => "Label with spaces" })
218
+ dot = node.to_s
218
219
  assert_match(dot, /label\s*=\s*"Label with spaces"/)
219
220
 
220
- node = DOT::Node.new({"name" => "test_name", "label" => "Label with \"quotes\""})
221
- dot = node.to_s
221
+ node = DOT::Node.new({ "name" => "test_name", "label" => "Label with \"quotes\"" })
222
+ dot = node.to_s
222
223
  assert_match(dot, /label\s*=\s*"Label with \\"quotes\\""/)
223
224
 
224
- node = DOT::Node.new({"name" => "test_name", "label" => "Label with \\backslashes\\"})
225
- dot = node.to_s
225
+ node = DOT::Node.new({ "name" => "test_name", "label" => "Label with \\backslashes\\" })
226
+ dot = node.to_s
226
227
  assert_match(dot, /label\s*=\s*"Label with \\\\backslashes\\\\"/)
227
228
 
228
- node = DOT::Node.new({"name" => "test_name", "label" => "Label with\nembedded\nnewlines"})
229
- dot = node.to_s
229
+ node = DOT::Node.new({ "name" => "test_name", "label" => "Label with\nembedded\nnewlines" })
230
+ dot = node.to_s
230
231
  assert_match(dot, /label\s*=\s*"Label with\\nembedded\\nnewlines"/)
231
232
 
232
- node = DOT::Node.new({"name" => "test_name", "label" => "Label_with_a_trailing_newline\n"})
233
- dot = node.to_s
233
+ node = DOT::Node.new({ "name" => "test_name", "label" => "Label_with_a_trailing_newline\n" })
234
+ dot = node.to_s
234
235
  assert_match(dot, /label\s*=\s*"Label_with_a_trailing_newline\\n"/)
235
236
 
236
- node = DOT::Node.new({"name" => "test_name", "label" => "Left justified label\\l"})
237
- dot = node.to_s
237
+ node = DOT::Node.new({ "name" => "test_name", "label" => "Left justified label\\l" })
238
+ dot = node.to_s
238
239
  assert_match(dot, /label\s*=\s*"Left justified label\\l"/)
239
240
 
240
- node = DOT::Node.new({"name" => "test_name", "label" => "Right justified label\\r"})
241
- dot = node.to_s
241
+ node = DOT::Node.new({ "name" => "test_name", "label" => "Right justified label\\r" })
242
+ dot = node.to_s
242
243
  assert_match(dot, /label\s*=\s*"Right justified label\\r"/)
243
244
 
244
- node = DOT::Node.new({"name" => "test_name", "label" => "123.456"})
245
- dot = node.to_s
245
+ node = DOT::Node.new({ "name" => "test_name", "label" => "123.456" })
246
+ dot = node.to_s
246
247
  assert_match(dot, /label\s*=\s*123.456/)
247
248
 
248
- node = DOT::Node.new({"name" => "test_name", "label" => ".456"})
249
- dot = node.to_s
249
+ node = DOT::Node.new({ "name" => "test_name", "label" => ".456" })
250
+ dot = node.to_s
250
251
  assert_match(dot, /label\s*=\s*.456/)
251
252
 
252
- node = DOT::Node.new({"name" => "test_name", "label" => "-.456"})
253
- dot = node.to_s
253
+ node = DOT::Node.new({ "name" => "test_name", "label" => "-.456" })
254
+ dot = node.to_s
254
255
  assert_match(dot, /label\s*=\s*-.456/)
255
256
 
256
- node = DOT::Node.new({"name" => "test_name", "label" => "-456"})
257
- dot = node.to_s
257
+ node = DOT::Node.new({ "name" => "test_name", "label" => "-456" })
258
+ dot = node.to_s
258
259
  assert_match(dot, /label\s*=\s*-456/)
259
260
 
260
- node = DOT::Node.new({"name" => "test_name", "label" => "-123.456"})
261
- dot = node.to_s
261
+ node = DOT::Node.new({ "name" => "test_name", "label" => "-123.456" })
262
+ dot = node.to_s
262
263
  assert_match(dot, /label\s*=\s*-123.456/)
263
264
 
264
- node = DOT::Node.new({"name" => "test_name", "label" => "<html><head><title>test</title></head>\n<body>text</body></html>"})
265
- dot = node.to_s
265
+ node = DOT::Node.new({ "name" => "test_name", "label" => "<html><head><title>test</title></head>\n<body>text</body></html>" })
266
+ dot = node.to_s
266
267
  assert_match(dot, /label\s*=\s*<html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html>/)
267
268
  end
268
269
 
269
270
  def test_option_quoting
270
- node = DOT::Node.new({"name" => "test_name", "comment" => "Comment with spaces"})
271
- dot = node.to_s
271
+ node = DOT::Node.new({ "name" => "test_name", "comment" => "Comment with spaces" })
272
+ dot = node.to_s
272
273
  assert_match(dot, /comment\s*=\s*"Comment with spaces"/)
273
274
 
274
- node = DOT::Node.new({"name" => "test_name", "comment" => "Comment with \"quotes\""})
275
- dot = node.to_s
275
+ node = DOT::Node.new({ "name" => "test_name", "comment" => "Comment with \"quotes\"" })
276
+ dot = node.to_s
276
277
  assert_match(dot, /comment\s*=\s*"Comment with \\"quotes\\""/)
277
278
 
278
- node = DOT::Node.new({"name" => "test_name", "comment" => "Comment with \\backslashes\\"})
279
- dot = node.to_s
279
+ node = DOT::Node.new({ "name" => "test_name", "comment" => "Comment with \\backslashes\\" })
280
+ dot = node.to_s
280
281
  assert_match(dot, /comment\s*=\s*"Comment with \\\\backslashes\\\\"/)
281
282
 
282
- node = DOT::Node.new({"name" => "test_name", "comment" => "123.456"})
283
- dot = node.to_s
283
+ node = DOT::Node.new({ "name" => "test_name", "comment" => "123.456" })
284
+ dot = node.to_s
284
285
  assert_match(dot, /comment\s*=\s*123.456/)
285
286
 
286
- node = DOT::Node.new({"name" => "test_name", "comment" => ".456"})
287
- dot = node.to_s
287
+ node = DOT::Node.new({ "name" => "test_name", "comment" => ".456" })
288
+ dot = node.to_s
288
289
  assert_match(dot, /comment\s*=\s*.456/)
289
290
 
290
- node = DOT::Node.new({"name" => "test_name", "comment" => "-.456"})
291
- dot = node.to_s
291
+ node = DOT::Node.new({ "name" => "test_name", "comment" => "-.456" })
292
+ dot = node.to_s
292
293
  assert_match(dot, /comment\s*=\s*-.456/)
293
294
 
294
- node = DOT::Node.new({"name" => "test_name", "comment" => "-456"})
295
- dot = node.to_s
295
+ node = DOT::Node.new({ "name" => "test_name", "comment" => "-456" })
296
+ dot = node.to_s
296
297
  assert_match(dot, /comment\s*=\s*-456/)
297
298
 
298
- node = DOT::Node.new({"name" => "test_name", "comment" => "-123.456"})
299
- dot = node.to_s
299
+ node = DOT::Node.new({ "name" => "test_name", "comment" => "-123.456" })
300
+ dot = node.to_s
300
301
  assert_match(dot, /comment\s*=\s*-123.456/)
301
302
 
302
- node = DOT::Node.new({"name" => "test_name", "comment" => "<html><head><title>test</title></head>\n<body>text</body></html>"})
303
- dot = node.to_s
303
+ node = DOT::Node.new({ "name" => "test_name", "comment" => "<html><head><title>test</title></head>\n<body>text</body></html>" })
304
+ dot = node.to_s
304
305
  assert_match(dot, /comment\s*=\s*<html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html>/)
305
306
  end
306
307
  end
@@ -309,26 +310,26 @@ end
309
310
  class TestDotEdge < Test::Unit::TestCase
310
311
 
311
312
  def test_0prop
312
- edge = DOT::Edge.new({'from' => 'a', 'to' => 'b'})
313
- dot = edge.to_s
313
+ edge = DOT::Edge.new({ 'from' => 'a', 'to' => 'b' })
314
+ dot = edge.to_s
314
315
  assert_equal('a -- b', dot)
315
316
  end
316
317
 
317
318
  def test_1prop_0comma
318
- edge = DOT::Edge.new({"label"=>"the_label"})
319
- dot = edge.to_s
319
+ edge = DOT::Edge.new({ "label" => "the_label" })
320
+ dot = edge.to_s
320
321
  assert_no_match(dot, /,/)
321
322
  end
322
323
 
323
324
  def test_2prop_1comma
324
- edge = DOT::Edge.new({"label"=>"the_label", "weight"=>"2"})
325
- dot = edge.to_s
325
+ edge = DOT::Edge.new({ "label" => "the_label", "weight" => "2" })
326
+ dot = edge.to_s
326
327
  assert_match(dot, /\[[^,]*,[^,]*\]/)
327
328
  end
328
329
 
329
330
  def test_no_label
330
- edge = DOT::Edge.new({"weight"=>"2"})
331
- dot = edge.to_s
331
+ edge = DOT::Edge.new({ "weight" => "2" })
332
+ dot = edge.to_s
332
333
  assert_no_match(dot, /label/)
333
334
  end
334
335
  end
@@ -337,26 +338,26 @@ end
337
338
  class TestDotDirectedEdge < Test::Unit::TestCase
338
339
 
339
340
  def test_0prop
340
- edge = DOT::DirectedEdge.new({'from' => 'a', 'to' => 'b'})
341
- dot = edge.to_s
341
+ edge = DOT::DirectedEdge.new({ 'from' => 'a', 'to' => 'b' })
342
+ dot = edge.to_s
342
343
  assert_equal('a -> b', dot)
343
344
  end
344
345
 
345
346
  def test_1prop_0comma
346
- edge = DOT::DirectedEdge.new({"label"=>"the_label"})
347
- dot = edge.to_s
347
+ edge = DOT::DirectedEdge.new({ "label" => "the_label" })
348
+ dot = edge.to_s
348
349
  assert_no_match(dot, /,/)
349
350
  end
350
351
 
351
352
  def test_2prop_1comma
352
- edge = DOT::DirectedEdge.new({"label"=>"the_label", "weight"=>"2"})
353
- dot = edge.to_s
353
+ edge = DOT::DirectedEdge.new({ "label" => "the_label", "weight" => "2" })
354
+ dot = edge.to_s
354
355
  assert_match(dot, /\[[^,]*,[^,]*\]/)
355
356
  end
356
357
 
357
358
  def test_no_label
358
- edge = DOT::DirectedEdge.new({"weight"=>"2"})
359
- dot = edge.to_s
359
+ edge = DOT::DirectedEdge.new({ "weight" => "2" })
360
+ dot = edge.to_s
360
361
  assert_no_match(dot, /label/)
361
362
  end
362
363
  end
@@ -365,145 +366,145 @@ end
365
366
  class TestDotGraph < Test::Unit::TestCase
366
367
  def test_graph_statement
367
368
  graph = DOT::Graph.new()
368
- dot = graph.to_s
369
+ dot = graph.to_s
369
370
  assert_match(dot, /^\s*graph /)
370
371
  end
371
372
 
372
373
  def test_name_quoting
373
- node = DOT::Graph.new({"name" => "Name with spaces"})
374
- dot = node.to_s
374
+ node = DOT::Graph.new({ "name" => "Name with spaces" })
375
+ dot = node.to_s
375
376
  assert_match(dot, /^graph "Name with spaces" \{$/)
376
377
 
377
- node = DOT::Graph.new({"name" => "Name with \"quotes\""})
378
- dot = node.to_s
378
+ node = DOT::Graph.new({ "name" => "Name with \"quotes\"" })
379
+ dot = node.to_s
379
380
  assert_match(dot, /^graph "Name with \\"quotes\\"" \{$/)
380
381
 
381
- node = DOT::Graph.new({"name" => "Name with \\backslashes\\"})
382
- dot = node.to_s
382
+ node = DOT::Graph.new({ "name" => "Name with \\backslashes\\" })
383
+ dot = node.to_s
383
384
  assert_match(dot, /^graph "Name with \\\\backslashes\\\\" \{$/)
384
385
 
385
- node = DOT::Graph.new({"name" => "Name with\nembedded\nnewlines"})
386
- dot = node.to_s
386
+ node = DOT::Graph.new({ "name" => "Name with\nembedded\nnewlines" })
387
+ dot = node.to_s
387
388
  assert_match(dot, /\A.*"Name with\nembedded\nnewlines".*\Z/m)
388
389
 
389
- node = DOT::Graph.new({"name" => "Name_with_trailing_newline\n"})
390
- dot = node.to_s
390
+ node = DOT::Graph.new({ "name" => "Name_with_trailing_newline\n" })
391
+ dot = node.to_s
391
392
  assert_match(dot, /\A.*"Name_with_trailing_newline\n".*\Z/m)
392
393
 
393
- node = DOT::Graph.new({"name" => "123.456"})
394
- dot = node.to_s
394
+ node = DOT::Graph.new({ "name" => "123.456" })
395
+ dot = node.to_s
395
396
  assert_match(dot, /^graph 123.456 \{$/)
396
397
 
397
- node = DOT::Graph.new({"name" => ".456"})
398
- dot = node.to_s
398
+ node = DOT::Graph.new({ "name" => ".456" })
399
+ dot = node.to_s
399
400
  assert_match(dot, /^graph .456 \{$/)
400
401
 
401
- node = DOT::Graph.new({"name" => "-.456"})
402
- dot = node.to_s
402
+ node = DOT::Graph.new({ "name" => "-.456" })
403
+ dot = node.to_s
403
404
  assert_match(dot, /^graph -.456 \{$/)
404
405
 
405
- node = DOT::Graph.new({"name" => "-456"})
406
- dot = node.to_s
406
+ node = DOT::Graph.new({ "name" => "-456" })
407
+ dot = node.to_s
407
408
  assert_match(dot, /^graph -456 \{$/)
408
409
 
409
- node = DOT::Graph.new({"name" => "-123.456"})
410
- dot = node.to_s
410
+ node = DOT::Graph.new({ "name" => "-123.456" })
411
+ dot = node.to_s
411
412
  assert_match(dot, /^graph -123.456 \{$/)
412
413
 
413
- node = DOT::Graph.new({"name" => "<html><head><title>test</title></head>\n<body>text</body></html>"})
414
- dot = node.to_s
414
+ node = DOT::Graph.new({ "name" => "<html><head><title>test</title></head>\n<body>text</body></html>" })
415
+ dot = node.to_s
415
416
  assert_match(dot, /^graph <html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html> \{$/)
416
417
  end
417
418
 
418
419
  def test_label_quoting
419
- node = DOT::Graph.new({"name" => "test_name", "label" => "Label with spaces"})
420
- dot = node.to_s
420
+ node = DOT::Graph.new({ "name" => "test_name", "label" => "Label with spaces" })
421
+ dot = node.to_s
421
422
  assert_match(dot, /label\s*=\s*"Label with spaces"/)
422
423
 
423
- node = DOT::Graph.new({"name" => "test_name", "label" => "Label with \"quotes\""})
424
- dot = node.to_s
424
+ node = DOT::Graph.new({ "name" => "test_name", "label" => "Label with \"quotes\"" })
425
+ dot = node.to_s
425
426
  assert_match(dot, /label\s*=\s*"Label with \\"quotes\\""/)
426
427
 
427
- node = DOT::Graph.new({"name" => "test_name", "label" => "Label with \\backslashes\\"})
428
- dot = node.to_s
428
+ node = DOT::Graph.new({ "name" => "test_name", "label" => "Label with \\backslashes\\" })
429
+ dot = node.to_s
429
430
  assert_match(dot, /label\s*=\s*"Label with \\\\backslashes\\\\"/)
430
431
 
431
- node = DOT::Graph.new({"name" => "test_name", "label" => "Label with\nembedded\nnewlines"})
432
- dot = node.to_s
432
+ node = DOT::Graph.new({ "name" => "test_name", "label" => "Label with\nembedded\nnewlines" })
433
+ dot = node.to_s
433
434
  assert_match(dot, /label\s*=\s*"Label with\\nembedded\\nnewlines"/)
434
435
 
435
- node = DOT::Graph.new({"name" => "test_name", "label" => "Label_with_a_trailing_newline\n"})
436
- dot = node.to_s
436
+ node = DOT::Graph.new({ "name" => "test_name", "label" => "Label_with_a_trailing_newline\n" })
437
+ dot = node.to_s
437
438
  assert_match(dot, /label\s*=\s*"Label_with_a_trailing_newline\\n"/)
438
439
 
439
- node = DOT::Graph.new({"name" => "test_name", "label" => "Left justified label\\l"})
440
- dot = node.to_s
440
+ node = DOT::Graph.new({ "name" => "test_name", "label" => "Left justified label\\l" })
441
+ dot = node.to_s
441
442
  assert_match(dot, /label\s*=\s*"Left justified label\\l"/)
442
443
 
443
- node = DOT::Graph.new({"name" => "test_name", "label" => "Right justified label\\r"})
444
- dot = node.to_s
444
+ node = DOT::Graph.new({ "name" => "test_name", "label" => "Right justified label\\r" })
445
+ dot = node.to_s
445
446
  assert_match(dot, /label\s*=\s*"Right justified label\\r"/)
446
447
 
447
- node = DOT::Graph.new({"name" => "test_name", "label" => "123.456"})
448
- dot = node.to_s
448
+ node = DOT::Graph.new({ "name" => "test_name", "label" => "123.456" })
449
+ dot = node.to_s
449
450
  assert_match(dot, /label\s*=\s*123.456/)
450
451
 
451
- node = DOT::Graph.new({"name" => "test_name", "label" => ".456"})
452
- dot = node.to_s
452
+ node = DOT::Graph.new({ "name" => "test_name", "label" => ".456" })
453
+ dot = node.to_s
453
454
  assert_match(dot, /label\s*=\s*.456/)
454
455
 
455
- node = DOT::Graph.new({"name" => "test_name", "label" => "-.456"})
456
- dot = node.to_s
456
+ node = DOT::Graph.new({ "name" => "test_name", "label" => "-.456" })
457
+ dot = node.to_s
457
458
  assert_match(dot, /label\s*=\s*-.456/)
458
459
 
459
- node = DOT::Graph.new({"name" => "test_name", "label" => "-456"})
460
- dot = node.to_s
460
+ node = DOT::Graph.new({ "name" => "test_name", "label" => "-456" })
461
+ dot = node.to_s
461
462
  assert_match(dot, /label\s*=\s*-456/)
462
463
 
463
- node = DOT::Graph.new({"name" => "test_name", "label" => "-123.456"})
464
- dot = node.to_s
464
+ node = DOT::Graph.new({ "name" => "test_name", "label" => "-123.456" })
465
+ dot = node.to_s
465
466
  assert_match(dot, /label\s*=\s*-123.456/)
466
467
 
467
- node = DOT::Graph.new({"name" => "test_name", "label" => "<html><head><title>test</title></head>\n<body>text</body></html>"})
468
- dot = node.to_s
468
+ node = DOT::Graph.new({ "name" => "test_name", "label" => "<html><head><title>test</title></head>\n<body>text</body></html>" })
469
+ dot = node.to_s
469
470
  assert_match(dot, /label\s*=\s*<html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html>/)
470
471
  end
471
472
 
472
473
  def test_option_quoting
473
- node = DOT::Graph.new({"name" => "test_name", "comment" => "Comment with spaces"})
474
- dot = node.to_s
474
+ node = DOT::Graph.new({ "name" => "test_name", "comment" => "Comment with spaces" })
475
+ dot = node.to_s
475
476
  assert_match(dot, /comment\s*=\s*"Comment with spaces"/)
476
477
 
477
- node = DOT::Graph.new({"name" => "test_name", "comment" => "Comment with \"quotes\""})
478
- dot = node.to_s
478
+ node = DOT::Graph.new({ "name" => "test_name", "comment" => "Comment with \"quotes\"" })
479
+ dot = node.to_s
479
480
  assert_match(dot, /comment\s*=\s*"Comment with \\"quotes\\""/)
480
481
 
481
- node = DOT::Graph.new({"name" => "test_name", "comment" => "Comment with \\backslashes\\"})
482
- dot = node.to_s
482
+ node = DOT::Graph.new({ "name" => "test_name", "comment" => "Comment with \\backslashes\\" })
483
+ dot = node.to_s
483
484
  assert_match(dot, /comment\s*=\s*"Comment with \\\\backslashes\\\\"/)
484
485
 
485
- node = DOT::Graph.new({"name" => "test_name", "comment" => "123.456"})
486
- dot = node.to_s
486
+ node = DOT::Graph.new({ "name" => "test_name", "comment" => "123.456" })
487
+ dot = node.to_s
487
488
  assert_match(dot, /comment\s*=\s*123.456/)
488
489
 
489
- node = DOT::Graph.new({"name" => "test_name", "comment" => ".456"})
490
- dot = node.to_s
490
+ node = DOT::Graph.new({ "name" => "test_name", "comment" => ".456" })
491
+ dot = node.to_s
491
492
  assert_match(dot, /comment\s*=\s*.456/)
492
493
 
493
- node = DOT::Graph.new({"name" => "test_name", "comment" => "-.456"})
494
- dot = node.to_s
494
+ node = DOT::Graph.new({ "name" => "test_name", "comment" => "-.456" })
495
+ dot = node.to_s
495
496
  assert_match(dot, /comment\s*=\s*-.456/)
496
497
 
497
- node = DOT::Graph.new({"name" => "test_name", "comment" => "-456"})
498
- dot = node.to_s
498
+ node = DOT::Graph.new({ "name" => "test_name", "comment" => "-456" })
499
+ dot = node.to_s
499
500
  assert_match(dot, /comment\s*=\s*-456/)
500
501
 
501
- node = DOT::Graph.new({"name" => "test_name", "comment" => "-123.456"})
502
- dot = node.to_s
502
+ node = DOT::Graph.new({ "name" => "test_name", "comment" => "-123.456" })
503
+ dot = node.to_s
503
504
  assert_match(dot, /comment\s*=\s*-123.456/)
504
505
 
505
- node = DOT::Graph.new({"name" => "test_name", "comment" => "<html><head><title>test</title></head>\n<body>text</body></html>"})
506
- dot = node.to_s
506
+ node = DOT::Graph.new({ "name" => "test_name", "comment" => "<html><head><title>test</title></head>\n<body>text</body></html>" })
507
+ dot = node.to_s
507
508
  assert_match(dot, /comment\s*=\s*<html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html>/)
508
509
  end
509
510
 
@@ -532,145 +533,145 @@ end
532
533
  class TestDotDigraph < Test::Unit::TestCase
533
534
  def test_digraph_statement
534
535
  digraph = DOT::Digraph.new()
535
- dot = digraph.to_s
536
+ dot = digraph.to_s
536
537
  assert_match(dot, /^\s*digraph /)
537
538
  end
538
539
 
539
540
  def test_name_quoting
540
- node = DOT::Digraph.new({"name" => "Name with spaces"})
541
- dot = node.to_s
541
+ node = DOT::Digraph.new({ "name" => "Name with spaces" })
542
+ dot = node.to_s
542
543
  assert_match(dot, /^digraph "Name with spaces" \{$/)
543
544
 
544
- node = DOT::Digraph.new({"name" => "Name with \"quotes\""})
545
- dot = node.to_s
545
+ node = DOT::Digraph.new({ "name" => "Name with \"quotes\"" })
546
+ dot = node.to_s
546
547
  assert_match(dot, /^digraph "Name with \\"quotes\\"" \{$/)
547
548
 
548
- node = DOT::Digraph.new({"name" => "Name with \\backslashes\\"})
549
- dot = node.to_s
549
+ node = DOT::Digraph.new({ "name" => "Name with \\backslashes\\" })
550
+ dot = node.to_s
550
551
  assert_match(dot, /^digraph "Name with \\\\backslashes\\\\" \{$/)
551
552
 
552
- node = DOT::Digraph.new({"name" => "Name with\nembedded\nnewlines"})
553
- dot = node.to_s
553
+ node = DOT::Digraph.new({ "name" => "Name with\nembedded\nnewlines" })
554
+ dot = node.to_s
554
555
  assert_match(dot, /\A.*"Name with\nembedded\nnewlines".*\Z/m)
555
556
 
556
- node = DOT::Digraph.new({"name" => "Name_with_trailing_newline\n"})
557
- dot = node.to_s
557
+ node = DOT::Digraph.new({ "name" => "Name_with_trailing_newline\n" })
558
+ dot = node.to_s
558
559
  assert_match(dot, /\A.*"Name_with_trailing_newline\n".*\Z/m)
559
560
 
560
- node = DOT::Digraph.new({"name" => "123.456"})
561
- dot = node.to_s
561
+ node = DOT::Digraph.new({ "name" => "123.456" })
562
+ dot = node.to_s
562
563
  assert_match(dot, /^digraph 123.456 \{$/)
563
564
 
564
- node = DOT::Digraph.new({"name" => ".456"})
565
- dot = node.to_s
565
+ node = DOT::Digraph.new({ "name" => ".456" })
566
+ dot = node.to_s
566
567
  assert_match(dot, /^digraph .456 \{$/)
567
568
 
568
- node = DOT::Digraph.new({"name" => "-.456"})
569
- dot = node.to_s
569
+ node = DOT::Digraph.new({ "name" => "-.456" })
570
+ dot = node.to_s
570
571
  assert_match(dot, /^digraph -.456 \{$/)
571
572
 
572
- node = DOT::Digraph.new({"name" => "-456"})
573
- dot = node.to_s
573
+ node = DOT::Digraph.new({ "name" => "-456" })
574
+ dot = node.to_s
574
575
  assert_match(dot, /^digraph -456 \{$/)
575
576
 
576
- node = DOT::Digraph.new({"name" => "-123.456"})
577
- dot = node.to_s
577
+ node = DOT::Digraph.new({ "name" => "-123.456" })
578
+ dot = node.to_s
578
579
  assert_match(dot, /^digraph -123.456 \{$/)
579
580
 
580
- node = DOT::Digraph.new({"name" => "<html><head><title>test</title></head>\n<body>text</body></html>"})
581
- dot = node.to_s
581
+ node = DOT::Digraph.new({ "name" => "<html><head><title>test</title></head>\n<body>text</body></html>" })
582
+ dot = node.to_s
582
583
  assert_match(dot, /^digraph <html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html> \{$/)
583
584
  end
584
585
 
585
586
  def test_label_quoting
586
- node = DOT::Digraph.new({"name" => "test_name", "label" => "Label with spaces"})
587
- dot = node.to_s
587
+ node = DOT::Digraph.new({ "name" => "test_name", "label" => "Label with spaces" })
588
+ dot = node.to_s
588
589
  assert_match(dot, /label\s*=\s*"Label with spaces"/)
589
590
 
590
- node = DOT::Digraph.new({"name" => "test_name", "label" => "Label with \"quotes\""})
591
- dot = node.to_s
591
+ node = DOT::Digraph.new({ "name" => "test_name", "label" => "Label with \"quotes\"" })
592
+ dot = node.to_s
592
593
  assert_match(dot, /label\s*=\s*"Label with \\"quotes\\""/)
593
594
 
594
- node = DOT::Digraph.new({"name" => "test_name", "label" => "Label with \\backslashes\\"})
595
- dot = node.to_s
595
+ node = DOT::Digraph.new({ "name" => "test_name", "label" => "Label with \\backslashes\\" })
596
+ dot = node.to_s
596
597
  assert_match(dot, /label\s*=\s*"Label with \\\\backslashes\\\\"/)
597
598
 
598
- node = DOT::Digraph.new({"name" => "test_name", "label" => "Label with\nembedded\nnewlines"})
599
- dot = node.to_s
599
+ node = DOT::Digraph.new({ "name" => "test_name", "label" => "Label with\nembedded\nnewlines" })
600
+ dot = node.to_s
600
601
  assert_match(dot, /label\s*=\s*"Label with\\nembedded\\nnewlines"/)
601
602
 
602
- node = DOT::Digraph.new({"name" => "test_name", "label" => "Label_with_a_trailing_newline\n"})
603
- dot = node.to_s
603
+ node = DOT::Digraph.new({ "name" => "test_name", "label" => "Label_with_a_trailing_newline\n" })
604
+ dot = node.to_s
604
605
  assert_match(dot, /label\s*=\s*"Label_with_a_trailing_newline\\n"/)
605
606
 
606
- node = DOT::Digraph.new({"name" => "test_name", "label" => "Left justified label\\l"})
607
- dot = node.to_s
607
+ node = DOT::Digraph.new({ "name" => "test_name", "label" => "Left justified label\\l" })
608
+ dot = node.to_s
608
609
  assert_match(dot, /label\s*=\s*"Left justified label\\l"/)
609
610
 
610
- node = DOT::Digraph.new({"name" => "test_name", "label" => "Right justified label\\r"})
611
- dot = node.to_s
611
+ node = DOT::Digraph.new({ "name" => "test_name", "label" => "Right justified label\\r" })
612
+ dot = node.to_s
612
613
  assert_match(dot, /label\s*=\s*"Right justified label\\r"/)
613
614
 
614
- node = DOT::Digraph.new({"name" => "test_name", "label" => "123.456"})
615
- dot = node.to_s
615
+ node = DOT::Digraph.new({ "name" => "test_name", "label" => "123.456" })
616
+ dot = node.to_s
616
617
  assert_match(dot, /label\s*=\s*123.456/)
617
618
 
618
- node = DOT::Digraph.new({"name" => "test_name", "label" => ".456"})
619
- dot = node.to_s
619
+ node = DOT::Digraph.new({ "name" => "test_name", "label" => ".456" })
620
+ dot = node.to_s
620
621
  assert_match(dot, /label\s*=\s*.456/)
621
622
 
622
- node = DOT::Digraph.new({"name" => "test_name", "label" => "-.456"})
623
- dot = node.to_s
623
+ node = DOT::Digraph.new({ "name" => "test_name", "label" => "-.456" })
624
+ dot = node.to_s
624
625
  assert_match(dot, /label\s*=\s*-.456/)
625
626
 
626
- node = DOT::Digraph.new({"name" => "test_name", "label" => "-456"})
627
- dot = node.to_s
627
+ node = DOT::Digraph.new({ "name" => "test_name", "label" => "-456" })
628
+ dot = node.to_s
628
629
  assert_match(dot, /label\s*=\s*-456/)
629
630
 
630
- node = DOT::Digraph.new({"name" => "test_name", "label" => "-123.456"})
631
- dot = node.to_s
631
+ node = DOT::Digraph.new({ "name" => "test_name", "label" => "-123.456" })
632
+ dot = node.to_s
632
633
  assert_match(dot, /label\s*=\s*-123.456/)
633
634
 
634
- node = DOT::Digraph.new({"name" => "test_name", "label" => "<html><head><title>test</title></head>\n<body>text</body></html>"})
635
- dot = node.to_s
635
+ node = DOT::Digraph.new({ "name" => "test_name", "label" => "<html><head><title>test</title></head>\n<body>text</body></html>" })
636
+ dot = node.to_s
636
637
  assert_match(dot, /label\s*=\s*<html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html>/)
637
638
  end
638
639
 
639
640
  def test_option_quoting
640
- node = DOT::Digraph.new({"name" => "test_name", "comment" => "Comment with spaces"})
641
- dot = node.to_s
641
+ node = DOT::Digraph.new({ "name" => "test_name", "comment" => "Comment with spaces" })
642
+ dot = node.to_s
642
643
  assert_match(dot, /comment\s*=\s*"Comment with spaces"/)
643
644
 
644
- node = DOT::Digraph.new({"name" => "test_name", "comment" => "Comment with \"quotes\""})
645
- dot = node.to_s
645
+ node = DOT::Digraph.new({ "name" => "test_name", "comment" => "Comment with \"quotes\"" })
646
+ dot = node.to_s
646
647
  assert_match(dot, /comment\s*=\s*"Comment with \\"quotes\\""/)
647
648
 
648
- node = DOT::Digraph.new({"name" => "test_name", "comment" => "Comment with \\backslashes\\"})
649
- dot = node.to_s
649
+ node = DOT::Digraph.new({ "name" => "test_name", "comment" => "Comment with \\backslashes\\" })
650
+ dot = node.to_s
650
651
  assert_match(dot, /comment\s*=\s*"Comment with \\\\backslashes\\\\"/)
651
652
 
652
- node = DOT::Digraph.new({"name" => "test_name", "comment" => "123.456"})
653
- dot = node.to_s
653
+ node = DOT::Digraph.new({ "name" => "test_name", "comment" => "123.456" })
654
+ dot = node.to_s
654
655
  assert_match(dot, /comment\s*=\s*123.456/)
655
656
 
656
- node = DOT::Digraph.new({"name" => "test_name", "comment" => ".456"})
657
- dot = node.to_s
657
+ node = DOT::Digraph.new({ "name" => "test_name", "comment" => ".456" })
658
+ dot = node.to_s
658
659
  assert_match(dot, /comment\s*=\s*.456/)
659
660
 
660
- node = DOT::Digraph.new({"name" => "test_name", "comment" => "-.456"})
661
- dot = node.to_s
661
+ node = DOT::Digraph.new({ "name" => "test_name", "comment" => "-.456" })
662
+ dot = node.to_s
662
663
  assert_match(dot, /comment\s*=\s*-.456/)
663
664
 
664
- node = DOT::Digraph.new({"name" => "test_name", "comment" => "-456"})
665
- dot = node.to_s
665
+ node = DOT::Digraph.new({ "name" => "test_name", "comment" => "-456" })
666
+ dot = node.to_s
666
667
  assert_match(dot, /comment\s*=\s*-456/)
667
668
 
668
- node = DOT::Digraph.new({"name" => "test_name", "comment" => "-123.456"})
669
- dot = node.to_s
669
+ node = DOT::Digraph.new({ "name" => "test_name", "comment" => "-123.456" })
670
+ dot = node.to_s
670
671
  assert_match(dot, /comment\s*=\s*-123.456/)
671
672
 
672
- node = DOT::Digraph.new({"name" => "test_name", "comment" => "<html><head><title>test</title></head>\n<body>text</body></html>"})
673
- dot = node.to_s
673
+ node = DOT::Digraph.new({ "name" => "test_name", "comment" => "<html><head><title>test</title></head>\n<body>text</body></html>" })
674
+ dot = node.to_s
674
675
  assert_match(dot, /comment\s*=\s*<html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html>/)
675
676
  end
676
677
 
@@ -699,145 +700,145 @@ end
699
700
  class TestDotSubgraph < Test::Unit::TestCase
700
701
  def test_subgraph_statement
701
702
  subgraph = DOT::Subgraph.new()
702
- dot = subgraph.to_s
703
+ dot = subgraph.to_s
703
704
  assert_match(dot, /^\s*subgraph /)
704
705
  end
705
706
 
706
707
  def test_name_quoting
707
- node = DOT::Subgraph.new({"name" => "Name with spaces"})
708
- dot = node.to_s
708
+ node = DOT::Subgraph.new({ "name" => "Name with spaces" })
709
+ dot = node.to_s
709
710
  assert_match(dot, /^subgraph "Name with spaces" \{$/)
710
711
 
711
- node = DOT::Subgraph.new({"name" => "Name with \"quotes\""})
712
- dot = node.to_s
712
+ node = DOT::Subgraph.new({ "name" => "Name with \"quotes\"" })
713
+ dot = node.to_s
713
714
  assert_match(dot, /^subgraph "Name with \\"quotes\\"" \{$/)
714
715
 
715
- node = DOT::Subgraph.new({"name" => "Name with \\backslashes\\"})
716
- dot = node.to_s
716
+ node = DOT::Subgraph.new({ "name" => "Name with \\backslashes\\" })
717
+ dot = node.to_s
717
718
  assert_match(dot, /^subgraph "Name with \\\\backslashes\\\\" \{$/)
718
719
 
719
- node = DOT::Subgraph.new({"name" => "Name with\nembedded\nnewlines"})
720
- dot = node.to_s
720
+ node = DOT::Subgraph.new({ "name" => "Name with\nembedded\nnewlines" })
721
+ dot = node.to_s
721
722
  assert_match(dot, /\A.*"Name with\nembedded\nnewlines".*\Z/m)
722
723
 
723
- node = DOT::Subgraph.new({"name" => "Name_with_trailing_newline\n"})
724
- dot = node.to_s
724
+ node = DOT::Subgraph.new({ "name" => "Name_with_trailing_newline\n" })
725
+ dot = node.to_s
725
726
  assert_match(dot, /\A.*"Name_with_trailing_newline\n".*\Z/m)
726
727
 
727
- node = DOT::Subgraph.new({"name" => "123.456"})
728
- dot = node.to_s
728
+ node = DOT::Subgraph.new({ "name" => "123.456" })
729
+ dot = node.to_s
729
730
  assert_match(dot, /^subgraph 123.456 \{$/)
730
731
 
731
- node = DOT::Subgraph.new({"name" => ".456"})
732
- dot = node.to_s
732
+ node = DOT::Subgraph.new({ "name" => ".456" })
733
+ dot = node.to_s
733
734
  assert_match(dot, /^subgraph .456 \{$/)
734
735
 
735
- node = DOT::Subgraph.new({"name" => "-.456"})
736
- dot = node.to_s
736
+ node = DOT::Subgraph.new({ "name" => "-.456" })
737
+ dot = node.to_s
737
738
  assert_match(dot, /^subgraph -.456 \{$/)
738
739
 
739
- node = DOT::Subgraph.new({"name" => "-456"})
740
- dot = node.to_s
740
+ node = DOT::Subgraph.new({ "name" => "-456" })
741
+ dot = node.to_s
741
742
  assert_match(dot, /^subgraph -456 \{$/)
742
743
 
743
- node = DOT::Subgraph.new({"name" => "-123.456"})
744
- dot = node.to_s
744
+ node = DOT::Subgraph.new({ "name" => "-123.456" })
745
+ dot = node.to_s
745
746
  assert_match(dot, /^subgraph -123.456 \{$/)
746
747
 
747
- node = DOT::Subgraph.new({"name" => "<html><head><title>test</title></head>\n<body>text</body></html>"})
748
- dot = node.to_s
748
+ node = DOT::Subgraph.new({ "name" => "<html><head><title>test</title></head>\n<body>text</body></html>" })
749
+ dot = node.to_s
749
750
  assert_match(dot, /^subgraph <html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html> \{$/)
750
751
  end
751
752
 
752
753
  def test_label_quoting
753
- node = DOT::Subgraph.new({"name" => "test_name", "label" => "Label with spaces"})
754
- dot = node.to_s
754
+ node = DOT::Subgraph.new({ "name" => "test_name", "label" => "Label with spaces" })
755
+ dot = node.to_s
755
756
  assert_match(dot, /label\s*=\s*"Label with spaces"/)
756
757
 
757
- node = DOT::Subgraph.new({"name" => "test_name", "label" => "Label with \"quotes\""})
758
- dot = node.to_s
758
+ node = DOT::Subgraph.new({ "name" => "test_name", "label" => "Label with \"quotes\"" })
759
+ dot = node.to_s
759
760
  assert_match(dot, /label\s*=\s*"Label with \\"quotes\\""/)
760
761
 
761
- node = DOT::Subgraph.new({"name" => "test_name", "label" => "Label with \\backslashes\\"})
762
- dot = node.to_s
762
+ node = DOT::Subgraph.new({ "name" => "test_name", "label" => "Label with \\backslashes\\" })
763
+ dot = node.to_s
763
764
  assert_match(dot, /label\s*=\s*"Label with \\\\backslashes\\\\"/)
764
765
 
765
- node = DOT::Subgraph.new({"name" => "test_name", "label" => "Label with\nembedded\nnewlines"})
766
- dot = node.to_s
766
+ node = DOT::Subgraph.new({ "name" => "test_name", "label" => "Label with\nembedded\nnewlines" })
767
+ dot = node.to_s
767
768
  assert_match(dot, /label\s*=\s*"Label with\\nembedded\\nnewlines"/)
768
769
 
769
- node = DOT::Subgraph.new({"name" => "test_name", "label" => "Label_with_a_trailing_newline\n"})
770
- dot = node.to_s
770
+ node = DOT::Subgraph.new({ "name" => "test_name", "label" => "Label_with_a_trailing_newline\n" })
771
+ dot = node.to_s
771
772
  assert_match(dot, /label\s*=\s*"Label_with_a_trailing_newline\\n"/)
772
773
 
773
- node = DOT::Subgraph.new({"name" => "test_name", "label" => "Left justified label\\l"})
774
- dot = node.to_s
774
+ node = DOT::Subgraph.new({ "name" => "test_name", "label" => "Left justified label\\l" })
775
+ dot = node.to_s
775
776
  assert_match(dot, /label\s*=\s*"Left justified label\\l"/)
776
777
 
777
- node = DOT::Subgraph.new({"name" => "test_name", "label" => "Right justified label\\r"})
778
- dot = node.to_s
778
+ node = DOT::Subgraph.new({ "name" => "test_name", "label" => "Right justified label\\r" })
779
+ dot = node.to_s
779
780
  assert_match(dot, /label\s*=\s*"Right justified label\\r"/)
780
781
 
781
- node = DOT::Subgraph.new({"name" => "test_name", "label" => "123.456"})
782
- dot = node.to_s
782
+ node = DOT::Subgraph.new({ "name" => "test_name", "label" => "123.456" })
783
+ dot = node.to_s
783
784
  assert_match(dot, /label\s*=\s*123.456/)
784
785
 
785
- node = DOT::Subgraph.new({"name" => "test_name", "label" => ".456"})
786
- dot = node.to_s
786
+ node = DOT::Subgraph.new({ "name" => "test_name", "label" => ".456" })
787
+ dot = node.to_s
787
788
  assert_match(dot, /label\s*=\s*.456/)
788
789
 
789
- node = DOT::Subgraph.new({"name" => "test_name", "label" => "-.456"})
790
- dot = node.to_s
790
+ node = DOT::Subgraph.new({ "name" => "test_name", "label" => "-.456" })
791
+ dot = node.to_s
791
792
  assert_match(dot, /label\s*=\s*-.456/)
792
793
 
793
- node = DOT::Subgraph.new({"name" => "test_name", "label" => "-456"})
794
- dot = node.to_s
794
+ node = DOT::Subgraph.new({ "name" => "test_name", "label" => "-456" })
795
+ dot = node.to_s
795
796
  assert_match(dot, /label\s*=\s*-456/)
796
797
 
797
- node = DOT::Subgraph.new({"name" => "test_name", "label" => "-123.456"})
798
- dot = node.to_s
798
+ node = DOT::Subgraph.new({ "name" => "test_name", "label" => "-123.456" })
799
+ dot = node.to_s
799
800
  assert_match(dot, /label\s*=\s*-123.456/)
800
801
 
801
- node = DOT::Subgraph.new({"name" => "test_name", "label" => "<html><head><title>test</title></head>\n<body>text</body></html>"})
802
- dot = node.to_s
802
+ node = DOT::Subgraph.new({ "name" => "test_name", "label" => "<html><head><title>test</title></head>\n<body>text</body></html>" })
803
+ dot = node.to_s
803
804
  assert_match(dot, /label\s*=\s*<html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html>/)
804
805
  end
805
806
 
806
807
  def test_option_quoting
807
- node = DOT::Subgraph.new({"name" => "test_name", "comment" => "Comment with spaces"})
808
- dot = node.to_s
808
+ node = DOT::Subgraph.new({ "name" => "test_name", "comment" => "Comment with spaces" })
809
+ dot = node.to_s
809
810
  assert_match(dot, /comment\s*=\s*"Comment with spaces"/)
810
811
 
811
- node = DOT::Subgraph.new({"name" => "test_name", "comment" => "Comment with \"quotes\""})
812
- dot = node.to_s
812
+ node = DOT::Subgraph.new({ "name" => "test_name", "comment" => "Comment with \"quotes\"" })
813
+ dot = node.to_s
813
814
  assert_match(dot, /comment\s*=\s*"Comment with \\"quotes\\""/)
814
815
 
815
- node = DOT::Subgraph.new({"name" => "test_name", "comment" => "Comment with \\backslashes\\"})
816
- dot = node.to_s
816
+ node = DOT::Subgraph.new({ "name" => "test_name", "comment" => "Comment with \\backslashes\\" })
817
+ dot = node.to_s
817
818
  assert_match(dot, /comment\s*=\s*"Comment with \\\\backslashes\\\\"/)
818
819
 
819
- node = DOT::Subgraph.new({"name" => "test_name", "comment" => "123.456"})
820
- dot = node.to_s
820
+ node = DOT::Subgraph.new({ "name" => "test_name", "comment" => "123.456" })
821
+ dot = node.to_s
821
822
  assert_match(dot, /comment\s*=\s*123.456/)
822
823
 
823
- node = DOT::Subgraph.new({"name" => "test_name", "comment" => ".456"})
824
- dot = node.to_s
824
+ node = DOT::Subgraph.new({ "name" => "test_name", "comment" => ".456" })
825
+ dot = node.to_s
825
826
  assert_match(dot, /comment\s*=\s*.456/)
826
827
 
827
- node = DOT::Subgraph.new({"name" => "test_name", "comment" => "-.456"})
828
- dot = node.to_s
828
+ node = DOT::Subgraph.new({ "name" => "test_name", "comment" => "-.456" })
829
+ dot = node.to_s
829
830
  assert_match(dot, /comment\s*=\s*-.456/)
830
831
 
831
- node = DOT::Subgraph.new({"name" => "test_name", "comment" => "-456"})
832
- dot = node.to_s
832
+ node = DOT::Subgraph.new({ "name" => "test_name", "comment" => "-456" })
833
+ dot = node.to_s
833
834
  assert_match(dot, /comment\s*=\s*-456/)
834
835
 
835
- node = DOT::Subgraph.new({"name" => "test_name", "comment" => "-123.456"})
836
- dot = node.to_s
836
+ node = DOT::Subgraph.new({ "name" => "test_name", "comment" => "-123.456" })
837
+ dot = node.to_s
837
838
  assert_match(dot, /comment\s*=\s*-123.456/)
838
839
 
839
- node = DOT::Subgraph.new({"name" => "test_name", "comment" => "<html><head><title>test</title></head>\n<body>text</body></html>"})
840
- dot = node.to_s
840
+ node = DOT::Subgraph.new({ "name" => "test_name", "comment" => "<html><head><title>test</title></head>\n<body>text</body></html>" })
841
+ dot = node.to_s
841
842
  assert_match(dot, /comment\s*=\s*<html><head><title>test<\/title><\/head>\n<body>text<\/body><\/html>/)
842
843
  end
843
844