test/unit/ut_5_tree.rb in ruote-2.3.0.1 vs test/unit/ut_5_tree.rb in ruote-2.3.0.2
- old
+ new
@@ -5,50 +5,60 @@
# Thu May 21 15:29:48 JST 2009
#
require File.expand_path('../../test_helper', __FILE__)
-require 'ruote/util/tree'
+require 'ruote'
class TreeTest < Test::Unit::TestCase
- def test_decompose_tree
+ def test_compact_tree_participant
assert_equal(
- { '0' => [ 'define', { 'name' => 'nada' } ],
- '0_0' => [ 'sequence', {} ],
- '0_0_0' => [ 'alpha', {} ],
- '0_0_1' => [ 'bravo', {} ] },
- Ruote.decompose_tree(
- [ 'define', { 'name' => 'nada' }, [
- [ 'sequence', {}, [ [ 'alpha', {}, [] ], [ 'bravo', {}, [] ] ] ]
- ] ]))
+ [ 'alpha', {}, [] ],
+ Ruote.compact_tree(
+ [ 'participant', { 'ref' => 'alpha' }, [] ]))
+
+ assert_equal(
+ [ 'alpha', {}, [] ],
+ Ruote.compact_tree(
+ [ 'participant', { 'alpha' => nil }, [] ]))
+
+ assert_equal(
+ [ 'alpha', { 'timeout' => '2d' }, [] ],
+ Ruote.compact_tree(
+ [ 'participant', { 'alpha' => nil, 'timeout' => '2d' }, [] ]))
end
- def test_decompose_sub_tree
+ def test_compact_tree_subprocess
assert_equal(
- { '0_1' => [ 'define', { 'name' => 'nada' } ],
- '0_1_0' => [ 'sequence', {} ],
- '0_1_0_0' => [ 'alpha', {} ],
- '0_1_0_1' => [ 'bravo', {} ]},
- Ruote.decompose_tree(
- [ 'define', { 'name' => 'nada' }, [
- [ 'sequence', {}, [ [ 'alpha', {}, [] ], [ 'bravo', {}, [] ] ] ]
- ] ], '0_1'))
+ [ 'do_this', {}, [] ],
+ Ruote.compact_tree(
+ [ 'subprocess', { 'ref' => 'do_this' }, [] ]))
+
+ assert_equal(
+ [ 'do_this', {}, [] ],
+ Ruote.compact_tree(
+ [ 'subprocess', { 'do_this' => nil }, [] ]))
end
- def test_recompose_tree
+ def test_compact_tree
assert_equal(
- [ 'define', { 'name' => 'nada' }, [
- [ 'sequence', {}, [ [ 'alpha', {}, [] ], [ 'bravo', {}, [] ] ] ]
- ] ],
- Ruote.recompose_tree(
- { '0' => [ 'define', { 'name' => 'nada' } ],
- '0_0' => [ 'sequence', {} ],
- '0_0_0' => [ 'alpha', {} ],
- '0_0_1' => [ 'bravo', {} ] }))
+ ["define", {}, [
+ ["concurrence", {}, [
+ ["alpha", {"timeout"=>"1d"}, []],
+ ["alpha", {}, []]]],
+ ["bravo", {}, []]]],
+ Ruote.compact_tree(
+ Ruote.define do
+ concurrence do
+ participant :ref => 'alpha', :timeout => '1d'
+ subprocess 'alpha'
+ end
+ bravo
+ end))
end
end