test/condition_test.rb in ruote-0.9.18 vs test/condition_test.rb in ruote-0.9.19
- old
+ new
@@ -5,151 +5,165 @@
# John Mettraux at openwfe.org
#
# Sun Oct 29 16:18:25 JST 2006
#
+require 'rubygems'
+
require 'test/unit'
require 'rutest_utils'
+require 'openwfe/rudefinitions'
+require 'openwfe/expressions/rprocdef'
require 'openwfe/expressions/condition'
+
#
# testing expression conditions
#
-
class ConditionTest < Test::Unit::TestCase
- include OpenWFE::ConditionMixin
- def setup
- @debug = false
- end
+ include OpenWFE::ConditionMixin
+ include OpenWFE::OwfeServiceLocator
- #def teardown
- #end
- def test_0
+ def setup
- #@debug = true
+ @debug = false
- assert_t "true"
- assert_F "false"
+ @application_context = {}
+ @application_context = {
+ :s_tree_checker => OpenWFE::TreeChecker.new(nil, @application_context)
+ }
+ end
- assert_t "1 == 1"
+ #def teardown
+ #end
- assert_t "'a' == 'a'"
- assert_t '"a" == "a"'
+ def test_0
- assert_t "a == a"
- assert_F "'a' == a"
+ #@debug = true
- #assert_t "!= ''"
+ assert_t "true"
+ assert_F "false"
- assert_F " == 1 "
- assert_F " == 1"
- assert_F "== 1"
- end
+ assert_t "1 == 1"
- def test_0b
+ assert_t "'a' == 'a'"
+ assert_t '"a" == "a"'
- #@debug = true
+ assert_t "a == a"
+ assert_F "'a' == a"
- assert_t "a"
- assert_F ""
- end
+ #assert_t "!= ''"
- def test_1
+ assert_F " == 1 "
+ assert_F " == 1"
+ assert_F "== 1"
+ end
- #@debug = true
+ def test_0b
- assert_set_t "1 is set"
- assert_set_t "1 set"
- assert_set_F "1 is not set"
- assert_set_F "1 not set"
+ #@debug = true
- assert_set_t " is not set"
- assert_set_t " not set"
- assert_set_F " is set"
- assert_set_F " set"
+ assert_t "a"
+ assert_F ""
+ end
- assert_t "1 is set"
- assert_t "1 set"
- assert_F "1 is not set"
- assert_F "1 not set"
+ def test_1
- assert_t " is not set"
- assert_t " not set"
- assert_F " is set"
- assert_F " set"
- end
+ #@debug = true
- def test_2
+ assert_set_t "1 is set"
+ assert_set_t "1 set"
+ assert_set_F "1 is not set"
+ assert_set_F "1 not set"
- #@debug = true
+ assert_set_t " is not set"
+ assert_set_t " not set"
+ assert_set_F " is set"
+ assert_set_F " set"
- $my_owferu_var = nil
+ assert_t "1 is set"
+ assert_t "1 set"
+ assert_F "1 is not set"
+ assert_F "1 not set"
- #assert_F "f = File.open('toto', 'w'); f.puts('nada'); f.close"
- assert_t "$my_owferu_var = 3; $my_owferu_var = 4"
+ assert_t " is not set"
+ assert_t " not set"
+ assert_F " is set"
+ assert_F " set"
+ end
- target = on_jruby? ? 4 : nil
- assert_equal target, $my_owferu_var
+ def test_2
- #assert_F "fe.reply('a')"
- assert_t "fe.reply('a')"
- end
+ #@debug = true
- protected
+ $my_owferu_var = nil
- #
- # just for test_2
- #
- def reply (m)
- @fei = nil
- end
+ #assert_F "f = File.open('toto', 'w'); f.puts('nada'); f.close"
+ assert_t "$my_owferu_var = 3; $my_owferu_var = 4"
- def assert_t (s, inv=false)
+ target = on_jruby? ? 4 : nil
+ assert_equal target, $my_owferu_var
- r = eval_condition(s, nil)
+ #assert_F "fe.reply('a')"
+ #assert_t "fe.reply('a')"
+ end
- #puts "raw r is _#{r}_" if @debug
+ protected
- r = (not r) if inv
+ #
+ # just for test_2
+ #
+ def reply (m)
- assert r, ">#{s}< should have evaluated to _#{not inv}_"
- end
+ @fei = nil
+ end
- def assert_F (s)
+ def assert_t (s, inv=false)
- assert_t s, true
- end
+ r = eval_condition(s, nil)
- def assert_set_t (s, inv=false)
+ #puts "raw r is _#{r}_" if @debug
- r = eval_set s
- r = (not r) if inv
+ r = (not r) if inv
- assert r, ">#{s}< should have evaluated to _#{not inv}_"
- end
+ assert r, ">#{s}< should have evaluated to _#{not inv}_"
+ end
- def assert_set_F (s)
+ def assert_F (s)
- assert_set_t s, true
- end
+ assert_t s, true
+ end
- #def evalc (s)
- # eval_condition(s, nil)
- #end
+ def assert_set_t (s, inv=false)
- def lookup_attribute (attname, workitem)
+ r = eval_set s
+ r = (not r) if inv
- attname
- end
+ assert r, ">#{s}< should have evaluated to _#{not inv}_"
+ end
- def ldebug (&block)
+ def assert_set_F (s)
- # don't do a thing
- return unless @debug
+ assert_set_t s, true
+ end
- puts " " + block.call
- end
+ #def evalc (s)
+ # eval_condition(s, nil)
+ #end
+
+ def lookup_attribute (attname, workitem)
+
+ attname
+ end
+
+ def ldebug (&block)
+
+ # don't do a thing
+ return unless @debug
+
+ puts " " + block.call
+ end
end