diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-07 15:35:22 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-07 15:35:22 +0200 |
commit | 6795890262d278b586fc4c2ea6744b8562712f1b (patch) | |
tree | aa492b9d38a2f5497061989f68dc7c9fe1f35c87 | |
parent | 28e869f93d60e12e01009875d83336b75b2763ab (diff) | |
download | edoors-ruby-6795890262d278b586fc4c2ea6744b8562712f1b.zip edoors-ruby-6795890262d278b586fc4c2ea6744b8562712f1b.tar.gz |
spec: Twirl.require_p and Twirl.release_p
-rw-r--r-- | spec/evendoors_spec.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/evendoors_spec.rb b/spec/evendoors_spec.rb index e25e425..e326107 100644 --- a/spec/evendoors_spec.rb +++ b/spec/evendoors_spec.rb @@ -1,6 +1,14 @@ #! /usr/bin/env ruby # -*- coding: UTF-8 -*- # +begin + require 'simplecov' + SimpleCov.start do + add_filter 'spec' + end +rescue LoadError +end +# require 'evendoors' # describe EvenDoors do @@ -9,4 +17,44 @@ describe EvenDoors do expect{ EvenDoors }.not_to raise_error(NameError) end # + describe EvenDoors::Twirl do + # + class MyP < EvenDoors::Particle; end + # + it "should correctly manage Particles pool" do + p0 = EvenDoors::Twirl.require_p EvenDoors::Particle + p1 = EvenDoors::Twirl.require_p EvenDoors::Particle + (p0===p1).should be_false + EvenDoors::Twirl.release_p p0 + p2 = EvenDoors::Twirl.require_p EvenDoors::Particle + (p0===p2).should be_true + end + # + it "should correctly manage different Particles classes" do + p0 = EvenDoors::Twirl.require_p EvenDoors::Particle + p1 = EvenDoors::Twirl.require_p EvenDoors::Particle + (p0===p1).should be_false + EvenDoors::Twirl.release_p p0 + p2 = EvenDoors::Twirl.require_p MyP + p3 = EvenDoors::Twirl.require_p MyP + (p2===p3).should be_false + EvenDoors::Twirl.release_p p2 + p4 = EvenDoors::Twirl.require_p MyP + (p2===p4).should be_true + end + # + it "should correctly release merged data" do + p0 = EvenDoors::Twirl.require_p EvenDoors::Particle + p1 = EvenDoors::Twirl.require_p EvenDoors::Particle + (p0===p1).should be_false + p0.merge! p1 + EvenDoors::Twirl.release_p p0 + p2 = EvenDoors::Twirl.require_p EvenDoors::Particle + (p2===p0).should be_true + p3 = EvenDoors::Twirl.require_p EvenDoors::Particle + (p3===p1).should be_true + end + # + end + # end |