diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/board_spec.rb | 32 | ||||
-rw-r--r-- | spec/door_spec.rb | 30 | ||||
-rw-r--r-- | spec/link_spec.rb | 22 | ||||
-rw-r--r-- | spec/particle_spec.rb | 80 | ||||
-rw-r--r-- | spec/room_spec.rb | 236 | ||||
-rw-r--r-- | spec/spec_helper.rb | 4 | ||||
-rw-r--r-- | spec/spin_spec.rb | 86 | ||||
-rw-r--r-- | spec/spot_spec.rb | 10 |
8 files changed, 250 insertions, 250 deletions
diff --git a/spec/board_spec.rb b/spec/board_spec.rb index 0499778..7e291c6 100644 --- a/spec/board_spec.rb +++ b/spec/board_spec.rb @@ -4,10 +4,10 @@ require 'spec_helper' # -describe Iotas::Board do +describe Edoors::Board do # before (:all) do - @spin = Iotas::Spin.new 'dom0' + @spin = Edoors::Spin.new 'dom0' end # before(:each) do @@ -15,23 +15,23 @@ describe Iotas::Board do end # it "require_p release_p" do - board = Iotas::Board.new 'hell', @spin - p0 = board.require_p Iotas::Particle - p1 = board.require_p Iotas::Particle + board = Edoors::Board.new 'hell', @spin + p0 = board.require_p Edoors::Particle + p1 = board.require_p Edoors::Particle (p0===p1).should be_false board.release_p p0 - p2 = board.require_p Iotas::Particle + p2 = board.require_p Edoors::Particle (p0===p2).should be_true end # it "particle wait and merge" do - p0 = Iotas::Particle.new + p0 = Edoors::Particle.new p0['k0'] = 'v0' p0['k1'] = 'neither' p0['k2'] = 'v2' p0.set_link_fields 'k0,k2' p0.link_value.should eql 'v0v2' - p1 = Iotas::Particle.new + p1 = Edoors::Particle.new p1['k0'] = 'v0' p1['k1'] = 'nore' p1['k2'] = 'v2' @@ -39,12 +39,12 @@ describe Iotas::Board do p1.link_value.should eql 'v0v2' P0 = p0 P1 = p1 - class Board0 < Iotas::Board + class Board0 < Edoors::Board attr_reader :ok, :follow def receive_p p @ok = false case p.action - when Iotas::ACT_FOLLOW + when Edoors::ACT_FOLLOW @follow = true @ok = (p===P0 and p.merged(0)===P1) else @@ -65,9 +65,9 @@ describe Iotas::Board do b0.process_p p0 p0.merged(0).should be_nil # need to set it to p0 too, so case in Board0 is ok - p0.add_dst Iotas::ACT_FOLLOW + p0.add_dst Edoors::ACT_FOLLOW p0.split_dst! - p1.add_dst Iotas::ACT_FOLLOW + p1.add_dst Edoors::ACT_FOLLOW p1.split_dst! b0.process_p p1 b0.ok.should be_true @@ -75,14 +75,14 @@ describe Iotas::Board do end # it "board->json->board" do - board = Iotas::Board.new 'hell', @spin - p0 = Iotas::Particle.new - p1 = Iotas::Particle.new + board = Edoors::Board.new 'hell', @spin + p0 = Edoors::Particle.new + p1 = Edoors::Particle.new p1['v0']=0 p1.set_link_fields 'v0' board.process_p p0 board.process_p p1 - hell = Iotas::Board.json_create( JSON.load( JSON.generate(board) ) ) + hell = Edoors::Board.json_create( JSON.load( JSON.generate(board) ) ) board.name.should eql hell.name JSON.generate(board).should eql JSON.generate(hell) end diff --git a/spec/door_spec.rb b/spec/door_spec.rb index 43b98a1..0c2dafe 100644 --- a/spec/door_spec.rb +++ b/spec/door_spec.rb @@ -4,10 +4,10 @@ require 'spec_helper' # -describe Iotas::Door do +describe Edoors::Door do # before (:all) do - @spin = Iotas::Spin.new 'dom0' + @spin = Edoors::Spin.new 'dom0' end # before(:each) do @@ -15,26 +15,26 @@ describe Iotas::Door do end # it "require_p release_p" do - door = Iotas::Door.new 'hell', @spin - p0 = door.require_p Iotas::Particle - p1 = door.require_p Iotas::Particle + door = Edoors::Door.new 'hell', @spin + p0 = door.require_p Edoors::Particle + p1 = door.require_p Edoors::Particle (p0===p1).should be_false door.release_p p0 - p2 = door.require_p Iotas::Particle + p2 = door.require_p Edoors::Particle (p0===p2).should be_true end # it "NoMethodError when receive_p not overridden" do - class Door0 < Iotas::Door + class Door0 < Edoors::Door end f = Fake.new 'fake', @spin d0 = Door0.new 'door0', f - p0 = d0.require_p Iotas::Particle + p0 = d0.require_p Edoors::Particle lambda { d0.process_p p0 }.should raise_error(NoMethodError) end # it "send_p, send_sys_p, release_p and release of lost particles" do - class Door0 < Iotas::Door + class Door0 < Edoors::Door def receive_p p case p.action when 'RELEASE' @@ -50,7 +50,7 @@ describe Iotas::Door do end f = Fake.new 'fake', @spin d0 = Door0.new 'door0', f - p0 = d0.require_p Iotas::Particle + p0 = d0.require_p Edoors::Particle # p0.add_dst 'SEND' p0.split_dst! @@ -67,25 +67,25 @@ describe Iotas::Door do p0.add_dst 'RELEASE' p0.split_dst! d0.process_p p0 - p1 = d0.require_p Iotas::Particle + p1 = d0.require_p Edoors::Particle p1.should be p0 p0.clear_dsts! # p0.add_dst 'LOST' p0.split_dst! d0.process_p p0 - p1 = d0.require_p Iotas::Particle + p1 = d0.require_p Edoors::Particle p1.should be p0 p0.clear_dsts! # d0.process_sys_p p0 - p1 = @spin.require_p Iotas::Particle + p1 = @spin.require_p Edoors::Particle p1.should be p0 end # it "door->json->door" do - door = Iotas::Door.new 'hell', @spin - hell = Iotas::Door.json_create( JSON.load( JSON.generate(door) ) ) + door = Edoors::Door.new 'hell', @spin + hell = Edoors::Door.json_create( JSON.load( JSON.generate(door) ) ) door.name.should eql hell.name JSON.generate(door).should eql JSON.generate(hell) end diff --git a/spec/link_spec.rb b/spec/link_spec.rb index 6120677..0de1d93 100644 --- a/spec/link_spec.rb +++ b/spec/link_spec.rb @@ -4,17 +4,17 @@ require 'spec_helper' # -describe Iotas::Link do +describe Edoors::Link do # it "from particle data" do - @spin = Iotas::Spin.new 'dom0' - p = @spin.require_p Iotas::Particle - p.set_data Iotas::LNK_SRC, 'input1' - p.set_data Iotas::LNK_DSTS, 'concat1?follow,output1' - p.set_data Iotas::LNK_FIELDS, 'f0,f2' - p.set_data Iotas::LNK_CONDF, 'f0,f1,f2' - p.set_data Iotas::LNK_CONDV, 'v0v1v2' - lnk = Iotas::Link.from_particle_data p + @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 lnk.src.should eql 'input1' lnk.dsts.should eql 'concat1?follow,output1' lnk.fields.should eql 'f0,f2' @@ -23,8 +23,8 @@ describe Iotas::Link do end # it "link->json->link" do - link = Iotas::Link.new 'input1', 'concat1?follow,output1', 'f0,f2', 'f0,f1,f2', 'v0v1v2' - lnk = Iotas::Link.json_create( JSON.load( JSON.generate(link) ) ) + link = Edoors::Link.new 'input1', 'concat1?follow,output1', 'f0,f2', 'f0,f1,f2', 'v0v1v2' + 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 diff --git a/spec/particle_spec.rb b/spec/particle_spec.rb index a10a9f9..b738343 100644 --- a/spec/particle_spec.rb +++ b/spec/particle_spec.rb @@ -4,10 +4,10 @@ require 'spec_helper' # -describe Iotas::Particle do +describe Edoors::Particle do # it "payload manipulation" do - p = Iotas::Particle.new + p = Edoors::Particle.new # p['key']=666 p['key'].should eql 666 @@ -21,10 +21,10 @@ describe Iotas::Particle do end # it "payload clone" do - p = Iotas::Particle.new + p = Edoors::Particle.new p['k00'] = { 'k0'=>0,'k1'=>1} p['k11'] = [1,2,3] - o = Iotas::Particle.new + o = Edoors::Particle.new o.clone_data p p['k00']=nil p['k00'].should be_nil @@ -38,9 +38,9 @@ describe Iotas::Particle do end # it "particle merge" do - p = Iotas::Particle.new - q = Iotas::Particle.new - o = Iotas::Particle.new + p = Edoors::Particle.new + q = Edoors::Particle.new + o = Edoors::Particle.new p.merge! q p.merge! o p.merged(0).should be q @@ -60,9 +60,9 @@ describe Iotas::Particle do end # it "routing: add_dsts, next_dst and dst_routed!" do - p = Iotas::Particle.new - d0 = Iotas::Door.new 'door0', nil - d1 = Iotas::Door.new 'door1', nil + p = Edoors::Particle.new + d0 = Edoors::Door.new 'door0', nil + 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' @@ -79,24 +79,24 @@ describe Iotas::Particle do end # it "wrong path should raise exeption" do - p = Iotas::Particle.new - lambda { p.add_dst 'action', '/room' }.should raise_error(Iotas::Exception) - lambda { p.add_dst 'action', 'room/' }.should raise_error(Iotas::Exception) - lambda { p.add_dst '', 'room/' }.should raise_error(Iotas::Exception) - lambda { p.add_dst 'action', 'room//door' }.should raise_error(Iotas::Exception) - lambda { p.add_dst ' ' }.should raise_error(Iotas::Exception) - lambda { p.add_dst ' ', '' }.should raise_error(Iotas::Exception) - lambda { p.add_dst 'f f' }.should raise_error(Iotas::Exception) - lambda { p.add_dst '', ' d' }.should raise_error(Iotas::Exception) - lambda { p.add_dst '' }.should raise_error(Iotas::Exception) - lambda { p.add_dst '', '' }.should raise_error(Iotas::Exception) + p = Edoors::Particle.new + lambda { p.add_dst 'action', '/room' }.should raise_error(Edoors::Exception) + lambda { p.add_dst 'action', 'room/' }.should raise_error(Edoors::Exception) + lambda { p.add_dst '', 'room/' }.should raise_error(Edoors::Exception) + lambda { p.add_dst 'action', 'room//door' }.should raise_error(Edoors::Exception) + lambda { p.add_dst ' ' }.should raise_error(Edoors::Exception) + lambda { p.add_dst ' ', '' }.should raise_error(Edoors::Exception) + lambda { p.add_dst 'f f' }.should raise_error(Edoors::Exception) + lambda { p.add_dst '', ' d' }.should raise_error(Edoors::Exception) + lambda { p.add_dst '' }.should raise_error(Edoors::Exception) + lambda { p.add_dst '', '' }.should raise_error(Edoors::Exception) lambda { p.add_dst nil }.should raise_error(TypeError) lambda { p.add_dst 'action', nil }.should raise_error(NoMethodError) end # it "routing: set_dst!" do - p = Iotas::Particle.new - d0 = Iotas::Door.new 'door0', nil + p = Edoors::Particle.new + d0 = Edoors::Door.new 'door0', nil # p.set_dst! 'action', d0 p.action.should eql 'action' @@ -104,8 +104,8 @@ describe Iotas::Particle do end # it "routing: add_dst and split_dst!" do - p = Iotas::Particle.new - d0 = Iotas::Door.new 'door0', nil + p = Edoors::Particle.new + d0 = Edoors::Door.new 'door0', nil # p.split_dst! p.room.should be_nil @@ -157,19 +157,19 @@ describe Iotas::Particle do end # it "routing: error!" do - p = Iotas::Particle.new - d = Iotas::Door.new 'door', nil + p = Edoors::Particle.new + d = Edoors::Door.new 'door', nil p.init! d p.add_dsts 'door?action,?action' p.next_dst.should eql 'door?action' p.error! 'err_msg' - p[Iotas::FIELD_ERROR_MSG].should eql 'err_msg' - p.action.should eq Iotas::ACT_ERROR + p[Edoors::FIELD_ERROR_MSG].should eql 'err_msg' + p.action.should eq Edoors::ACT_ERROR p.dst.should be d end # it "link fields and link value" do - p = Iotas::Particle.new + p = Edoors::Particle.new p['k0'] = 'v0' p['k1'] = 'v1' p['k2'] = 'v2' @@ -182,7 +182,7 @@ describe Iotas::Particle do end # it "apply_link!" do - p = Iotas::Particle.new + p = Edoors::Particle.new p['k0'] = 'v0' p['k1'] = 'v1' p['k2'] = 'v2' @@ -191,7 +191,7 @@ describe Iotas::Particle do p.src.should be_nil p.link_value.should eql 'v0v2' p.next_dst.should eql 'door?action' - lnk = Iotas::Link.new('door0', 'door1?get,door2', 'k1', 'f0,f1', 'v0v1') + lnk = Edoors::Link.new('door0', 'door1?get,door2', 'k1', 'f0,f1', 'v0v1') f = Fake.new 'fake', nil lnk.door = f p.apply_link! lnk @@ -201,12 +201,12 @@ describe Iotas::Particle do end # it "particle->json->particle" do - s0 = Iotas::Spin.new 'top' - s1 = Iotas::Room.new 'room0', s0 - s2 = Iotas::Room.new 'room1', s1 - s3 = Iotas::Door.new 'doora', s2 - s4 = Iotas::Door.new 'doorb', s1 - p0 = Iotas::Particle.new + s0 = Edoors::Spin.new 'top' + s1 = Edoors::Room.new 'room0', s0 + s2 = Edoors::Room.new 'room1', s1 + s3 = Edoors::Door.new 'doora', s2 + s4 = Edoors::Door.new 'doorb', s1 + p0 = Edoors::Particle.new p0['k0'] = 'v0' p0['k1'] = 'v1' p0['k2'] = 'v2' @@ -214,7 +214,7 @@ describe Iotas::Particle do p0.set_link_fields 'k0,k2' p0.add_dsts 'room0/room1/room2/doorX?myaction,door?action,?action' p0.split_dst! - p1 = Iotas::Particle.new + p1 = Edoors::Particle.new p1['k3'] = 'v6' p1['k4'] = 'v7' p1['k5'] = 'v8' @@ -225,7 +225,7 @@ describe Iotas::Particle do p0.merge! p1 o = JSON.load( JSON.generate(p0) ) o['spin'] = s0 - px = Iotas::Particle.json_create( o ) + px = Edoors::Particle.json_create( o ) ((px.ts-p0.ts)<0.5).should be_true px.src.should be s3 px.dst.should be_nil 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# # diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5a549c5..0e500dd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,9 +9,9 @@ begin rescue LoadError end # -require 'iotas' +require 'edoors' # -class Fake < Iotas::Iota +class Fake < Edoors::Iota attr_reader :p, :sp, :start, :stop def process_p p @p = p diff --git a/spec/spin_spec.rb b/spec/spin_spec.rb index 69266e5..93ddf27 100644 --- a/spec/spin_spec.rb +++ b/spec/spin_spec.rb @@ -4,24 +4,24 @@ require 'spec_helper' # -describe Iotas::Spin do +describe Edoors::Spin do # - class MyP < Iotas::Particle; end + class MyP < Edoors::Particle; end # it "Particles pool" do - spin = Iotas::Spin.new 'dom0' - p0 = spin.require_p Iotas::Particle - p1 = spin.require_p Iotas::Particle + spin = Edoors::Spin.new 'dom0' + p0 = spin.require_p Edoors::Particle + p1 = spin.require_p Edoors::Particle (p0===p1).should be_false spin.release_p p0 - p2 = spin.require_p Iotas::Particle + p2 = spin.require_p Edoors::Particle (p0===p2).should be_true end # it "different Particles classes in pool" do - spin = Iotas::Spin.new 'dom0' - p0 = spin.require_p Iotas::Particle - p1 = spin.require_p Iotas::Particle + spin = Edoors::Spin.new 'dom0' + p0 = spin.require_p Edoors::Particle + p1 = spin.require_p Edoors::Particle (p0===p1).should be_false spin.release_p p0 p2 = spin.require_p MyP @@ -33,36 +33,36 @@ describe Iotas::Spin do end # it "release of merged particles" do - spin = Iotas::Spin.new 'dom0' - p0 = spin.require_p Iotas::Particle - p1 = spin.require_p Iotas::Particle + spin = Edoors::Spin.new 'dom0' + p0 = spin.require_p Edoors::Particle + p1 = spin.require_p Edoors::Particle (p0===p1).should be_false p0.merge! p1 spin.release_p p0 - p2 = spin.require_p Iotas::Particle + p2 = spin.require_p Edoors::Particle (p2===p0).should be_true - p3 = spin.require_p Iotas::Particle + p3 = spin.require_p Edoors::Particle (p3===p1).should be_true end # it "clear!" do - spin = Iotas::Spin.new 'dom0' - p0 = spin.require_p Iotas::Particle - p1 = spin.require_p Iotas::Particle + spin = Edoors::Spin.new 'dom0' + p0 = spin.require_p Edoors::Particle + p1 = spin.require_p Edoors::Particle spin.send_p p0 spin.release_p p1 spin.clear! - p2 = spin.require_p Iotas::Particle + p2 = spin.require_p Edoors::Particle (p2==p0).should be_false (p2==p1).should be_false end # it "post_p post_sys_p spin!" do - spin = Iotas::Spin.new 'dom0' + spin = Edoors::Spin.new 'dom0' f = Fake.new 'fake', spin - p0 = spin.require_p Iotas::Particle + p0 = spin.require_p Edoors::Particle p0.dst_routed! f - p1 = spin.require_p Iotas::Particle + p1 = spin.require_p Edoors::Particle p1.dst_routed! f spin.post_p p0 spin.post_sys_p p1 @@ -74,52 +74,52 @@ describe Iotas::Spin do end # it "process_sys" do - spin = Iotas::Spin.new 'dom0' - p0 = spin.require_p Iotas::Particle + spin = Edoors::Spin.new 'dom0' + p0 = spin.require_p Edoors::Particle p0.add_dst 'unknown' spin.send_sys_p p0 spin.spin! - p1 = spin.require_p Iotas::Particle + p1 = spin.require_p Edoors::Particle p0.should be p0 end # it "option debug" do - spin = Iotas::Spin.new 'dom0' + spin = Edoors::Spin.new 'dom0' spin.debug_routing.should be false spin.debug_errors.should be false - spin = Iotas::Spin.new 'dom0', :debug_routing=>true, :debug_errors=>true + spin = Edoors::Spin.new 'dom0', :debug_routing=>true, :debug_errors=>true spin.debug_routing.should be true spin.debug_errors.should be true end # it "spin->json->spin" do - spin = Iotas::Spin.new 'dom0', :debug_routing=>true - 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 - p0 = spin.require_p Iotas::Particle - p1 = spin.require_p Iotas::Particle - p2 = spin.require_p Iotas::Particle + spin = Edoors::Spin.new 'dom0', :debug_routing=>true + 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 + p0 = spin.require_p Edoors::Particle + p1 = spin.require_p Edoors::Particle + p2 = spin.require_p Edoors::Particle spin.post_p p0 spin.post_p p1 spin.post_sys_p p2 json = JSON.generate spin - dom0 = Iotas::Spin.json_create( JSON.load( json ) ) + dom0 = Edoors::Spin.json_create( JSON.load( json ) ) json.should eql JSON.generate(dom0) end # it "hibernate! resume!" do - spin = Iotas::Spin.new 'dom0' - p0 = spin.require_p Iotas::Particle - p0.add_dst Iotas::SYS_ACT_HIBERNATE + spin = Edoors::Spin.new 'dom0' + p0 = spin.require_p Edoors::Particle + p0.add_dst Edoors::SYS_ACT_HIBERNATE spin.send_sys_p p0 spin.spin! - dom0 = Iotas::Spin.resume! spin.hibernate_path + dom0 = Edoors::Spin.resume! spin.hibernate_path dom0.name.should eql spin.name File.unlink dom0.hibernate_path end diff --git a/spec/spot_spec.rb b/spec/spot_spec.rb index 1ed2b03..38f61b7 100644 --- a/spec/spot_spec.rb +++ b/spec/spot_spec.rb @@ -4,10 +4,10 @@ require 'spec_helper' # -describe Iotas::Iota do +describe Edoors::Iota do # it "path construction" do - class S<Iotas::Iota + class S<Edoors::Iota def add_iota s end end @@ -16,9 +16,9 @@ describe Iotas::Iota do s2 = S.new 'room1', s1 s3 = S.new 'door', s2 s3.path.should eql 'top/room0/room1/door' - lambda { Iotas::Iota.new('do/or0', nil) }.should raise_error(Iotas::Exception) - lambda { Iotas::Iota.new('/door0', nil) }.should raise_error(Iotas::Exception) - lambda { Iotas::Iota.new('door0/', nil) }.should raise_error(Iotas::Exception) + lambda { Edoors::Iota.new('do/or0', nil) }.should raise_error(Edoors::Exception) + lambda { Edoors::Iota.new('/door0', nil) }.should raise_error(Edoors::Exception) + lambda { Edoors::Iota.new('door0/', nil) }.should raise_error(Edoors::Exception) end # end |