test/ft_11_ppd.rb in ruote-0.9.18 vs test/ft_11_ppd.rb in ruote-0.9.19

- old
+ new

@@ -12,404 +12,400 @@ require 'flowtestbase' require 'openwfe/def' class FlowTest11 < Test::Unit::TestCase - include FlowTestBase + include FlowTestBase - #def setup - #end + #def setup + #end - #def teardown - #end + #def teardown + #end - # - # Test 0 - # + # + # Test 0 + # - class TestDefinition0 < OpenWFE::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 + class TestDefinition0 < OpenWFE::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 test_ppd_0 - #log_level_to_debug + #log_level_to_debug - dotest TestDefinition0, "a\nb\nc" - end + dotest TestDefinition0, "a\nb\nc" + end - # - # Test 1 - # + # + # Test 1 + # - class TestDefinition1 < OpenWFE::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 + class TestDefinition1 < OpenWFE::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 test_ppd_1 - dotest( - TestDefinition1, - """ + dotest( + TestDefinition1, + """ toto:nada ftoto:_nada__321 - """.strip, - true) - end + """.strip, + true) + end - # - # Test 2 - # + # + # Test 2 + # - class TestDefinition2 < OpenWFE::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 + class TestDefinition2 < OpenWFE::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 test_ppd_2 - dotest( - TestDefinition2, - "toto:nada") - #true) - end + dotest( + TestDefinition2, + "toto:nada") + #true) + end - # - # Test 3 - # + # + # Test 3 + # - class TestDefinition3 < OpenWFE::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 + class TestDefinition3 < OpenWFE::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 test_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 + #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'\nvar0 is 'b'" - end + dotest TestDefinition3, "var0 is 'a'\nvar0 is 'b'" + end - # - # Test 4 - # + # + # Test 4 + # - class TestDefinition4 < OpenWFE::ProcessDefinition - def make - process_definition :name => "test4", :revision => "0" do - sequence do - sequence do - _print "a" - end - sequence do - _print "b" - end - end - end + class TestDefinition4 < OpenWFE::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 + CODE4 = """ +process_definition :name => \"test4\", :revision => \"0\" do + sequence do sequence do - sequence do - _print do - 'a' - end - end - sequence do - _print do - 'b' - end - end + _print 'a' end + sequence do + _print 'b' + end + end end - """.strip + """.strip - def test_ppd_4 + def test_ppd_4 - s = OpenWFE::ExpressionTree.to_code_s TestDefinition4.do_make + s = OpenWFE::ExpressionTree.to_code_s TestDefinition4.do_make - dotest( - TestDefinition4, - "a\nb") - #0.300) + dotest( + TestDefinition4, + "a\nb") + #0.300) - assert_equal CODE4, s, "nested sequences test failed (4)" - end + assert_equal CODE4, s, "nested sequences test failed (4)" + end - # - # Test 5 - # + # + # Test 5 + # - class TestDefinition5 < OpenWFE::ProcessDefinition - def make - process_definition :name => "test5", :revision => "0" do - sequence do - sequence do - _print { "a" } - end - sequence do - _print { "b" } - end - end - end + class TestDefinition5 < OpenWFE::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 = <<-EOS + CODE5 = <<-EOS process_definition :name => 'test5', :revision => '0' do + sequence do sequence do - sequence do - _print do - 'a' - end - end - sequence do - _print do - 'b' - end - end + _print do + 'a' + end end + sequence do + _print do + 'b' + end + end + end end - EOS + EOS - def test_ppd_5 + def test_ppd_5 - s = OpenWFE::ExpressionTree.to_code_s(TestDefinition5.do_make) + s = OpenWFE::ExpressionTree.to_code_s(TestDefinition5.do_make) - dotest TestDefinition5, "a\nb" + dotest TestDefinition5, "a\nb" - assert CODE5, s - end + assert CODE5, s + end - # - # Test 6 - # + # + # Test 6 + # - class TestDefinition6 < OpenWFE::ProcessDefinition + class TestDefinition6 < OpenWFE::ProcessDefinition - def initialize (count) - super() - @count = count - end + def initialize (count) + super() + @count = count + end - def make - process_definition :name => "test6", :revision => "0" do - sequence do - @count.times do |i| - _print i - end - end - 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 test_ppd_6 - dotest( - TestDefinition6.new(3), - %w{ 0 1 2 }.join("\n")) - end + dotest( + TestDefinition6.new(3), + %w{ 0 1 2 }.join("\n")) + end - # - # Test 7 - # + # + # Test 7 + # - class TestDefinition7 < OpenWFE::ProcessDefinition - def make - _process_definition :name => "test7", :revision => "0" do - _sequence do - _print "a" - _print "b" - end - end + class TestDefinition7 < OpenWFE::ProcessDefinition + def make + _process_definition :name => "test7", :revision => "0" do + _sequence do + _print "a" + _print "b" end + end end + end - def test_ppd_7 + def test_ppd_7 - dotest( - TestDefinition7, - %w{ a b }.join("\n")) - end + dotest( + TestDefinition7, + %w{ a b }.join("\n")) + end - # - # Test 8 - # + # + # Test 8 + # - class TestDefinition8 < OpenWFE::ProcessDefinition - def make - process_definition :name => "test8", :revision => "0" do - toto - process_definition :name => "toto" do - _print "toto" - end - end + class TestDefinition8 < OpenWFE::ProcessDefinition + def make + process_definition :name => "test8", :revision => "0" do + toto + process_definition :name => "toto" do + _print "toto" end + end end + end - def test_ppd_8 + def test_ppd_8 - dotest TestDefinition8, "toto" - end + dotest TestDefinition8, "toto" + end - # - # Test 9 - # + # + # Test 9 + # - class TestDefinition9 < OpenWFE::ProcessDefinition - def make - process_definition :name => "test9", :revision => "0" do - _toto - process_definition :name => "toto" do - _print "toto" - end - end + class TestDefinition9 < OpenWFE::ProcessDefinition + def make + process_definition :name => "test9", :revision => "0" do + _toto + process_definition :name => "toto" do + _print "toto" end + end end + end - def test_ppd_9 + def test_ppd_9 - dotest TestDefinition9, "toto" - end + dotest TestDefinition9, "toto" + end - # - # Test 10 - # + # + # Test 10 + # - class TestDefinition10 < OpenWFE::ProcessDefinition - def make - process_definition :name => "test10", :revision => "0" do - sequence do - participant :ref => "toto_underscore" - _toto_underscore - toto_underscore - end - end + class TestDefinition10 < OpenWFE::ProcessDefinition + def make + process_definition :name => "test10", :revision => "0" do + sequence do + participant :ref => "toto_underscore" + _toto_underscore + toto_underscore end + end end + end - def test_ppd_10 + def test_ppd_10 - @engine.register_participant(:toto_underscore) do |workitem| - @tracer << "toto\n" - end - - dotest TestDefinition10, ([ 'toto' ] * 3).join("\n") + @engine.register_participant(:toto_underscore) do |workitem| + @tracer << "toto\n" end + dotest TestDefinition10, ([ 'toto' ] * 3).join("\n") + end - # - # Test 11 - # - class TestDefinition11 < OpenWFE::ProcessDefinition - def make - sequence do - [ :b, :b, :b ].each do |p| - participant p - end - participant "b" - end + # + # Test 11 + # + + class TestDefinition11 < OpenWFE::ProcessDefinition + def make + sequence do + [ :b, :b, :b ].each do |p| + participant p end + participant "b" + end end + end - def test_ppd_11 + def test_ppd_11 - @engine.register_participant(:b) do |workitem| - @tracer << "b\n" - end - - dotest TestDefinition11, ([ 'b' ] * 4).join("\n") + @engine.register_participant(:b) do |workitem| + @tracer << "b\n" end - # - # Test 12 - # + dotest TestDefinition11, ([ 'b' ] * 4).join("\n") + end - class TestDefinition12 < OpenWFE::ProcessDefinition - sequence do - _print "main" - sub_x - end - process_definition :name => "sub-x" do - _print "sub" - end + # + # Test 12 + # + + class TestDefinition12 < OpenWFE::ProcessDefinition + sequence do + _print "main" + sub_x end + process_definition :name => "sub-x" do + _print "sub" + end + end - def test_prog_12 + def test_prog_12 - dotest TestDefinition12, "main\nsub" - end + dotest TestDefinition12, "main\nsub" + end - # - # Test 13 - # + # + # Test 13 + # - class TestDefinition13 < OpenWFE::ProcessDefinition - end + class TestDefinition13 < OpenWFE::ProcessDefinition + end - def _test_prog_13 + def _test_prog_13 - dotest TestDefinition13, "" - end + dotest TestDefinition13, "" + end end