bloom-lang / bud

Prototype Bud runtime (Bloom Under Development)
http://bloom-lang.net
Other
854 stars 59 forks source link

recursion not working in join #221

Closed jhellerstein closed 13 years ago

jhellerstein commented 13 years ago
class TestSelfRecursion < Test::Unit::TestCase
  class SelfRecursion 
    include Bud
    state do
      scratch :descendant, [:child,:parent]         #intensional descendant(child,parent)
      scratch :desc, descendant.schema
    end

    bloom do
       descendant <= [["a", "b"],["a", "c"],["b", "e"],["b", "f"],["c", "g"],["c", "h"]]
       desc <= descendant
       descendant <= (desc*descendant).pairs(:child => :parent) {|a1,a2| [a1.child,a2.parent]}
    end
  end

  def test_self_recursion
    p = SelfRecursion.new
    p.tick
    assert_equal([["a", "b"],["a", "c"],["a", "e"],["a", "f"],["a", "g"],["b", "e"],["a", "h"],["b", "f"],["c", "g"],["c", "h"]], p.descendant.to_a)
  end
end
jhellerstein commented 13 years ago

This is not a bud Issue. The example Bloom program contains a bug: third line of bloom block should have the table refs flipped in the projection:

    descendant <= (desc*descendant).pairs(:child => :parent) {|a1,a2| [a2.child,a1.parent]}