# # Testing OpenWFE # # John Mettraux at openwfe.org # # Tue Jan 2 13:14:37 JST 2007 # require 'flowtestbase' require 'openwfe/expressions/raw_prog' include OpenWFE class FlowTest11 < FlowTestBase #def setup #end #def teardown #end # # Test 0 # class TestDefinition0 < ProcessDefinition def make process_definition :name => "test0", :revision => "0" do sequence do _print do "a" end _print { "b" } _print "c" # # all these notations for nesting a string # are allowed # # of course, the latter one is the nicest end end end end def test_ppd_0 #def xxxx_ppd_0 dotest( TestDefinition0, """a b c""") end # # Test 1 # class TestDefinition1 < ProcessDefinition def make process_definition :name => "test1", :revision => "0" do sequence do set :variable => "toto", :value => "nada" _print "toto:${toto}" set :field => "ftoto" do "_${toto}__${r:'123'.reverse}" end _print { "ftoto:${f:ftoto}" } end end end end def test_ppd_1 #def xxxx_ppd_1 dotest( TestDefinition1, """toto:nada ftoto:_nada__321""") end # # Test 2 # class TestDefinition2 < ProcessDefinition def make process_definition :name => "test2", :revision => "0" do sequence do set :variable => "toto", :value => "nada" _if do equals :variable_value => "toto", :other_value => "nada" _print "toto:${toto}" _print "not ok" end end end end end def test_ppd_2 #def xxxx_ppd_2 dotest( TestDefinition2, "toto:nada") end # # Test 3 # class TestDefinition3 < ProcessDefinition def make process_definition :name => "test3", :revision => "0" do sequence do subprocess :ref => "sub0", :var0 => "a" sub0 :var0 => "b" end process_definition :name => "sub0" do _print "var0 is '${var0}'" end end end end def test_ppd_3 #def xxxx_ppd_3 #puts #puts TestDefinition3.do_make(ExpressionMap.new(nil, nil)).to_code_s #puts #puts TestDefinition3.do_make(ExpressionMap.new(nil, nil)).to_s dotest( TestDefinition3, """var0 is 'a' var0 is 'b'""") end # # Test 4 # class TestDefinition4 < ProcessDefinition def make process_definition :name => "test4", :revision => "0" do sequence do sequence do _print "a" end sequence do _print "b" end end end end end CODE4 = """ process_definition :name => 'test4', :revision => '0' do sequence do sequence do _print do 'a' end end sequence do _print do 'b' end end end end """.strip def test_ppd_4 #def xxxx_ppd_4 s = TestDefinition4.do_make( ExpressionMap.new(nil, nil)).to_code_s #puts #puts s #puts #puts TestDefinition4.do_make(ExpressionMap.new(nil, nil)).to_s dotest( TestDefinition4, """a b""") assert \ s == CODE4, "nested sequences test failed (4)" end # # Test 5 # class TestDefinition5 < ProcessDefinition def make process_definition :name => "test5", :revision => "0" do sequence do sequence do _print { "a" } end sequence do _print { "b" } end end end end end CODE5 = """ process_definition :name => 'test5', :revision => '0' do sequence do sequence do _print do 'a' end end sequence do _print do 'b' end end end end """.strip def test_ppd_5 #def xxxx_ppd_5 s = TestDefinition5.do_make( ExpressionMap.new(nil, nil)).to_code_s #puts #puts s #puts #puts TestDefinition5.do_make(ExpressionMap.new(nil, nil)).to_s dotest( TestDefinition5, """a b""") assert \ s == CODE5, "nested sequences test failed (5)" end # # Test 6 # class TestDefinition6 < ProcessDefinition def initialize (expressions, count) super(expressions) @count = count end def make process_definition :name => "test6", :revision => "0" do sequence do @count.times do |i| _print i end end end end end def test_ppd_6 #def xxxx_ppd_6 dotest( TestDefinition6.new(@engine, 3), """0 1 2""") end end