diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-10 09:31:26 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-10 09:31:26 +0200 |
commit | 6886fa096d832b0682eafe631922694653384994 (patch) | |
tree | b224ac22372483404305eecbe99528ae2b1b94cf /spec/door_spec.rb | |
parent | 274411458b30ba08a9e0adca0a0f5820e9a8648f (diff) | |
download | edoors-ruby-6886fa096d832b0682eafe631922694653384994.zip edoors-ruby-6886fa096d832b0682eafe631922694653384994.tar.gz |
split specs
Diffstat (limited to 'spec/door_spec.rb')
-rw-r--r-- | spec/door_spec.rb | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/spec/door_spec.rb b/spec/door_spec.rb new file mode 100644 index 0000000..93cd975 --- /dev/null +++ b/spec/door_spec.rb @@ -0,0 +1,70 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- +# + +require 'spec_helper' +# +describe EvenDoors::Door do + # + it "require_p release_p" do + door = EvenDoors::Door.new 'hell' + p0 = door.require_p EvenDoors::Particle + p0.src.should be door + p1 = door.require_p EvenDoors::Particle + p1.src.should be door + (p0===p1).should be_false + door.release_p p0 + p2 = door.require_p EvenDoors::Particle + p2.src.should be door + (p0===p2).should be_true + end + # + it "send_p, send_sys_p, release_p and release of lost particles" do + class Door0 < EvenDoors::Door + def receive_p p + case p.action + when 'RELEASE' + release_p p + when 'SEND' + send_p p + when 'SEND_SYS' + send_sys_p p + else + # lost!! + end + end + end + f = Fake.new + d0 = Door0.new 'door0', f + p0 = EvenDoors::Spin.require_p EvenDoors::Particle + # + p0.set_dst! 'SEND' + p0.split_dst! + d0.process_p p0 + f.p.should eql p0 + # + p0.set_dst! 'SEND_SYS' + p0.split_dst! + d0.process_p p0 + f.sp.should eql p0 + # + p0.set_dst! 'RELEASE' + p0.split_dst! + d0.process_p p0 + p1 = EvenDoors::Spin.require_p EvenDoors::Particle + p1.should be p0 + # + p0.set_dst! 'LOST' + p0.split_dst! + d0.process_p p0 + p1 = EvenDoors::Spin.require_p EvenDoors::Particle + p1.should be p0 + # + d0.process_sys_p p0 + p1 = EvenDoors::Spin.require_p EvenDoors::Particle + p1.should be p0 + end + # +end +# +# EOF |