test/functional/ft_10_dollar.rb in ruote-2.2.0 vs test/functional/ft_10_dollar.rb in ruote-2.3.0

- old
+ new

@@ -3,11 +3,11 @@ # testing ruote # # Wed Jun 10 22:57:18 JST 2009 # -require File.join(File.dirname(__FILE__), 'base') +require File.expand_path('../base', __FILE__) class FtDollarTest < Test::Unit::TestCase include FunctionalBase @@ -86,18 +86,18 @@ end end #noisy - wfid = @engine.launch(pdef) + wfid = @dashboard.launch(pdef) - @engine.wait_for(wfid) + @dashboard.wait_for(wfid) assert_equal( "#<ArgumentError: 'ruby_eval_allowed' is set to false, cannot evaluate" + " >1 + 2< (http://ruote.rubyforge.org/dollar.html)>", - @engine.errors.first.message) + @dashboard.errors.first.message) end def test_r pdef = Ruote.process_definition do @@ -106,30 +106,31 @@ end end #noisy - @engine.context['ruby_eval_allowed'] = true + @dashboard.context['ruby_eval_allowed'] = true assert_trace('>3<', pdef) end def test_r_and_wi pdef = Ruote.process_definition do sequence do set 'f:toto' => 'person' + echo "${r:wi['toto']}" echo "${r:wi.fields['toto']}" echo "${r:workitem.fields['toto']}" end end #noisy - @engine.context['ruby_eval_allowed'] = true + @dashboard.context['ruby_eval_allowed'] = true - assert_trace "person\nperson", pdef + assert_trace [ 'person' ] * 3, pdef end def test_r_and_d pdef = Ruote.process_definition do @@ -139,11 +140,11 @@ end end #noisy - @engine.context['ruby_eval_allowed'] = true + @dashboard.context['ruby_eval_allowed'] = true assert_trace 'person', pdef end def test_nested @@ -168,13 +169,13 @@ echo '${fei}' echo '${wfid}' end end - wfid = @engine.launch(pdef) + wfid = @dashboard.launch(pdef) - @engine.wait_for(wfid) + @dashboard.wait_for(wfid) assert_match /^0_0_0![^!]+!#{wfid}\n#{wfid}$/, @tracer.to_s end def test_direct_access_to_fields @@ -184,11 +185,11 @@ set 'f:a' => [ 'alpha', 'bravo', 'charly' ] echo '${r:a.join("/")}' end end - @engine.context['ruby_eval_allowed'] = true + @dashboard.context['ruby_eval_allowed'] = true #noisy assert_trace 'alpha/bravo/charly', pdef end @@ -223,13 +224,13 @@ filter :f => /^[a-c]$/, :del => true end #noisy - wfid = @engine.launch(pdef) + wfid = @dashboard.launch(pdef) - r = @engine.wait_for(wfid) + r = @dashboard.wait_for(wfid) assert_equal( { 'A' => %w[ A B C ], 'B' => %w[ A B C ], @@ -248,21 +249,81 @@ pdef = Ruote.define do set 'f:a' => %w[ A B C ] alpha :b => '$f:a' end - @engine.register_participant :alpha do |wi| + @dashboard.register_participant :alpha do |wi| wi.fields['parameters'] = wi.fields['params'] end #noisy - wfid = @engine.launch(pdef) + wfid = @dashboard.launch(pdef) - r = @engine.wait_for(wfid) + r = @dashboard.wait_for(wfid) assert_equal( { 'b' => %w[ A B C ], 'ref' => 'alpha' }, r['workitem']['fields']['parameters']) + end + + # Issue pointed out by John Le. + # + def test_not_a_number + + pdef = Ruote.define do + echo 'a0', :if => '${a}' + echo 'a1', :if => '${a} is set' + echo 'b', :if => '${b}' + echo 'c' + end + + wfid = @dashboard.launch( + pdef, + 'a' => '0a') + + @dashboard.wait_for(wfid) + + assert_equal "a0\na1\nc", @tracer.to_s + end + + def test_literal + + pdef = Ruote.define do + set 'f:a' => true + _if '$a' do + echo 'a0' + end + echo 'a1', :if => '$a' + end + + wfid = @dashboard.launch(pdef) + @dashboard.wait_for(wfid) + + assert_equal "a0\na1", @tracer.to_s + end + + def test_participant_params + + #@dashboard.noisy = true + + @dashboard.register :toto do |workitem, fexp| + workitem['a'] = fexp.compile_atts + workitem['p'] = workitem.params + end + + pdef = Ruote.define do + toto "${a}", "${b}" => "${c}" + end + + wfid = @dashboard.launch(pdef, 'a' => 'x', 'b' => 'y', 'c' => 'z') + r = @dashboard.wait_for(wfid) + + assert_equal( + { 'y' => 'z', 'x' => nil, 'ref' => 'toto' }, + r['workitem']['fields']['a']) + assert_equal( + { 'y' => 'z', 'x' => nil, 'ref' => 'toto' }, + r['workitem']['fields']['p']) end end