summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKOBAYASHI Shuji <[email protected]>2019-02-19 20:02:50 +0900
committerKOBAYASHI Shuji <[email protected]>2019-02-19 20:02:50 +0900
commit8a7298e069023b634c2011c4727d12f9fea725c2 (patch)
treef31aea66abd07e4f248638cd1be626679fbd348e
parent971bfd13c152bb9ac8f09737b89a228c88e15d66 (diff)
downloadmruby-8a7298e069023b634c2011c4727d12f9fea725c2.tar.gz
mruby-8a7298e069023b634c2011c4727d12f9fea725c2.zip
Use more appropriate assertion methods
-rw-r--r--mrbgems/mruby-metaprog/test/metaprog.rb11
-rw-r--r--test/t/bs_block.rb63
-rw-r--r--test/t/module.rb2
3 files changed, 39 insertions, 37 deletions
diff --git a/mrbgems/mruby-metaprog/test/metaprog.rb b/mrbgems/mruby-metaprog/test/metaprog.rb
index 748fe9c6c..8bc3719b8 100644
--- a/mrbgems/mruby-metaprog/test/metaprog.rb
+++ b/mrbgems/mruby-metaprog/test/metaprog.rb
@@ -143,8 +143,8 @@ assert('Module#class_variable_set', '15.2.2.4.18') do
end
end
- assert_true Test4ClassVariableSet.class_variable_set(:@@cv, 99)
- assert_true Test4ClassVariableSet.class_variable_set(:@@foo, 101)
+ assert_equal 99, Test4ClassVariableSet.class_variable_set(:@@cv, 99)
+ assert_equal 101, Test4ClassVariableSet.class_variable_set(:@@foo, 101)
assert_true Test4ClassVariableSet.class_variables.include? :@@cv
assert_equal 99, Test4ClassVariableSet.class_variable_get(:@@cv)
assert_equal 101, Test4ClassVariableSet.new.foo
@@ -238,9 +238,10 @@ assert('Module#remove_method', '15.2.2.4.41') do
end
end
- assert_true Test4RemoveMethod::Child.class_eval{ remove_method :hello }
- assert_true Test4RemoveMethod::Child.instance_methods.include? :hello
- assert_false Test4RemoveMethod::Child.instance_methods(false).include? :hello
+ klass = Test4RemoveMethod::Child
+ assert_same klass, klass.class_eval{ remove_method :hello }
+ assert_true klass.instance_methods.include? :hello
+ assert_false klass.instance_methods(false).include? :hello
end
assert('Module.nesting', '15.2.2.2.2') do
diff --git a/test/t/bs_block.rb b/test/t/bs_block.rb
index 62eb7e32e..995e52559 100644
--- a/test/t/bs_block.rb
+++ b/test/t/bs_block.rb
@@ -408,42 +408,43 @@ assert('BS Block 32') do
end
assert('BS Block [ruby-core:14395]') do
- class Controller
- def respond_to(&block)
- responder = Responder.new
- block.call(responder)
- responder.respond
- end
- def test_for_bug
- respond_to{|format|
- format.js{
- "in test"
- render{|obj|
- obj
+ assert_nothing_raised do
+ class Controller
+ def respond_to(&block)
+ responder = Responder.new
+ block.call(responder)
+ responder.respond
+ end
+ def test_for_bug
+ respond_to{|format|
+ format.js{
+ "in test"
+ render{|obj|
+ obj
+ }
}
}
- }
- end
- def render(&block)
- "in render"
- end
- end
-
- class Responder
- def method_missing(symbol, &block)
- "enter method_missing"
- @response = Proc.new{
- 'in method missing'
- block.call
- }
- "leave method_missing"
+ end
+ def render(&block)
+ "in render"
+ end
end
- def respond
- @response.call
+ class Responder
+ def method_missing(symbol, &block)
+ "enter method_missing"
+ @response = Proc.new{
+ 'in method missing'
+ block.call
+ }
+ "leave method_missing"
+ end
+ def respond
+ @response.call
+ end
end
+ t = Controller.new
+ t.test_for_bug
end
- t = Controller.new
- assert_true t.test_for_bug
end
assert("BS Block 33") do
diff --git a/test/t/module.rb b/test/t/module.rb
index f01245e88..b2dbe52a2 100644
--- a/test/t/module.rb
+++ b/test/t/module.rb
@@ -231,7 +231,7 @@ assert('Module#const_set', '15.2.2.4.23') do
Const4Test4ConstSet = 42
end
- assert_true Test4ConstSet.const_set(:Const4Test4ConstSet, 23)
+ assert_equal 23, Test4ConstSet.const_set(:Const4Test4ConstSet, 23)
assert_equal 23, Test4ConstSet.const_get(:Const4Test4ConstSet)
end