diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-09 11:21:32 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-09 11:21:32 +0200 |
commit | bc08d80e50cfcd4805f529901c370856950fc5e5 (patch) | |
tree | 670f5481cee36671ea3225dd07cf8209c7a8dc90 | |
parent | a47cb5c5b4c9cc8cf959500160db50cee620215d (diff) | |
download | edoors-ruby-bc08d80e50cfcd4805f529901c370856950fc5e5.zip edoors-ruby-bc08d80e50cfcd4805f529901c370856950fc5e5.tar.gz |
specs: increase Room coverage with #try_links
-rw-r--r-- | spec/evendoors_spec.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/evendoors_spec.rb b/spec/evendoors_spec.rb index 37a49f2..4fe107c 100644 --- a/spec/evendoors_spec.rb +++ b/spec/evendoors_spec.rb @@ -589,6 +589,62 @@ describe EvenDoors do p.dst.should be door0 end # + it "routing success: unconditional link" do + room0 = EvenDoors::Room.new 'room0', nil + door0 = EvenDoors::Door.new 'door0', room0 + door1 = EvenDoors::Door.new 'door1', room0 + room0.add_link EvenDoors::Link.new('door0', 'door1') + p = EvenDoors::Twirl.require_p EvenDoors::Particle + door0.send_p p + p.action.should be_nil + p.dst.should be door1 + end + # + it "routing success: conditional link" do + room0 = EvenDoors::Room.new 'room0', nil + door0 = EvenDoors::Door.new 'door0', room0 + door1 = EvenDoors::Door.new 'door1', room0 + room0.add_link EvenDoors::Link.new('door0', 'door1', 'fields', 'f0,f1', 'v0v1') + p = EvenDoors::Twirl.require_p EvenDoors::Particle + p['f0']='v0' + p['f1']='v1' + door0.send_p p + p.action.should be_nil + p.src.should be door0 + p.dst.should be door1 + end + # + it "routing success: more then one matching link" do + room0 = EvenDoors::Room.new 'room0', nil + door0 = EvenDoors::Door.new 'door0', room0 + class Out < EvenDoors::Door + attr_reader :ps + def receive_p p + @ps||=[] + @ps << p + end + end + door1 = Out.new 'door1', room0 + room0.add_link EvenDoors::Link.new('door0', 'door1') + room0.add_link EvenDoors::Link.new('door0', 'door1', 'fields', 'f0,f1', 'v0v1') + p = EvenDoors::Twirl.require_p EvenDoors::Particle + EvenDoors::Twirl.clear! + p['f0']='v0' + p['f1']='v1' + door0.send_p p + EvenDoors::Twirl.run = true + EvenDoors::Twirl.twirl! + door1.ps.length.should eql 2 + p0 = door1.ps[0] + p0.action.should be_nil + p0.src.should be door0 + p0.dst.should be door1 + p1 = door1.ps[1] + p1.action.should be_nil + p1.src.should be door0 + p1.dst.should be door1 + p1.should be p + end # end end |