summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_autoload.rb10
-rw-r--r--test/ruby/test_const.rb2
-rw-r--r--test/ruby/test_file_exhaustive.rb2
-rw-r--r--test/ruby/test_iseq.rb4
-rw-r--r--test/ruby/test_m17n.rb10
-rw-r--r--test/ruby/test_math.rb6
-rw-r--r--test/ruby/test_rational.rb3
-rw-r--r--test/ruby/test_refinement.rb6
-rw-r--r--test/ruby/test_syntax.rb20
-rw-r--r--test/ruby/test_variable.rb2
10 files changed, 36 insertions, 29 deletions
diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb
index b793fd2..b2d8d66 100644
--- a/test/ruby/test_autoload.rb
+++ b/test/ruby/test_autoload.rb
@@ -189,7 +189,9 @@ p Foo::Bar
end
def ruby_impl_require
- Kernel.module_eval do; alias :old_require :require; end
+ Kernel.module_eval do
+ alias old_require require
+ end
called_with = []
Kernel.send :define_method, :require do |path|
called_with << path
@@ -197,7 +199,11 @@ p Foo::Bar
end
yield called_with
ensure
- Kernel.module_eval do; alias :require :old_require; undef :old_require; end
+ Kernel.module_eval do
+ undef require
+ alias require old_require
+ undef old_require
+ end
end
def test_require_implemented_in_ruby_is_called
diff --git a/test/ruby/test_const.rb b/test/ruby/test_const.rb
index 0b2c449..ff83257 100644
--- a/test/ruby/test_const.rb
+++ b/test/ruby/test_const.rb
@@ -37,7 +37,7 @@ class TestConst < Test::Unit::TestCase
self.class.class_eval {
include Const2
}
- STDERR.print "intentionally redefines TEST3, TEST4\n" if $VERBOSE
+ # STDERR.print "intentionally redefines TEST3, TEST4\n" if $VERBOSE
assert defined?(TEST1)
assert_equal 1, TEST1
assert defined?(TEST2)
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb
index 53b867e..53b75c6 100644
--- a/test/ruby/test_file_exhaustive.rb
+++ b/test/ruby/test_file_exhaustive.rb
@@ -107,7 +107,7 @@ class TestFileExhaustive < Test::Unit::TestCase
end
def symlinkfile
- return @symlinkfile if @symlinkfile
+ return @symlinkfile if defined? @symlinkfile
@symlinkfile = make_tmp_filename("symlinkfile")
begin
File.symlink(regular_file, @symlinkfile)
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb
index 06931c8..501043e 100644
--- a/test/ruby/test_iseq.rb
+++ b/test/ruby/test_iseq.rb
@@ -9,7 +9,9 @@ class TestISeq < Test::Unit::TestCase
end
def compile(src, line = nil, opt = nil)
- RubyVM::InstructionSequence.new(src, __FILE__, __FILE__, line, opt)
+ EnvUtil.suppress_warning do
+ RubyVM::InstructionSequence.new(src, __FILE__, __FILE__, line, opt)
+ end
end
def lines src
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index 3a45f1f..8e7e4c6 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -1673,13 +1673,9 @@ class TestM17N < Test::Unit::TestCase
def test_inspect_with_default_internal
bug11787 = '[ruby-dev:49415] [Bug #11787]'
- orig_int = Encoding.default_internal
- Encoding.default_internal = ::Encoding::EUC_JP
- s = begin
- [e("\xB4\xC1\xBB\xFA")].inspect
- ensure
- Encoding.default_internal = orig_int
- end
+ s = EnvUtil.with_default_internal(::Encoding::EUC_JP) do
+ [e("\xB4\xC1\xBB\xFA")].inspect
+ end
assert_equal(e("[\"\xB4\xC1\xBB\xFA\"]"), s, bug11787)
end
end
diff --git a/test/ruby/test_math.rb b/test/ruby/test_math.rb
index f2805a2..72ed987 100644
--- a/test/ruby/test_math.rb
+++ b/test/ruby/test_math.rb
@@ -289,7 +289,7 @@ class TestMath < Test::Unit::TestCase
check(Math.exp((0 + 1)._to_f), Math.exp(0))
check(Math.log((0 + 1)._to_f), Math.log(0))
- Fixnum.class_eval { alias to_f _to_f }
+ Fixnum.class_eval { undef to_f; alias to_f _to_f; undef _to_f }
end
def test_bignum_to_f
@@ -307,7 +307,7 @@ class TestMath < Test::Unit::TestCase
check(Math.cos((1 << 62 << 1)._to_f), Math.cos(1 << 62))
check(Math.log((1 << 62 << 1)._to_f), Math.log(1 << 62))
- Bignum.class_eval { alias to_f _to_f }
+ Bignum.class_eval { undef to_f; alias to_f _to_f; undef _to_f }
end
def test_rational_to_f
@@ -326,6 +326,6 @@ class TestMath < Test::Unit::TestCase
check(Math.exp((0r + 1)._to_f), Math.exp(0r))
check(Math.log((0r + 1)._to_f), Math.log(0r))
- Rational.class_eval { alias to_f _to_f }
+ Rational.class_eval { undef to_f; alias to_f _to_f; undef _to_f }
end
end
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb
index 44e186f..ae46965 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -904,7 +904,8 @@ class Rational_Test < Test::Unit::TestCase
def test_fixed_bug
n = Float::MAX.to_i * 2
- assert_equal(1.0, Rational(n + 2, n + 1).to_f, '[ruby-dev:33852]')
+ x = EnvUtil.suppress_warning {Rational(n + 2, n + 1).to_f}
+ assert_equal(1.0, x, '[ruby-dev:33852]')
end
def test_power_of_1_and_minus_1
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 99987da..60d0c9a 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -503,8 +503,10 @@ class TestRefinement < Test::Unit::TestCase
end
class C
- def foo
- "redefined"
+ EnvUtil.suppress_warning do
+ def foo
+ "redefined"
+ end
end
end
end
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index e2c524b..81a0f6e 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -369,22 +369,22 @@ WARN
def test_duplicated_arg
assert_syntax_error("def foo(a, a) end", /duplicated argument name/)
- assert_nothing_raised { def foo(_, _) end }
+ assert_valid_syntax("def foo(_, _) end")
end
def test_duplicated_rest
assert_syntax_error("def foo(a, *a) end", /duplicated argument name/)
- assert_nothing_raised { def foo(_, *_) end }
+ assert_valid_syntax("def foo(_, *_) end")
end
def test_duplicated_opt
assert_syntax_error("def foo(a, a=1) end", /duplicated argument name/)
- assert_nothing_raised { def foo(_, _=1) end }
+ assert_valid_syntax("def foo(_, _=1) end")
end
def test_duplicated_opt_rest
assert_syntax_error("def foo(a=1, *a) end", /duplicated argument name/)
- assert_nothing_raised { def foo(_=1, *_) end }
+ assert_valid_syntax("def foo(_=1, *_) end")
end
def test_duplicated_rest_opt
@@ -397,12 +397,12 @@ WARN
def test_duplicated_opt_post
assert_syntax_error("def foo(a=1, a) end", /duplicated argument name/)
- assert_nothing_raised { def foo(_=1, _) end }
+ assert_valid_syntax("def foo(_=1, _) end")
end
def test_duplicated_kw
assert_syntax_error("def foo(a, a: 1) end", /duplicated argument name/)
- assert_nothing_raised { def foo(_, _: 1) end }
+ assert_valid_syntax("def foo(_, _: 1) end")
end
def test_duplicated_rest_kw
@@ -412,22 +412,22 @@ WARN
def test_duplicated_opt_kw
assert_syntax_error("def foo(a=1, a: 1) end", /duplicated argument name/)
- assert_nothing_raised { def foo(_=1, _: 1) end }
+ assert_valid_syntax("def foo(_=1, _: 1) end")
end
def test_duplicated_kw_kwrest
assert_syntax_error("def foo(a: 1, **a) end", /duplicated argument name/)
- assert_nothing_raised { def foo(_: 1, **_) end }
+ assert_valid_syntax("def foo(_: 1, **_) end")
end
def test_duplicated_rest_kwrest
assert_syntax_error("def foo(*a, **a) end", /duplicated argument name/)
- assert_nothing_raised { def foo(*_, **_) end }
+ assert_valid_syntax("def foo(*_, **_) end")
end
def test_duplicated_opt_kwrest
assert_syntax_error("def foo(a=1, **a) end", /duplicated argument name/)
- assert_nothing_raised { def foo(_=1, **_) end }
+ assert_valid_syntax("def foo(_=1, **_) end")
end
def test_duplicated_when
diff --git a/test/ruby/test_variable.rb b/test/ruby/test_variable.rb
index 3da836b..c8e2617 100644
--- a/test/ruby/test_variable.rb
+++ b/test/ruby/test_variable.rb
@@ -141,7 +141,7 @@ class TestVariable < Test::Unit::TestCase
v.instance_variable_set(:@foo, :bar)
end
- assert_nil v.instance_variable_get(:@foo)
+ assert_nil EnvUtil.suppress_warning {v.instance_variable_get(:@foo)}
assert_not_send([v, :instance_variable_defined?, :@foo])
assert_raise_with_message(RuntimeError, msg) do