Permalink
Browse files

Test @@_dummy_img_

  • Loading branch information...
1 parent c7c4bad commit 68fe654000e4da2ce333b68f3fbeb7f43ae66fac rmagick committed Mar 29, 2008
Showing with 31 additions and 0 deletions.
  1. +31 −0 test/Draw.rb
View
31 test/Draw.rb
@@ -5,12 +5,43 @@
require 'test/unit'
require 'test/unit/ui/console/testrunner'
+class Magick::Draw
+ def self._dummy_img_
+ @@_dummy_img_
+ end
+end
+
class Draw_UT < Test::Unit::TestCase
def setup
@draw = Magick::Draw.new
end
+ # Ensure @@_dummy_img_ class var is working properly
+ def test_dummy_img
+ # initially this variable is not defined.
+ assert_raise(NameError) do
+ Magick::Draw._dummy_img_
+ end
+
+ # cause it to become defined. save the object id.
+ @draw.get_type_metrics("ABCDEF")
+ dummy = nil
+ assert_nothing_raised do
+ dummy = Magick::Draw._dummy_img_
+ end
+
+ assert_instance_of(Magick::Image, dummy)
+
+ # ensure that it is always the same object
+ @draw.get_type_metrics("ABCDEF")
+ dummy2 = nil
+ assert_nothing_raised do
+ dummy2 = Magick::Draw._dummy_img_
+ end
+ assert_same(dummy, dummy2)
+ end
+
def test_patterns
img = Magick::Image.new(20,20)
assert_nothing_raised { @draw.fill_pattern = img }

0 comments on commit 68fe654

Please sign in to comment.