summaryrefslogtreecommitdiff
path: root/test/digest
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-25 13:32:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-25 13:32:48 +0000
commit3e7c68119c1528f1589e53d9a795bc303dbddc1c (patch)
tree6a47a01e7c662997b80cd0e87443ad94e83700a8 /test/digest
parent7df8b94926b79f280ed0be387897fa3d0187fb44 (diff)
* test/digest/test_digest_extend.rb (TestDigestExtend#setup):
should not depend on the result of previous tests * test/with_diffent_ofs.rb (DifferentOFS::WithDifferentOFS): give name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/digest')
-rw-r--r--test/digest/test_digest_extend.rb31
1 files changed, 20 insertions, 11 deletions
diff --git a/test/digest/test_digest_extend.rb b/test/digest/test_digest_extend.rb
index 131f90d..8f541af 100644
--- a/test/digest/test_digest_extend.rb
+++ b/test/digest/test_digest_extend.rb
@@ -38,6 +38,10 @@ class TestDigestExtend < Test::Unit::TestCase
end
end
+ def setup
+ @MyDigest = Class.new(MyDigest)
+ end
+
def test_digest_s_hexencode
assert_equal('', Digest.hexencode(''))
assert_equal('0102', Digest.hexencode("\1\2"))
@@ -63,11 +67,11 @@ class TestDigestExtend < Test::Unit::TestCase
end
def test_hexdigest
- assert_equal("03", MyDigest.hexdigest("foo"))
+ assert_equal("03", @MyDigest.hexdigest("foo"))
end
def test_context
- digester = MyDigest.new
+ digester = @MyDigest.new
digester.update("foo")
assert_equal("\3", digester.digest)
digester.update("foobar")
@@ -91,7 +95,7 @@ class TestDigestExtend < Test::Unit::TestCase
[:digest, :hexdigest].each do |m|
exp_1st = "\3"; exp_1st = Digest.hexencode(exp_1st) if m == :hexdigest
exp_2nd = "\6"; exp_2nd = Digest.hexencode(exp_2nd) if m == :hexdigest
- digester = MyDigest.new
+ digester = @MyDigest.new
digester.update("foo")
obj = digester.send(m)
# digest w/o param does not reset the org digester.
@@ -108,7 +112,7 @@ class TestDigestExtend < Test::Unit::TestCase
def test_digest_hexdigest_bang
[:digest!, :hexdigest!].each do |m|
exp_1st = "\3"; exp_1st = Digest.hexencode(exp_1st) if m == :hexdigest!
- digester = MyDigest.new
+ digester = @MyDigest.new
digester.update("foo")
obj = digester.send(m) # digest! always resets the org digester.
assert_equal(exp_1st, obj)
@@ -119,30 +123,35 @@ class TestDigestExtend < Test::Unit::TestCase
end
def test_to_s
- digester = MyDigest.new
+ digester = @MyDigest.new
digester.update("foo")
assert_equal("03", digester.to_s)
end
def test_length
- digester = MyDigest.new
+ @MyDigest.class_eval do
+ def digest_length
+ 2
+ end
+ end
+ digester = @MyDigest.new
assert_equal(2, digester.length)
assert_equal(2, digester.size)
end
- def test_digest_length # breaks MyDigest#digest_length
- assert_equal(1, MyDigest.new.digest_length)
- MyDigest.class_eval do
+ def test_digest_length # breaks @MyDigest#digest_length
+ assert_equal(1, @MyDigest.new.digest_length)
+ @MyDigest.class_eval do
def digest_length
2
end
end
- assert_equal(2, MyDigest.new.digest_length)
+ assert_equal(2, @MyDigest.new.digest_length)
end
def test_block_length
assert_raises(RuntimeError) do
- MyDigest.new.block_length
+ @MyDigest.new.block_length
end
end
end