summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-09 07:21:50 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-09 07:21:50 +0000
commit56486e00ecd02007787620e814c991f94d68ff49 (patch)
treead318ee95563d9b2524fcdd6572d02504600a141 /test
parentf4c52b483cb4794e3e0e526a084cdbd32da8086c (diff)
test_{env,hash}.rb: descriptive assertions
* test/ruby/test_{env,hash}.rb: use descriptive assertions than plain assert. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_env.rb12
-rw-r--r--test/ruby/test_hash.rb50
2 files changed, 31 insertions, 31 deletions
diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb
index ced00c30cc..618be37214 100644
--- a/test/ruby/test_env.rb
+++ b/test/ruby/test_env.rb
@@ -270,15 +270,15 @@ class TestEnv < Test::Unit::TestCase
def test_empty_p
ENV.clear
- assert(ENV.empty?)
+ assert_predicate(ENV, :empty?)
ENV["test"] = "foo"
- assert(!ENV.empty?)
+ assert_not_predicate(ENV, :empty?)
end
def test_has_key
- assert(!ENV.has_key?("test"))
+ assert_not_send([ENV, :has_key?, "test"])
ENV["test"] = "foo"
- assert(ENV.has_key?("test"))
+ assert_send([ENV, :has_key?, "test"])
assert_raise(ArgumentError) { ENV.has_key?("foo\0bar") }
end
@@ -298,9 +298,9 @@ class TestEnv < Test::Unit::TestCase
def test_has_value2
ENV.clear
- assert(!ENV.has_value?("foo"))
+ assert_not_send([ENV, :has_value?, "foo"])
ENV["test"] = "foo"
- assert(ENV.has_value?("foo"))
+ assert_send([ENV, :has_value?, "foo"])
end
def test_rassoc
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 01a0706c3e..4aee4a05b6 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -21,8 +21,8 @@ class TestHash < Test::Unit::TestCase
end)
assert_equal(3, x.length)
- assert(x.has_key?(1))
- assert(x.has_value?(4))
+ assert_send([x, :has_key?, 1])
+ assert_send([x, :has_value?, 4])
assert_equal([4,6], x.values_at(2,3))
assert_equal({1=>2, 2=>4, 3=>6}, x)
@@ -208,17 +208,17 @@ class TestHash < Test::Unit::TestCase
h2 = @cls[ "a" => 1, "c" => 2, 7 => 35 ]
h3 = @cls[ "a" => 1, "c" => 2, 7 => 35 ]
h4 = @cls[ ]
- assert(h1 == h1)
- assert(h2 == h2)
- assert(h3 == h3)
- assert(h4 == h4)
- assert(!(h1 == h2))
- assert(h2 == h3)
- assert(!(h3 == h4))
+ assert_equal(h1, h1)
+ assert_equal(h2, h2)
+ assert_equal(h3, h3)
+ assert_equal(h4, h4)
+ assert_not_equal(h1, h2)
+ assert_equal(h2, h3)
+ assert_not_equal(h3, h4)
end
def test_clear
- assert(@h.size > 0)
+ assert_operator(@h.size, :>, 0)
@h.clear
assert_equal(0, @h.size)
assert_nil(@h[1])
@@ -235,7 +235,7 @@ class TestHash < Test::Unit::TestCase
b = a.clone
assert_equal(a, b)
- assert(a.__id__ != b.__id__)
+ assert_not_same(a, b)
assert_equal(a.frozen?, b.frozen?)
assert_equal(a.untrusted?, b.untrusted?)
assert_equal(a.tainted?, b.tainted?)
@@ -327,7 +327,7 @@ class TestHash < Test::Unit::TestCase
b = a.dup
assert_equal(a, b)
- assert(a.__id__ != b.__id__)
+ assert_not_same(a, b)
assert_equal(false, b.frozen?)
assert_equal(a.tainted?, b.tainted?)
assert_equal(a.untrusted?, b.untrusted?)
@@ -397,8 +397,8 @@ class TestHash < Test::Unit::TestCase
end
def test_empty?
- assert(@cls[].empty?)
- assert(!@h.empty?)
+ assert_empty(@cls[])
+ assert_not_empty(@h)
end
def test_fetch
@@ -453,11 +453,11 @@ class TestHash < Test::Unit::TestCase
def test_values_at
res = @h.values_at('dog', 'cat', 'horse')
- assert(res.length == 3)
+ assert_equal(3, res.length)
assert_equal([nil, nil, nil], res)
res = @h.values_at
- assert(res.length == 0)
+ assert_equal(0, res.length)
res = @h.values_at(3, 2, 1, nil)
assert_equal 4, res.length
@@ -476,7 +476,7 @@ class TestHash < Test::Unit::TestCase
assert_equal(nil, h['nil'])
h.each do |k, v|
- assert(@h.key?(v)) # not true in general, but works here
+ assert_send([@h, :key?, v]) # not true in general, but works here
end
h = @cls[ 'a' => 1, 'b' => 2, 'c' => 1].invert
@@ -841,18 +841,18 @@ class TestHash < Test::Unit::TestCase
end
def test_equal2
- assert({} != 0)
+ assert_not_equal(0, {})
o = Object.new
def o.to_hash; {}; end
def o.==(x); true; end
- assert({} == o)
+ assert_equal({}, o)
def o.==(x); false; end
- assert({} != o)
+ assert_not_equal({}, o)
h1 = {1=>2}; h2 = {3=>4}
- assert(h1 != h2)
+ assert_not_equal(h1, h2)
h1 = {1=>2}; h2 = {1=>4}
- assert(h1 != h2)
+ assert_not_equal(h1, h2)
end
def test_eql
@@ -922,11 +922,11 @@ class TestHash < Test::Unit::TestCase
def test_compare_by_identity
a = "foo"
- assert(!{}.compare_by_identity?)
+ assert_not_predicate({}, :compare_by_identity?)
h = { a => "bar" }
- assert(!h.compare_by_identity?)
+ assert_not_predicate(h, :compare_by_identity?)
h.compare_by_identity
- assert(h.compare_by_identity?)
+ assert_predicate(h, :compare_by_identity?)
#assert_equal("bar", h[a])
assert_nil(h["foo"])
end