diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-06-10 11:11:28 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-06-10 11:11:28 +0200 |
commit | 6553912a6dff9b2c8bd3f06cb5f10488eef2c18c (patch) | |
tree | 804cbb720c993afd5453ea4a8086b264e22382fe /spec/room_spec.rb | |
parent | 74d45762846ea7e6ac09f65fb31672b822f7a349 (diff) | |
download | edoors-ruby-6553912a6dff9b2c8bd3f06cb5f10488eef2c18c.zip edoors-ruby-6553912a6dff9b2c8bd3f06cb5f10488eef2c18c.tar.gz |
project iotas->edoors-ruby, module Iotas->Edoors
Diffstat (limited to 'spec/room_spec.rb')
-rw-r--r-- | spec/room_spec.rb | 236 |
1 files changed, 118 insertions, 118 deletions
diff --git a/spec/room_spec.rb b/spec/room_spec.rb index de4b55e..1c994e2 100644 --- a/spec/room_spec.rb +++ b/spec/room_spec.rb @@ -4,10 +4,10 @@ require 'spec_helper' # -describe Iotas::Room do +describe Edoors::Room do # before (:all) do - @spin = Iotas::Spin.new 'dom0' + @spin = Edoors::Spin.new 'dom0' end # before(:each) do @@ -15,16 +15,16 @@ describe Iotas::Room do end # it "add_iota and add_link correctly" do - r0 = Iotas::Room.new 'room0', @spin - d0 = Iotas::Door.new 'door0', r0 - lambda { Iotas::Door.new('door0', r0) }.should raise_error(Iotas::Exception) - lambda { r0.add_iota Iotas::Door.new('door1', r0) }.should raise_error(Iotas::Exception) - r0.add_link Iotas::Link.new 'door0', 'somewhere' - lambda { r0.add_link(Iotas::Link.new('nowhere', 'somewhere')) }.should raise_error(Iotas::Exception) + r0 = Edoors::Room.new 'room0', @spin + d0 = Edoors::Door.new 'door0', r0 + lambda { Edoors::Door.new('door0', r0) }.should raise_error(Edoors::Exception) + lambda { r0.add_iota Edoors::Door.new('door1', r0) }.should raise_error(Edoors::Exception) + r0.add_link Edoors::Link.new 'door0', 'somewhere' + lambda { r0.add_link(Edoors::Link.new('nowhere', 'somewhere')) }.should raise_error(Edoors::Exception) end # it "start! and stop! should work" do - r0 = Iotas::Room.new 'room0', @spin + r0 = Edoors::Room.new 'room0', @spin d0 = Fake.new 'fake', r0 d0.start.should be_nil d0.stop.should be_nil @@ -37,11 +37,11 @@ describe Iotas::Room do end # it "parent, spin and search_down should be ok" do - r0 = Iotas::Room.new 'r0', @spin - r1 = Iotas::Room.new 'r1', r0 - r2 = Iotas::Room.new 'r2', r1 - r3 = Iotas::Room.new 'r3', @spin - r4 = Iotas::Room.new 'r4', r3 + r0 = Edoors::Room.new 'r0', @spin + r1 = Edoors::Room.new 'r1', r0 + r2 = Edoors::Room.new 'r2', r1 + r3 = Edoors::Room.new 'r3', @spin + r4 = Edoors::Room.new 'r4', r3 r2.parent.should be r1 r1.parent.should be r0 r0.parent.should be @spin @@ -59,9 +59,9 @@ describe Iotas::Room do end # it "routing success (direct add_dst)" do - room0 = Iotas::Room.new 'room0', @spin - door0 = Iotas::Door.new 'door0', room0 - p = @spin.require_p Iotas::Particle + room0 = Edoors::Room.new 'room0', @spin + door0 = Edoors::Door.new 'door0', room0 + p = @spin.require_p Edoors::Particle p.init! Fake.new( 'fake', @spin) p.add_dst 'get', 'door0' room0.send_p p @@ -70,9 +70,9 @@ describe Iotas::Room do end # it "routing success (direct send to self)" do - room0 = Iotas::Room.new 'room0', @spin - door0 = Iotas::Door.new 'door0', room0 - p = @spin.require_p Iotas::Particle + room0 = Edoors::Room.new 'room0', @spin + door0 = Edoors::Door.new 'door0', room0 + p = @spin.require_p Edoors::Particle p.init! Fake.new( 'fake', @spin) door0.send_p p, 'get' p.action.should eql 'get' @@ -80,9 +80,9 @@ describe Iotas::Room do end # it "routing success (direct send to pointer)" do - room0 = Iotas::Room.new 'room0', @spin - door0 = Iotas::Door.new 'door0', room0 - p = @spin.require_p Iotas::Particle + room0 = Edoors::Room.new 'room0', @spin + door0 = Edoors::Door.new 'door0', room0 + p = @spin.require_p Edoors::Particle p.init! Fake.new( 'fake', @spin) door0.send_p p, 'get', door0 p.action.should eql 'get' @@ -90,9 +90,9 @@ describe Iotas::Room do end # it "routing success (direct send to path)" do - room0 = Iotas::Room.new 'room0', @spin - door0 = Iotas::Door.new 'door0', room0 - p = @spin.require_p Iotas::Particle + room0 = Edoors::Room.new 'room0', @spin + door0 = Edoors::Door.new 'door0', room0 + p = @spin.require_p Edoors::Particle p.init! Fake.new( 'fake', @spin) door0.send_p p, 'get', door0.path p.action.should eql 'get' @@ -100,10 +100,10 @@ describe Iotas::Room do end # it "routing success through Spin@world" do - room0 = Iotas::Room.new 'room0', @spin - room1 = Iotas::Room.new 'room1', room0 - door0 = Iotas::Door.new 'door0', room1 - p = @spin.require_p Iotas::Particle + room0 = Edoors::Room.new 'room0', @spin + room1 = Edoors::Room.new 'room1', room0 + door0 = Edoors::Door.new 'door0', room1 + p = @spin.require_p Edoors::Particle p.init! Fake.new('fake', @spin) p.add_dst 'get', 'dom0/room0/room1/door0' room0.send_p p @@ -112,75 +112,75 @@ describe Iotas::Room do end # it "route error: no source" do - room = Iotas::Room.new 'room', @spin - p = @spin.require_p Iotas::Particle + room = Edoors::Room.new 'room', @spin + p = @spin.require_p Edoors::Particle p.add_dst 'get', 'room/door' room.send_p p - p.action.should eql Iotas::ACT_ERROR - p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_NS + p.action.should eql Edoors::ACT_ERROR + p[Edoors::FIELD_ERROR_MSG].should eql Edoors::ERROR_ROUTE_NS p.dst.should be room.spin end # it "route error: no destination no links" do - room = Iotas::Room.new 'room', @spin - p = @spin.require_p Iotas::Particle + room = Edoors::Room.new 'room', @spin + p = @spin.require_p Edoors::Particle p.init! Fake.new('fake', @spin) room.send_p p - p.action.should eql Iotas::ACT_ERROR - p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_NDNL + p.action.should eql Edoors::ACT_ERROR + p[Edoors::FIELD_ERROR_MSG].should eql Edoors::ERROR_ROUTE_NDNL p.dst.should be p.src end # it "route error: no rooom, wrong door -> right room wrong door" do - room0 = Iotas::Room.new 'room0', @spin - p = @spin.require_p Iotas::Particle + room0 = Edoors::Room.new 'room0', @spin + p = @spin.require_p Edoors::Particle p.init! Fake.new('fake', @spin) p.add_dst 'get', 'nodoor' room0.send_p p - p.action.should eql Iotas::ACT_ERROR - p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_RRWD + p.action.should eql Edoors::ACT_ERROR + p[Edoors::FIELD_ERROR_MSG].should eql Edoors::ERROR_ROUTE_RRWD p.dst.should be p.src end # it "route error: right rooom, wrong door -> right room wrong door" do - room0 = Iotas::Room.new 'room0', @spin - p = @spin.require_p Iotas::Particle + room0 = Edoors::Room.new 'room0', @spin + p = @spin.require_p Edoors::Particle p.init! Fake.new('fake', @spin) p.add_dst 'get', 'dom0/room0/nodoor' room0.send_p p - p.action.should eql Iotas::ACT_ERROR - p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_RRWD + p.action.should eql Edoors::ACT_ERROR + p[Edoors::FIELD_ERROR_MSG].should eql Edoors::ERROR_ROUTE_RRWD p.dst.should be p.src end # it "route error: right room, wrong door through Spin@world -> does not exists" do - room0 = Iotas::Room.new 'room0', @spin - room1 = Iotas::Room.new 'room1', room0 - p = @spin.require_p Iotas::Particle + room0 = Edoors::Room.new 'room0', @spin + room1 = Edoors::Room.new 'room1', room0 + p = @spin.require_p Edoors::Particle p.init! Fake.new('fake', room0) p.add_dst 'get', 'dom0/room0/nodoor' room1.send_p p - p.action.should eql Iotas::ACT_ERROR - p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_DNE + p.action.should eql Edoors::ACT_ERROR + p[Edoors::FIELD_ERROR_MSG].should eql Edoors::ERROR_ROUTE_DNE p.dst.should be p.src end # it "route error: wrong room, right door through Spin@world -> does not exists" do - room0 = Iotas::Room.new 'room0', @spin - room1 = Iotas::Room.new 'room1', room0 - p = @spin.require_p Iotas::Particle + room0 = Edoors::Room.new 'room0', @spin + room1 = Edoors::Room.new 'room1', room0 + p = @spin.require_p Edoors::Particle p.init! Fake.new('fake', @spin) p.add_dst 'get', 'dom0/noroom/fake' room1.send_p p - p.action.should eql Iotas::ACT_ERROR - p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_DNE + p.action.should eql Edoors::ACT_ERROR + p[Edoors::FIELD_ERROR_MSG].should eql Edoors::ERROR_ROUTE_DNE p.dst.should be p.src end # it "routing ~failure: no door name -> src" do - room0 = Iotas::Room.new 'room0', @spin - door0 = Iotas::Door.new 'door0', room0 - p = @spin.require_p Iotas::Particle + room0 = Edoors::Room.new 'room0', @spin + door0 = Edoors::Door.new 'door0', room0 + p = @spin.require_p Edoors::Particle p.init! door0 p.add_dst 'get' room0.send_p p @@ -189,22 +189,22 @@ describe Iotas::Room do end # it "routing success: unconditional link" do - room0 = Iotas::Room.new 'room0', @spin - door0 = Iotas::Door.new 'door0', room0 - door1 = Iotas::Door.new 'door1', room0 - room0.add_link Iotas::Link.new('door0', 'door1') - p = @spin.require_p Iotas::Particle + 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') + p = @spin.require_p Edoors::Particle door0.send_p p p.action.should be_nil p.dst.should be door1 end # it "routing success: conditional link" do - room0 = Iotas::Room.new 'room0', @spin - door0 = Iotas::Door.new 'door0', room0 - door1 = Iotas::Door.new 'door1', room0 - room0.add_link Iotas::Link.new('door0', 'door1', 'fields', 'f0,f1', 'v0v1') - p = @spin.require_p Iotas::Particle + 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') + p = @spin.require_p Edoors::Particle p['f0']='v0' p['f1']='v1' door0.send_p p @@ -214,9 +214,9 @@ describe Iotas::Room do end # it "routing success: more then one matching link" do - room0 = Iotas::Room.new 'room0', @spin - door0 = Iotas::Door.new 'door0', room0 - class Out < Iotas::Door + room0 = Edoors::Room.new 'room0', @spin + door0 = Edoors::Door.new 'door0', room0 + class Out < Edoors::Door attr_reader :count def receive_p p @count||=0 @@ -224,10 +224,10 @@ describe Iotas::Room do end end door1 = Out.new 'door1', room0 - room0.add_link Iotas::Link.new('door0', 'door1') - room0.add_link Iotas::Link.new('door0', 'door1', 'fields', 'f0,f1', 'v0v1') - room0.add_link Iotas::Link.new('door0', 'door1', 'fields', 'f0,f1', 'v0v2') - p = @spin.require_p Iotas::Particle + 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') + p = @spin.require_p Edoors::Particle p['f0']='v0' p['f1']='v1' door0.send_p p @@ -236,55 +236,55 @@ describe Iotas::Room do end # it "system route error: system no destination" do - room0 = Iotas::Room.new 'room0', @spin - p = @spin.require_p Iotas::Particle + room0 = Edoors::Room.new 'room0', @spin + p = @spin.require_p Edoors::Particle room0.send_sys_p p - p.action.should eql Iotas::ACT_ERROR - p[Iotas::FIELD_ERROR_MSG].should eql Iotas::ERROR_ROUTE_SND + p.action.should eql Edoors::ACT_ERROR + p[Edoors::FIELD_ERROR_MSG].should eql Edoors::ERROR_ROUTE_SND end # it "system routing success: action only" do - room0 = Iotas::Room.new 'room0', @spin - p = @spin.require_p Iotas::Particle - p.add_dst Iotas::SYS_ACT_ADD_LINK + room0 = Edoors::Room.new 'room0', @spin + p = @spin.require_p Edoors::Particle + p.add_dst Edoors::SYS_ACT_ADD_LINK room0.send_sys_p p - p.action.should eql Iotas::SYS_ACT_ADD_LINK + p.action.should eql Edoors::SYS_ACT_ADD_LINK p.dst.should be room0.spin end # it "system routing success (add_dst)" do - room0 = Iotas::Room.new 'room0', @spin - door0 = Iotas::Door.new 'door0', room0 - p = @spin.require_p Iotas::Particle - p.add_dst Iotas::SYS_ACT_ADD_LINK, 'dom0/room0/door0' + room0 = Edoors::Room.new 'room0', @spin + door0 = Edoors::Door.new 'door0', room0 + p = @spin.require_p Edoors::Particle + p.add_dst Edoors::SYS_ACT_ADD_LINK, 'dom0/room0/door0' room0.send_sys_p p - p.action.should eql Iotas::SYS_ACT_ADD_LINK + p.action.should eql Edoors::SYS_ACT_ADD_LINK p.dst.should be door0 end # it "system routing success (send_sys_p)" do - room0 = Iotas::Room.new 'room0', @spin - door0 = Iotas::Door.new 'door0', room0 - p = @spin.require_p Iotas::Particle - door0.send_sys_p p, Iotas::SYS_ACT_ADD_LINK - p.action.should eql Iotas::SYS_ACT_ADD_LINK + room0 = Edoors::Room.new 'room0', @spin + door0 = Edoors::Door.new 'door0', room0 + p = @spin.require_p Edoors::Particle + door0.send_sys_p p, Edoors::SYS_ACT_ADD_LINK + p.action.should eql Edoors::SYS_ACT_ADD_LINK p.dst.should be door0 end # it "SYS_ACT_ADD_LINK" do - room0 = Iotas::Room.new 'room0', @spin - door0 = Iotas::Door.new 'door0', room0 - door1 = Iotas::Door.new 'door1', room0 - p0 = @spin.require_p Iotas::Particle - p0.set_data Iotas::LNK_SRC, 'door0' - p0.set_data Iotas::LNK_DSTS, 'door1' - p0.set_data Iotas::LNK_FIELDS, 'fields' - p0.set_data Iotas::LNK_CONDF, 'f0,f1' - p0.set_data Iotas::LNK_CONDV, 'v0v1' - p0.add_dst Iotas::SYS_ACT_ADD_LINK, room0.path + room0 = Edoors::Room.new 'room0', @spin + door0 = Edoors::Door.new 'door0', room0 + door1 = Edoors::Door.new 'door1', room0 + 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.add_dst Edoors::SYS_ACT_ADD_LINK, room0.path room0.send_sys_p p0 @spin.spin! - p = @spin.require_p Iotas::Particle + p = @spin.require_p Edoors::Particle p['f0']='v0' p['f1']='v1' door0.send_p p @@ -294,19 +294,19 @@ describe Iotas::Room do end # it "room->json->room" do - r0 = Iotas::Room.new 'r0', @spin - r1 = Iotas::Room.new 'r1', r0 - r2 = Iotas::Room.new 'r2', r1 - r3 = Iotas::Room.new 'r3', r1 - r4 = Iotas::Room.new 'r4', r3 - d0 = Iotas::Door.new 'd0', r1 - d1 = Iotas::Door.new 'd1', r1 - d2 = Iotas::Door.new 'd2', r2 - r1.add_link Iotas::Link.new('d0', 'd1', 'fields', 'f0,f1', 'v0v1') - r1.add_link Iotas::Link.new('d0', 'd2') - r1.add_link Iotas::Link.new('d1', 'd0') - r2.add_link Iotas::Link.new('d2', 'd1', 'fies', 'f5,f1', 'v9v1') - rx = Iotas::Room.json_create( JSON.load( JSON.generate(r0) ) ) + r0 = Edoors::Room.new 'r0', @spin + r1 = Edoors::Room.new 'r1', r0 + r2 = Edoors::Room.new 'r2', r1 + r3 = Edoors::Room.new 'r3', r1 + r4 = Edoors::Room.new 'r4', r3 + 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', 'd2') + r1.add_link Edoors::Link.new('d1', 'd0') + r2.add_link Edoors::Link.new('d2', 'd1', 'fies', 'f5,f1', 'v9v1') + rx = Edoors::Room.json_create( JSON.load( JSON.generate(r0) ) ) JSON.generate(r0).should eql JSON.generate(rx) end# # |