The way this class was testing edges was
causing them to appear adjacencies to appear magically,
because it was only testing that a hash had a key, not that
the value had any edges.

This fixes the infinite recursion mentioned in #2111.

Signed-off-by: Luke Kanies <[email protected]>
---
 lib/puppet/simple_graph.rb |    2 +-
 spec/unit/simple_graph.rb  |    9 +++++++++
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb
index d6418e0..bc81a6a 100644
--- a/lib/puppet/simple_graph.rb
+++ b/lib/puppet/simple_graph.rb
@@ -29,7 +29,7 @@ class Puppet::SimpleGraph
 
             return @adjacencies[direction].values.flatten if options[:type] == 
:edges
 
-            return @adjacencies[direction].keys
+            return @adjacencies[direction].keys.reject { |vertex| 
@adjacencies[direction][vertex].empty? }
         end
 
         # Add an edge to our list.
diff --git a/spec/unit/simple_graph.rb b/spec/unit/simple_graph.rb
index 2c061ae..a5984c9 100755
--- a/spec/unit/simple_graph.rb
+++ b/spec/unit/simple_graph.rb
@@ -197,6 +197,15 @@ describe Puppet::SimpleGraph do
         it "should support returning an array of matching edges" do
             @graph.adjacent(:two, :type => :edges).should == [...@two_three]
         end
+
+        # Bug #2111
+        it "should not consider a vertex adjacent just because it was asked 
about previously" do
+            @graph = Puppet::SimpleGraph.new
+            @graph.add_vertex("a")
+            @graph.add_vertex("b")
+            @graph.edge?("a", "b")
+            @graph.adjacent("a").should == []
+        end
     end
 
     describe "when clearing" do
-- 
1.6.1


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to