Skip to content

Commit

Permalink
adding test for join nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
jkutner committed Nov 12, 2009
1 parent 6b53c1f commit 693f5af
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions tests/join_nodes.rb
@@ -0,0 +1,63 @@
# This file is part of the Ruleby project (http://ruleby.org)
#
# This application is free software; you can redistribute it and/or
# modify it under the terms of the Ruby license defined in the
# LICENSE.txt file.
#
# Copyright (c) 2009 Joe Kutner and Matt Smith. All rights reserved.
#
# * Authors: Joe Kutner
#

require 'test/unit'

require 'ruleby'

include Ruleby

module JoinNodes

class A

end

class B

end

class JoinNodesRulebook < Rulebook
def rules
rule [A], [B], [Context, :c] do |v|
v[:c].inc :rule1
end
end
end

class Test < Test::Unit::TestCase
def test_0
engine :engine do |e|
JoinNodesRulebook.new(e).rules
ctx = Context.new
a = A.new
b = B.new
e.assert ctx
e.assert a
e.assert b
e.match
assert_equal 1, ctx.get(:rule1)
e.retract a
e.match
assert_equal 1, ctx.get(:rule1)
e.assert B.new
e.match
assert_equal 1, ctx.get(:rule1)
e.assert A.new
e.match
assert_equal 3, ctx.get(:rule1)
e.retract b
e.match
assert_equal 4, ctx.get(:rule1)
end
end
end
end

0 comments on commit 693f5af

Please sign in to comment.