summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/board_spec.rb14
-rw-r--r--spec/door_spec.rb6
-rw-r--r--spec/link_spec.rb23
-rw-r--r--spec/particle_spec.rb55
-rw-r--r--spec/room_spec.rb19
-rw-r--r--spec/spin_spec.rb8
6 files changed, 68 insertions, 57 deletions
diff --git a/spec/board_spec.rb b/spec/board_spec.rb
index 7e291c6..1b2e0c4 100644
--- a/spec/board_spec.rb
+++ b/spec/board_spec.rb
@@ -16,11 +16,11 @@ describe Edoors::Board do
#
it "require_p release_p" do
board = Edoors::Board.new 'hell', @spin
- p0 = board.require_p Edoors::Particle
+ p0 = board.require_p
p1 = board.require_p Edoors::Particle
(p0===p1).should be_false
board.release_p p0
- p2 = board.require_p Edoors::Particle
+ p2 = board.require_p
(p0===p2).should be_true
end
#
@@ -29,14 +29,14 @@ describe Edoors::Board do
p0['k0'] = 'v0'
p0['k1'] = 'neither'
p0['k2'] = 'v2'
- p0.set_link_fields 'k0,k2'
- p0.link_value.should eql 'v0v2'
+ p0.set_link_keys 'k0', 'k2'
+ p0.link_value.should == {'k0'=>'v0','k2'=>'v2'}
p1 = Edoors::Particle.new
p1['k0'] = 'v0'
p1['k1'] = 'nore'
p1['k2'] = 'v2'
- p1.set_link_fields 'k0,k2'
- p1.link_value.should eql 'v0v2'
+ p1.set_link_keys 'k0', 'k2'
+ p1.link_value.should == {'k0'=>'v0','k2'=>'v2'}
P0 = p0
P1 = p1
class Board0 < Edoors::Board
@@ -79,7 +79,7 @@ describe Edoors::Board do
p0 = Edoors::Particle.new
p1 = Edoors::Particle.new
p1['v0']=0
- p1.set_link_fields 'v0'
+ p1.set_link_keys 'v0'
board.process_p p0
board.process_p p1
hell = Edoors::Board.json_create( JSON.load( JSON.generate(board) ) )
diff --git a/spec/door_spec.rb b/spec/door_spec.rb
index 0c2dafe..d86bb5a 100644
--- a/spec/door_spec.rb
+++ b/spec/door_spec.rb
@@ -17,10 +17,10 @@ describe Edoors::Door do
it "require_p release_p" do
door = Edoors::Door.new 'hell', @spin
p0 = door.require_p Edoors::Particle
- p1 = door.require_p Edoors::Particle
+ p1 = door.require_p
(p0===p1).should be_false
door.release_p p0
- p2 = door.require_p Edoors::Particle
+ p2 = door.require_p
(p0===p2).should be_true
end
#
@@ -67,7 +67,7 @@ describe Edoors::Door do
p0.add_dst 'RELEASE'
p0.split_dst!
d0.process_p p0
- p1 = d0.require_p Edoors::Particle
+ p1 = d0.require_p
p1.should be p0
p0.clear_dsts!
#
diff --git a/spec/link_spec.rb b/spec/link_spec.rb
index 0de1d93..49f086a 100644
--- a/spec/link_spec.rb
+++ b/spec/link_spec.rb
@@ -10,26 +10,23 @@ describe Edoors::Link do
@spin = Edoors::Spin.new 'dom0'
p = @spin.require_p Edoors::Particle
p.set_data Edoors::LNK_SRC, 'input1'
- p.set_data Edoors::LNK_DSTS, 'concat1?follow,output1'
- p.set_data Edoors::LNK_FIELDS, 'f0,f2'
- p.set_data Edoors::LNK_CONDF, 'f0,f1,f2'
- p.set_data Edoors::LNK_CONDV, 'v0v1v2'
- lnk = Edoors::Link.from_particle_data p
+ p.set_data Edoors::LNK_DSTS, ['concat1?follow','output1']
+ p.set_data Edoors::LNK_KEYS, ['f0','f2']
+ p.set_data Edoors::LNK_VALUE, {'f0'=>'v0','f1'=>'v1','f2'=>'v2'}
+ lnk = Edoors::Link.from_particle p
lnk.src.should eql 'input1'
- lnk.dsts.should eql 'concat1?follow,output1'
- lnk.fields.should eql 'f0,f2'
- lnk.cond_fields.should eql 'f0,f1,f2'
- lnk.cond_value.should eql 'v0v1v2'
+ lnk.dsts.should eql ['concat1?follow','output1']
+ lnk.keys.should eql ['f0','f2']
+ lnk.value.should == {'f0'=>'v0','f1'=>'v1','f2'=>'v2'}
end
#
it "link->json->link" do
- link = Edoors::Link.new 'input1', 'concat1?follow,output1', 'f0,f2', 'f0,f1,f2', 'v0v1v2'
+ link = Edoors::Link.new 'input1', ['concat1?follow','output1'], ['f0','f2'], {'f0'=>'v0','f1'=>'v1','f2'=>'v2'}
lnk = Edoors::Link.json_create( JSON.load( JSON.generate(link) ) )
link.src.should eql lnk.src
link.dsts.should eql lnk.dsts
- link.fields.should eql lnk.fields
- link.cond_fields.should eql lnk.cond_fields
- link.cond_value.should eql lnk.cond_value
+ link.keys.should eql lnk.keys
+ link.value.should eql lnk.value
JSON.generate(link).should eql JSON.generate(lnk)
end
#
diff --git a/spec/particle_spec.rb b/spec/particle_spec.rb
index fe6508f..8d926ef 100644
--- a/spec/particle_spec.rb
+++ b/spec/particle_spec.rb
@@ -74,7 +74,7 @@ describe Edoors::Particle do
d1 = Edoors::Door.new 'door1', nil
p.dst.should be_nil
p.next_dst.should be_nil
- p.add_dsts 'some?where,room0/room1/door?action,room/door,door'
+ p.add_dsts 'some?where', 'room0/room1/door?action', 'room/door', 'door'
p.next_dst.should eql 'some?where'
p.dst_routed! d0
p.dst.should be d0
@@ -155,7 +155,7 @@ describe Edoors::Particle do
p.action.should eql 'action'
p.clear_dsts!
#
- p.add_dsts 'door?action,?action'
+ p.add_dsts 'door?action', '?action'
p.split_dst!
p.room.should be_nil
p.door.should eql 'door'
@@ -175,7 +175,7 @@ describe Edoors::Particle do
p = Edoors::Particle.new
d = Edoors::Door.new 'door', nil
p.init! d
- p.add_dsts 'door?action,?action'
+ p.add_dsts 'door?action', '?action'
p.next_dst.should eql 'door?action'
p.error! 'err_msg'
p[Edoors::FIELD_ERROR_MSG].should eql 'err_msg'
@@ -183,17 +183,30 @@ describe Edoors::Particle do
p.dst.should be d
end
#
- it "link fields and link value" do
+ it "link keys and link values" do
+ p = Edoors::Particle.new
+ p['k0'] = 'v0'
+ p.set_data 'k1', 'v1'
+ p['k2'] = 'v2'
+ p['k3'] = 'v3'
+ p.set_link_keys 'k0', 'k2', 'k1'
+ p.link_value.should == {'k0'=>'v0','k1'=>'v1','k2'=>'v2'}
+ p.del_data 'k0'
+ p.link_value.should == {'k1'=>'v1','k2'=>'v2'}
+ p.set_link_keys 'k1', 'k0'
+ p.link_value.should == {'k1'=>'v1'}
+ p['k1']='vX'
+ p.link_value.should == {'k1'=>'vX'}
+ end
+ #
+ it 'link_with?' do
p = Edoors::Particle.new
p['k0'] = 'v0'
p['k1'] = 'v1'
p['k2'] = 'v2'
- p.set_link_fields 'k0,k2'
- p.link_value.should eql 'v0v2'
- p.set_link_fields 'k1,k0'
- p.link_value.should eql 'v1v0'
- p['k0']='vx'
- p.link_value.should eql 'v1vx'
+ p.link_with?(Edoors::Link.new('', '', '')).should be_true
+ p.link_with?(Edoors::Link.new('', '', '', {'k0'=>'v0','k1'=>'v1'})).should be_true
+ p.link_with?(Edoors::Link.new('', '', '', {'k0'=>'v2','k1'=>'v1'})).should be_false
end
#
it "apply_link!" do
@@ -201,18 +214,18 @@ describe Edoors::Particle do
p['k0'] = 'v0'
p['k1'] = 'v1'
p['k2'] = 'v2'
- p.set_link_fields 'k0,k2'
- p.add_dsts 'door?action,?action'
+ p.set_link_keys 'k0', 'k2'
+ p.add_dsts 'door?action', '?action'
p.src.should be_nil
- p.link_value.should eql 'v0v2'
+ p.link_value.should == {'k0'=>'v0','k2'=>'v2'}
p.next_dst.should eql 'door?action'
- lnk = Edoors::Link.new('door0', 'door1?get,door2', 'k1', 'f0,f1', 'v0v1')
+ lnk = Edoors::Link.new('door0', ['door1?get','door2'], 'k1', {'f0'=>'v0','f1'=>'v1'})
f = Fake.new 'fake', nil
lnk.door = f
p.apply_link! lnk
p.src.should be f
p.next_dst.should eql 'door1?get'
- p.link_value.should eql 'v1'
+ p.link_value.should == {'k1'=>'v1'}
end
#
it "particle->json->particle" do
@@ -226,8 +239,8 @@ describe Edoors::Particle do
p0['k1'] = 'v1'
p0['k2'] = 'v2'
p0.init! s3
- p0.set_link_fields 'k0,k2'
- p0.add_dsts 'room0/room1/room2/doorX?myaction,door?action,?action'
+ p0.set_link_keys 'k0', 'k2'
+ p0.add_dsts 'room0/room1/room2/doorX?myaction', 'door?action', '?action'
p0.split_dst!
p1 = Edoors::Particle.new
p1['k3'] = 'v6'
@@ -235,8 +248,8 @@ describe Edoors::Particle do
p1['k5'] = 'v8'
p1.init! s3
p1.dst_routed! s4
- p1.set_link_fields 'k5,k4,k3'
- p1.add_dsts 'room0/room1/door?action,output?action'
+ p1.set_link_keys 'k5', 'k4', 'k3'
+ p1.add_dsts 'room0/room1/door?action', 'output?action'
p0.merge! p1
o = JSON.load( JSON.generate(p0) )
o['spin'] = s0
@@ -248,7 +261,7 @@ describe Edoors::Particle do
px.door.should eql 'doorX'
px.action.should eql 'myaction'
px.next_dst.should eql 'room0/room1/room2/doorX?myaction'
- px.link_value.should eql 'v0v2'
+ px.link_value.should == {'k0'=>'v0','k2'=>'v2'}
px['k0'].should eql 'v0'
px['k1'].should eql 'v1'
px['k2'].should eql 'v2'
@@ -260,7 +273,7 @@ describe Edoors::Particle do
py.door.should be_nil
py.action.should be_nil
py.next_dst.should eql 'room0/room1/door?action'
- py.link_value.should eql 'v8v7v6'
+ py.link_value.should == {'k3'=>'v6','k4'=>'v7','k5'=>'v8'}
py['k3'].should eql 'v6'
py['k4'].should eql 'v7'
py['k5'].should eql 'v8'
diff --git a/spec/room_spec.rb b/spec/room_spec.rb
index de697c1..3757951 100644
--- a/spec/room_spec.rb
+++ b/spec/room_spec.rb
@@ -203,7 +203,7 @@ describe Edoors::Room do
room0 = Edoors::Room.new 'room0', @spin
door0 = Edoors::Door.new 'door0', room0
door1 = Edoors::Door.new 'door1', room0
- room0.add_link Edoors::Link.new('door0', 'door1', 'fields', 'f0,f1', 'v0v1')
+ room0.add_link Edoors::Link.new('door0', 'door1', 'keys', {'f0'=>'v0','f1'=>'v1'})
p = @spin.require_p Edoors::Particle
p['f0']='v0'
p['f1']='v1'
@@ -225,14 +225,16 @@ describe Edoors::Room do
end
door1 = Out.new 'door1', room0
room0.add_link Edoors::Link.new('door0', 'door1')
- room0.add_link Edoors::Link.new('door0', 'door1', 'fields', 'f0,f1', 'v0v1')
- room0.add_link Edoors::Link.new('door0', 'door1', 'fields', 'f0,f1', 'v0v2')
+ room0.add_link Edoors::Link.new('door0', 'door1', 'keys', {'f0'=>'v0'})
+ room0.add_link Edoors::Link.new('door0', 'door1', 'keys', {'f0'=>'v0','f1'=>'v1'})
+ room0.add_link Edoors::Link.new('door0', 'door1', 'keys', {'f0'=>'v0','f1'=>'v2'})
+ room0.add_link Edoors::Link.new('door0', 'door1', 'keys', {'f0'=>'v0','f2'=>'v1'})
p = @spin.require_p Edoors::Particle
p['f0']='v0'
p['f1']='v1'
door0.send_p p
@spin.spin!
- door1.count.should eql 2
+ door1.count.should eql 3
end
#
it "system route error: system no destination" do
@@ -278,9 +280,8 @@ describe Edoors::Room do
p0 = @spin.require_p Edoors::Particle
p0.set_data Edoors::LNK_SRC, 'door0'
p0.set_data Edoors::LNK_DSTS, 'door1'
- p0.set_data Edoors::LNK_FIELDS, 'fields'
- p0.set_data Edoors::LNK_CONDF, 'f0,f1'
- p0.set_data Edoors::LNK_CONDV, 'v0v1'
+ p0.set_data Edoors::LNK_KEYS, 'keys'
+ p0.set_data Edoors::LNK_VALUE, {'f0'=>'v0','f1'=>'v1'}
p0.add_dst Edoors::SYS_ACT_ADD_LINK, room0.path
room0.send_sys_p p0
@spin.spin!
@@ -318,10 +319,10 @@ describe Edoors::Room do
d0 = Edoors::Door.new 'd0', r1
d1 = Edoors::Door.new 'd1', r1
d2 = Edoors::Door.new 'd2', r2
- r1.add_link Edoors::Link.new('d0', 'd1', 'fields', 'f0,f1', 'v0v1')
+ r1.add_link Edoors::Link.new('d0', 'd1', 'keys', {'f0'=>'v0','f1'=>'v1'})
r1.add_link Edoors::Link.new('d0', 'd2')
r1.add_link Edoors::Link.new('d1', 'd0')
- r2.add_link Edoors::Link.new('d2', 'd1', 'fies', 'f5,f1', 'v9v1')
+ r2.add_link Edoors::Link.new('d2', 'd1', 'fies', {'f5'=>'v9','f1'=>'v1'})
rx = Edoors::Room.json_create( JSON.load( JSON.generate(r0) ) )
JSON.generate(r0).should eql JSON.generate(rx)
end#
diff --git a/spec/spin_spec.rb b/spec/spin_spec.rb
index 9ceebf8..9c2e2ea 100644
--- a/spec/spin_spec.rb
+++ b/spec/spin_spec.rb
@@ -86,10 +86,10 @@ describe Edoors::Spin do
it "option debug" do
spin = Edoors::Spin.new 'dom0'
spin.debug_routing.should be false
- spin.debug_errors.should be false
- spin = Edoors::Spin.new 'dom0', :debug_routing=>true, :debug_errors=>true
+ spin.debug_garbage.should be false
+ spin = Edoors::Spin.new 'dom0', :debug_routing=>true, :debug_garbage=>true
spin.debug_routing.should be true
- spin.debug_errors.should be true
+ spin.debug_garbage.should be true
end
#
it "search world" do
@@ -129,7 +129,7 @@ describe Edoors::Spin do
p0.add_dst Edoors::SYS_ACT_HIBERNATE
Edoors::Room.new 'input', spin
Edoors::Room.new 'output', spin
- spin.add_link Edoors::Link.new('input', 'output', nil, nil, nil)
+ spin.add_link Edoors::Link.new('input', 'output', nil, nil)
spin.send_sys_p p0
spin.spin!
dom0 = Edoors::Spin.resume! spin.hibernate_path