Skip to content

Commit

Permalink
change explanations of examples in rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
seiya committed Apr 21, 2011
1 parent 3ba61b6 commit 1304f54
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions spec/ruby-mpi_spec.rb
Expand Up @@ -8,7 +8,7 @@
MPI.Finalize()
end

it "should be able to ge version" do
it "should give version" do
MPI.constants.should include("VERSION")
MPI.constants.should include("SUBVERSION")
MPI::VERSION.class.should eql(Fixnum)
Expand All @@ -23,7 +23,7 @@
world.size.should > 0
end

it "should be able to send and receive String" do
it "should send and receive String" do
world = MPI::Comm::WORLD
message = "Hello from #{world.rank}"
tag = 0
Expand All @@ -40,7 +40,7 @@
end
end

it "should be able to send and receive NArray" do
it "should send and receive NArray" do
world = MPI::Comm::WORLD
tag = 0
[NArray[1,2,3], NArray[3.0,2.0,1.0]].each do |ary0|
Expand All @@ -59,29 +59,45 @@
end
end

it "should be able to send and receive without blocking" do
it "should send and receive without blocking" do
world = MPI::Comm::WORLD
message = "Hello from #{world.rank}"
tag = 0
request = world.Isend(message, 0, tag)
status = request.Wait
status.source.should eql(0)
status.source.should eql(world.rank)
status.tag.should eql(tag)
if world.rank == 0
world.size.times do |i|
str = " "*30
request = world.Irecv(str, i, tag)
status = request.Wait
status.source.should eql(0)
status.source.should eql(i)
status.tag.should eql(tag)
str.should match(/\AHello from #{i}+/)
end
end
end

it "should gather data" do
world = MPI::Comm::WORLD
rank = world.rank
size = world.size
root = 0
bufsize = 2
sendbuf = rank.to_s*bufsize
recvbuf = rank == root ? "?"*bufsize*size : nil
world.Gather(sendbuf, recvbuf, root)
if rank == root
str = ""
size.times{|i| str << i.to_s*bufsize}
recvbuf.should eql(str)
end
end



it "shoud be raise exeption" do
it "shoud raise exeption" do
world = MPI::Comm::WORLD
lambda{ world.Send("", -1, 0) }.should raise_error(MPI::ERR::RANK)
lambda{ world.Send("", world.size+1, 0) }.should raise_error(MPI::ERR::RANK)
Expand Down

0 comments on commit 1304f54

Please sign in to comment.