summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-19 07:48:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-19 07:48:02 +0000
commit41f4317f45021460871bd11c666f438f5517904b (patch)
treec7ac02b58faafe7f92946fe8f14c18480280624f /test/ruby
parent311b7154839b91c87ee40908ac6d3f5c330d7b11 (diff)
test/ruby: suppress parser warnings
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/enc/test_casing_options.rb32
-rw-r--r--test/ruby/enc/test_regex_casefold.rb6
-rw-r--r--test/ruby/test_array.rb2
-rw-r--r--test/ruby/test_backtrace.rb4
-rw-r--r--test/ruby/test_basicinstructions.rb10
-rw-r--r--test/ruby/test_class.rb3
-rw-r--r--test/ruby/test_enum.rb6
-rw-r--r--test/ruby/test_enumerator.rb1
-rw-r--r--test/ruby/test_env.rb4
-rw-r--r--test/ruby/test_eval.rb9
-rw-r--r--test/ruby/test_exception.rb16
-rw-r--r--test/ruby/test_fixnum.rb2
-rw-r--r--test/ruby/test_flip.rb1
-rw-r--r--test/ruby/test_hash.rb2
-rw-r--r--test/ruby/test_io.rb7
-rw-r--r--test/ruby/test_iseq.rb4
-rw-r--r--test/ruby/test_iterator.rb2
-rw-r--r--test/ruby/test_lambda.rb6
-rw-r--r--test/ruby/test_method.rb26
-rw-r--r--test/ruby/test_object.rb2
-rw-r--r--test/ruby/test_parse.rb8
-rw-r--r--test/ruby/test_primitive.rb2
-rw-r--r--test/ruby/test_proc.rb6
-rw-r--r--test/ruby/test_rational.rb2
-rw-r--r--test/ruby/test_rubyoptions.rb4
-rw-r--r--test/ruby/test_settracefunc.rb6
-rw-r--r--test/ruby/test_sprintf.rb2
-rw-r--r--test/ruby/test_super.rb4
-rw-r--r--test/ruby/test_symbol.rb2
-rw-r--r--test/ruby/test_syntax.rb8
-rw-r--r--test/ruby/test_variable.rb6
31 files changed, 104 insertions, 91 deletions
diff --git a/test/ruby/enc/test_casing_options.rb b/test/ruby/enc/test_casing_options.rb
index 69d0acc..4150fc7 100644
--- a/test/ruby/enc/test_casing_options.rb
+++ b/test/ruby/enc/test_casing_options.rb
@@ -4,17 +4,17 @@ require "test/unit"
class TestCasingOptions < Test::Unit::TestCase
def assert_raise_functional_operations (arg, *options)
- assert_raise(ArgumentError) { arg.upcase *options }
- assert_raise(ArgumentError) { arg.downcase *options }
- assert_raise(ArgumentError) { arg.capitalize *options }
- assert_raise(ArgumentError) { arg.swapcase *options }
+ assert_raise(ArgumentError) { arg.upcase(*options) }
+ assert_raise(ArgumentError) { arg.downcase(*options) }
+ assert_raise(ArgumentError) { arg.capitalize(*options) }
+ assert_raise(ArgumentError) { arg.swapcase(*options) }
end
def assert_raise_bang_operations (arg, *options)
- assert_raise(ArgumentError) { arg.upcase! *options }
- assert_raise(ArgumentError) { arg.downcase! *options }
- assert_raise(ArgumentError) { arg.capitalize! *options }
- assert_raise(ArgumentError) { arg.swapcase! *options }
+ assert_raise(ArgumentError) { arg.upcase!(*options) }
+ assert_raise(ArgumentError) { arg.downcase!(*options) }
+ assert_raise(ArgumentError) { arg.capitalize!(*options) }
+ assert_raise(ArgumentError) { arg.swapcase!(*options) }
end
def assert_raise_both_types (*options)
@@ -36,17 +36,17 @@ class TestCasingOptions < Test::Unit::TestCase
end
def assert_okay_functional_operations (arg, *options)
- assert_nothing_raised { arg.upcase *options }
- assert_nothing_raised { arg.downcase *options }
- assert_nothing_raised { arg.capitalize *options }
- assert_nothing_raised { arg.swapcase *options }
+ assert_nothing_raised { arg.upcase(*options) }
+ assert_nothing_raised { arg.downcase(*options) }
+ assert_nothing_raised { arg.capitalize(*options) }
+ assert_nothing_raised { arg.swapcase(*options) }
end
def assert_okay_bang_operations (arg, *options)
- assert_nothing_raised { arg.upcase! *options }
- assert_nothing_raised { arg.downcase! *options }
- assert_nothing_raised { arg.capitalize! *options }
- assert_nothing_raised { arg.swapcase! *options }
+ assert_nothing_raised { arg.upcase!(*options) }
+ assert_nothing_raised { arg.downcase!(*options) }
+ assert_nothing_raised { arg.capitalize!(*options) }
+ assert_nothing_raised { arg.swapcase!(*options) }
end
def assert_okay_both_types (*options)
diff --git a/test/ruby/enc/test_regex_casefold.rb b/test/ruby/enc/test_regex_casefold.rb
index 30193e3..c98e053 100644
--- a/test/ruby/enc/test_regex_casefold.rb
+++ b/test/ruby/enc/test_regex_casefold.rb
@@ -22,8 +22,8 @@ class TestCaseFold < Test::Unit::TestCase
.collect.with_index { |linedata, linenumber| [linenumber.to_i+1, linedata.chomp] }
.reject { |number, data| data =~ /^(#|$)/ }
.collect do |linenumber, linedata|
- data, name = linedata.split /#\s*/
- code, kind, result, _ = data.split /;\s*/
+ data, _ = linedata.split(/#\s*/)
+ code, kind, result, _ = data.split(/;\s*/)
CaseTest.new code.to_i(16).chr('UTF-8'),
result.split(/ /).collect { |hex| hex.to_i(16) }.pack('U*'),
kind, linenumber
@@ -81,6 +81,8 @@ class TestCaseFold < Test::Unit::TestCase
"12345#{to_codepoints(target)}67890 and /#{reg}/i do not match " +
"(CaseFolding.txt line #{test[:line]})"
rescue Encoding::UndefinedConversionError
+ source = source
+ regexp = regexp
end
end
end
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index feeccd4..dc276e0 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -2409,7 +2409,7 @@ class TestArray < Test::Unit::TestCase
def test_combination_clear
bug9939 = '[ruby-core:63149] [Bug #9939]'
- assert_separately([], <<-'end;')
+ assert_ruby_status([], <<-'end;', bug9939)
100_000.times {Array.new(1000)}
a = [*0..100]
a.combination(3) {|*,x| a.clear}
diff --git a/test/ruby/test_backtrace.rb b/test/ruby/test_backtrace.rb
index ff95a89..b6b0f73 100644
--- a/test/ruby/test_backtrace.rb
+++ b/test/ruby/test_backtrace.rb
@@ -198,7 +198,7 @@ class TestBacktrace < Test::Unit::TestCase
def test_caller_locations_base_label
assert_equal("#{__method__}", caller_locations(0, 1)[0].base_label)
- loc, = tap {|loc| break caller_locations(0, 1)}
+ loc, = tap {break caller_locations(0, 1)}
assert_equal("#{__method__}", loc.base_label)
begin
raise
@@ -209,7 +209,7 @@ class TestBacktrace < Test::Unit::TestCase
def test_caller_locations_label
assert_equal("#{__method__}", caller_locations(0, 1)[0].label)
- loc, = tap {|loc| break caller_locations(0, 1)}
+ loc, = tap {break caller_locations(0, 1)}
assert_equal("block in #{__method__}", loc.label)
begin
raise
diff --git a/test/ruby/test_basicinstructions.rb b/test/ruby/test_basicinstructions.rb
index b56b6d1..d13c41c 100644
--- a/test/ruby/test_basicinstructions.rb
+++ b/test/ruby/test_basicinstructions.rb
@@ -211,9 +211,9 @@ class TestBasicInstructions < Test::Unit::TestCase
assert_raise(NameError) { a }
assert_raise(NameError) { b }
assert_raise(NameError) { c }
- a = "NOT OK"
- b = "NOT OK"
- c = "NOT OK"
+ a = a = "NOT OK"
+ b = b = "NOT OK"
+ c = c = "NOT OK"
end
class Const
@@ -611,8 +611,8 @@ class TestBasicInstructions < Test::Unit::TestCase
x = OP.new
assert_equal 42, x.foo = 42, bug7773
assert_equal 42, x.foo, bug7773
- assert_equal -6, x.send(:foo=, -6), bug7773
- assert_equal -6, x.foo, bug7773
+ assert_equal (-6), x.send(:foo=, -6), bug7773
+ assert_equal (-6), x.foo, bug7773
assert_equal :Bug1996, x.send(:x=, :case_when_setter_returns_other_value), bug7773
assert_equal :case_when_setter_returns_other_value, x.x, bug7773
end
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb
index f84c2d7..ce9ffab 100644
--- a/test/ruby/test_class.rb
+++ b/test/ruby/test_class.rb
@@ -371,6 +371,9 @@ class TestClass < Test::Unit::TestCase
end;
}
assert_raise_with_message(TypeError, /#{n}/) {
+ Class.new(c)
+ }
+ assert_raise_with_message(TypeError, /#{n}/) {
m.module_eval "class #{n} < Class.new; end"
}
end
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb
index ab35644..6162830 100644
--- a/test/ruby/test_enum.rb
+++ b/test/ruby/test_enum.rb
@@ -206,7 +206,7 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal([], @empty.first(10))
bug5801 = '[ruby-dev:45041]'
- assert_in_out_err([], <<-'end;', [], /unexpected break/)
+ assert_in_out_err([], <<-'end;', [], /unexpected break/, bug5801)
empty = Object.new
class << empty
attr_reader :block
@@ -703,7 +703,7 @@ class TestEnumerable < Test::Unit::TestCase
bug9605 = '[ruby-core:61340]'
lambda2 = ->(x, i) { x == 'c' }
- assert_equal(['c',2], @obj.each_with_index.detect(&lambda2))
+ assert_equal(['c',2], @obj.each_with_index.detect(&lambda2), bug9605)
end
def test_select
@@ -723,7 +723,7 @@ class TestEnumerable < Test::Unit::TestCase
bug9605 = '[ruby-core:61340]'
lambda2 = ->(x, i) { x == 'c' }
- assert_equal([['c',2]], @obj.each_with_index.select(&lambda2))
+ assert_equal([['c',2]], @obj.each_with_index.select(&lambda2), bug9605)
end
def test_map
diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb
index aa36187..3cb9dc7 100644
--- a/test/ruby/test_enumerator.rb
+++ b/test/ruby/test_enumerator.rb
@@ -103,6 +103,7 @@ class TestEnumerator < Test::Unit::TestCase
1.times do
foo = [1,2,3].to_enum
GC.start
+ foo
end
GC.start
end
diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb
index 7224d57..b14ea22 100644
--- a/test/ruby/test_env.rb
+++ b/test/ruby/test_env.rb
@@ -53,7 +53,7 @@ class TestEnv < Test::Unit::TestCase
end
assert_raise(TypeError) {
- tmp = ENV[1]
+ ENV[1]
}
assert_raise(TypeError) {
ENV[1] = 'foo'
@@ -318,7 +318,7 @@ class TestEnv < Test::Unit::TestCase
assert_equal("test", k)
assert_equal("foo", v)
end
- assert_invalid_env {|v| ENV.assoc(v)}
+ assert_invalid_env {|var| ENV.assoc(var)}
end
def test_has_value2
diff --git a/test/ruby/test_eval.rb b/test/ruby/test_eval.rb
index 6982429..30f5e5c 100644
--- a/test/ruby/test_eval.rb
+++ b/test/ruby/test_eval.rb
@@ -258,9 +258,9 @@ class TestEval < Test::Unit::TestCase
#
def make_test_binding
- local1 = "local1"
+ local1 = local1 = "local1"
lambda {
- local2 = "local2"
+ local2 = local2 = "local2"
return binding
}.call
end
@@ -287,7 +287,7 @@ class TestEval < Test::Unit::TestCase
assert_equal('assert(true)', eval("$foo"))
assert_equal(true, eval("true"))
- i = 5
+ i = i = 5
assert(eval("i == 5"))
assert_equal(5, eval("i"))
assert(eval("defined? i"))
@@ -308,6 +308,7 @@ class TestEval < Test::Unit::TestCase
module EvTest
EVTEST1 = 25
evtest2 = 125
+ evtest2 = evtest2
binding
end
)
@@ -354,7 +355,7 @@ class TestEval < Test::Unit::TestCase
p = binding
eval "foo11 = 1", p
foo22 = 5
- proc{foo11=22}.call
+ proc{foo11=22;foo11}.call
proc{foo22=55}.call
# assert_equal(eval("foo11"), eval("foo11", p))
# assert_equal(1, eval("foo11"))
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index c5b3852..a24f1ca 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -20,8 +20,8 @@ class TestException < Test::Unit::TestCase
if bad
bad = false
retry
- assert(false)
end
+ assert(!bad)
end
assert(true)
end
@@ -626,6 +626,7 @@ end.join
end
def test_cause_raised_in_rescue
+ a = nil
e = assert_raise_with_message(RuntimeError, 'b') {
begin
raise 'a'
@@ -633,6 +634,7 @@ end.join
begin
raise 'b'
rescue => b
+ assert_same(a, b.cause)
begin
raise 'c'
rescue
@@ -641,15 +643,17 @@ end.join
end
end
}
- assert_equal('a', e.cause.message, 'cause should not be overwritten by reraise')
+ assert_same(a, e.cause, 'cause should not be overwritten by reraise')
end
def test_cause_at_raised
+ a = nil
e = assert_raise_with_message(RuntimeError, 'b') {
begin
raise 'a'
rescue => a
b = RuntimeError.new('b')
+ assert_nil(b.cause)
begin
raise 'c'
rescue
@@ -658,6 +662,7 @@ end.join
end
}
assert_equal('c', e.cause.message, 'cause should be the exception at raised')
+ assert_same(a, e.cause.cause)
end
def test_raise_with_cause
@@ -682,6 +687,7 @@ end.join
begin
raise 'b'
rescue => b
+ assert_same(a, b.cause)
begin
raise 'c'
rescue
@@ -691,6 +697,7 @@ end.join
end
}
assert_equal('d', e.cause.message, 'cause option should be honored always')
+ assert_nil(e.cause.cause)
end
def test_unknown_option
@@ -751,7 +758,8 @@ end.join
assert_same(obj, e.receiver)
def obj.test(a, b=nil, *c, &d)
e = a
- 1.times {|f| g = foo}
+ 1.times {|f| g = foo; g}
+ e
end
e = assert_raise(NameError) {
obj.test(3)
@@ -776,7 +784,7 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
assert_equal 0, errs.size
err = outs.first.force_encoding('utf-8')
assert err.valid_encoding?, 'must be valid encoding'
- assert_match /\u3042/, err
+ assert_match %r/\u3042/, err
end
end
diff --git a/test/ruby/test_fixnum.rb b/test/ruby/test_fixnum.rb
index 7e89caf..024f905 100644
--- a/test/ruby/test_fixnum.rb
+++ b/test/ruby/test_fixnum.rb
@@ -305,7 +305,7 @@ class TestFixnum < Test::Unit::TestCase
big = 1 << 66
assert_eql 1, 1 ** -big , bug5715
assert_eql 1, (-1) ** -big , bug5715
- assert_eql -1, (-1) ** -(big+1) , bug5715
+ assert_eql (-1), (-1) ** -(big+1), bug5715
end
def test_power_of_0
diff --git a/test/ruby/test_flip.rb b/test/ruby/test_flip.rb
index 594c810..0f2ae09 100644
--- a/test/ruby/test_flip.rb
+++ b/test/ruby/test_flip.rb
@@ -9,6 +9,7 @@ class TestFlip < Test::Unit::TestCase
assert_nothing_raised(NotImplementedError, bug6899) do
2000.times {eval %[(foo..bar) ? 1 : 2]}
end
+ foo = bar
end
def test_shared_eval
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 8b6910c..e08235e 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -1330,7 +1330,7 @@ class TestHash < Test::Unit::TestCase
def o.respond_to?(*args)
super
end
- assert_raise(TypeError) {{foo: o}.dig(:foo, :foo)}
+ assert_raise(TypeError, bug12030) {{foo: o}.dig(:foo, :foo)}
end
def test_cmp
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 33a2ab8..3f6825d 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2185,7 +2185,7 @@ End
assert_file.exist?(fname)
stdin = $stdin.dup
begin
- assert_nothing_raised(Errno::ENOENT, enc) {
+ assert_nothing_raised(Errno::ENOENT, "#{bug11320}: #{enc}") {
$stdin.reopen(fname, 'r')
}
ensure
@@ -2461,7 +2461,7 @@ End
def test_flush_in_finalizer1
require 'tempfile'
bug3910 = '[ruby-dev:42341]'
- t = Tempfile.open("bug3910") {|t|
+ tmp = Tempfile.open("bug3910") {|t|
path = t.path
t.close
fds = []
@@ -2481,7 +2481,7 @@ End
f.close
end
}
- t.close!
+ tmp.close!
end
def test_flush_in_finalizer2
@@ -2959,7 +2959,6 @@ End
def test_frozen_autoclose
with_pipe do |r,w|
- fd = r.fileno
assert_equal(true, r.freeze.autoclose?)
end
end
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb
index 4561eeb..06931c8 100644
--- a/test/ruby/test_iseq.rb
+++ b/test/ruby/test_iseq.rb
@@ -89,9 +89,9 @@ class TestISeq < Test::Unit::TestCase
LINE_BEFORE_METHOD = __LINE__
def method_test_line_trace
- a = 1
+ _a = 1
- b = 2
+ _b = 2
end
diff --git a/test/ruby/test_iterator.rb b/test/ruby/test_iterator.rb
index fb81820..52eac0d 100644
--- a/test/ruby/test_iterator.rb
+++ b/test/ruby/test_iterator.rb
@@ -109,7 +109,7 @@ class TestIterator < Test::Unit::TestCase
def test_append_method_to_built_in_class
x = [[1,2],[3,4],[5,6]]
- assert_equal(x.iter_test1{|x|x}, x.iter_test2{|x|x})
+ assert_equal(x.iter_test1{|e|e}, x.iter_test2{|e|e})
end
class IterTest
diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb
index f61e8a9..efc3d0f 100644
--- a/test/ruby/test_lambda.rb
+++ b/test/ruby/test_lambda.rb
@@ -61,9 +61,9 @@ class TestLambdaParameters < Test::Unit::TestCase
assert_equal(nil, ->(&b){ b }.call)
foo { puts "bogus block " }
assert_equal(1, ->(&b){ b.call }.call { 1 })
- b = nil
- assert_equal(1, ->(&b){ b.call }.call { 1 })
- assert_nil(b)
+ _b = nil
+ assert_equal(1, ->(&_b){ _b.call }.call { 1 })
+ assert_nil(_b)
end
def test_call_block_from_lambda
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index 1e5f054..7816e6c 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -322,7 +322,7 @@ class TestMethod < Test::Unit::TestCase
def o.define(n)
define_singleton_method(n)
end
- assert_raise(ArgumentError) {o.define(:bar) {:bar}}
+ assert_raise(ArgumentError, bug11283) {o.define(:bar) {:bar}}
end
def test_define_method_invalid_arg
@@ -804,7 +804,7 @@ class TestMethod < Test::Unit::TestCase
def test_curry_from_proc
c = Class.new {
- define_method(:three_args) {|a,b,c| a + b + c}
+ define_method(:three_args) {|x,y,z| x + y + z}
}
assert_curry_three_args(c.new.method(:three_args))
end
@@ -901,7 +901,7 @@ class TestMethod < Test::Unit::TestCase
class C
D = "Const_D"
def foo
- a = b = c = 12345
+ a = b = c = a = b = c = 12345
end
end
@@ -909,16 +909,16 @@ class TestMethod < Test::Unit::TestCase
bug11012 = '[ruby-core:68673] [Bug #11012]'
b = C.new.method(:foo).to_proc.binding
- assert_equal([], b.local_variables)
- assert_equal("Const_D", b.eval("D")) # Check CREF
-
- assert_raise(NameError){ b.local_variable_get(:foo) }
- assert_equal(123, b.local_variable_set(:foo, 123))
- assert_equal(123, b.local_variable_get(:foo))
- assert_equal(456, b.local_variable_set(:bar, 456))
- assert_equal(123, b.local_variable_get(:foo))
- assert_equal(456, b.local_variable_get(:bar))
- assert_equal([:bar, :foo], b.local_variables.sort)
+ assert_equal([], b.local_variables, bug11012)
+ assert_equal("Const_D", b.eval("D"), bug11012) # Check CREF
+
+ assert_raise(NameError, bug11012){ b.local_variable_get(:foo) }
+ assert_equal(123, b.local_variable_set(:foo, 123), bug11012)
+ assert_equal(123, b.local_variable_get(:foo), bug11012)
+ assert_equal(456, b.local_variable_set(:bar, 456), bug11012)
+ assert_equal(123, b.local_variable_get(:foo), bug11012)
+ assert_equal(456, b.local_variable_get(:bar), bug11012)
+ assert_equal([:bar, :foo], b.local_variables.sort, bug11012)
end
class MethodInMethodClass
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index 0ab1341..e170935 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -844,7 +844,7 @@ class TestObject < Test::Unit::TestCase
end
end
- assert_raise_with_message(#{exc}, "bug5473") {1.foo}
+ assert_raise_with_message(#{exc}, "bug5473", #{bug5473.dump}) {1.foo}
SRC
end
end
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb
index 6560618..42df891 100644
--- a/test/ruby/test_parse.rb
+++ b/test/ruby/test_parse.rb
@@ -681,14 +681,14 @@ x = __ENCODING__
def test_invalid_char
bug10117 = '[ruby-core:64243] [Bug #10117]'
invalid_char = /Invalid char `\\x01'/
- x = 1
+ x = x = 1
assert_in_out_err(%W"-e \x01x", "", [], invalid_char, bug10117)
assert_syntax_error("\x01x", invalid_char, bug10117)
assert_equal(nil, eval("\x04x"))
end
def test_literal_concat
- x = "baz"
+ x = x = "baz"
assert_equal("foobarbaz", eval('"foo" "bar#{x}"'))
end
@@ -759,7 +759,7 @@ x = __ENCODING__
$VERBOSE = true
stderr = $stderr
$stderr = StringIO.new("")
- x = 1
+ x = x = 1
assert_nil eval("x; nil")
assert_nil eval("1+1; nil")
assert_nil eval("TestParse; nil")
@@ -825,7 +825,7 @@ x = __ENCODING__
end
assert_nothing_raised do
- x = "bar"
+ x = x = "bar"
eval <<-END, nil, __FILE__, __LINE__+1
:"foo#{"x"}baz" ? 1 : 2
END
diff --git a/test/ruby/test_primitive.rb b/test/ruby/test_primitive.rb
index d1503a5..19af44a 100644
--- a/test/ruby/test_primitive.rb
+++ b/test/ruby/test_primitive.rb
@@ -82,7 +82,7 @@ class TestRubyPrimitive < Test::Unit::TestCase
end
i = 0
while i < 3
- r = A3::B3::C # cache
+ r = r = A3::B3::C # cache
class A3::B3
remove_const :C
end
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index 684a770..84055ca 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -1264,8 +1264,8 @@ class TestProc < Test::Unit::TestCase
def test_local_variables
b = get_binding
assert_equal(%i'if case when begin end a', b.local_variables)
- a = tap {|;a, b| break binding.local_variables}
- assert_equal(%i[a b], a.sort)
+ a = tap {|;x, y| x = y; break binding.local_variables}
+ assert_equal(%i[a b x y], a.sort)
end
def test_local_variables_nested
@@ -1274,7 +1274,7 @@ class TestProc < Test::Unit::TestCase
end
def local_variables_of(bind)
- this_should_not_be_in_bind = 2
+ this_should_not_be_in_bind = this_should_not_be_in_bind = 2
bind.local_variables
end
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb
index ea51ca2..44e186f 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -913,7 +913,7 @@ class Rational_Test < Test::Unit::TestCase
one = Rational( 1, 1)
assert_eql one, one ** -big , bug5715
assert_eql one, (-one) ** -big , bug5715
- assert_eql -one, (-one) ** -(big+1) , bug5715
+ assert_eql (-one), (-one) ** -(big+1) , bug5715
assert_equal Complex, ((-one) ** Rational(1,3)).class
end
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index ba74be5..340e945 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -818,14 +818,14 @@ class TestRubyOptions < Test::Unit::TestCase
["--disable-frozen-string-literal", false],
[nil, false],
]
- debug = [
+ debugs = [
["--debug-frozen-string-literal", true],
["--debug=frozen-string-literal", true],
["--debug", true],
[nil, false],
]
opts = ["--disable=gems"]
- frozen.product(debug) do |(opt1, freeze), (opt2, debug)|
+ frozen.product(debugs) do |(opt1, freeze), (opt2, debug)|
opt = opts + [opt1, opt2].compact
err = !freeze ? [] : debug ? with_debug_pat : wo_debug_pat
assert_in_out_err(opt, '"foo" << "bar"', [], err)
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index fc1391e..9de2137 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -1359,7 +1359,7 @@ class TestSetTraceFunc < Test::Unit::TestCase
assert_consistent_call_return '[Bug #9959]' do
begin
method_test_argument_error_on_bmethod(wrong_key: 2)
- rescue => e
+ rescue
# ignore
end
end
@@ -1369,7 +1369,7 @@ class TestSetTraceFunc < Test::Unit::TestCase
assert_consistent_call_return '[Bug #9961]' do
begin
-Numeric.new
- rescue => e
+ rescue
# ignore
end
end
@@ -1413,7 +1413,7 @@ class TestSetTraceFunc < Test::Unit::TestCase
return if Thread.current != target_th
evs << tp.event
}.enable{
- a = Bug10724.new
+ Bug10724.new
}
assert_equal([:call, :return], evs)
diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb
index e196e7c..501930a 100644
--- a/test/ruby/test_sprintf.rb
+++ b/test/ruby/test_sprintf.rb
@@ -174,7 +174,7 @@ class TestSprintf < Test::Unit::TestCase
end
bug11766 = '[ruby-core:71806] [Bug #11766]'
- assert_equal("x"*10+" 1.0", sprintf("x"*10+"%8.1f", 1r))
+ assert_equal("x"*10+" 1.0", sprintf("x"*10+"%8.1f", 1r), bug11766)
end
def test_hash
diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb
index 06e3e6e..469ba60 100644
--- a/test/ruby/test_super.rb
+++ b/test/ruby/test_super.rb
@@ -485,8 +485,8 @@ class TestSuper < Test::Unit::TestCase
bug9740 = '[ruby-core:62017] [Bug #9740]'
b.module_eval do
- define_method(:foo) do |result|
- um.bind(self).call(result)
+ define_method(:foo) do |res|
+ um.bind(self).call(res)
end
end
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index 7ed4788..9c51e26 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -356,7 +356,7 @@ class TestSymbol < Test::Unit::TestCase
def test_symbol_fstr_leak
bug10686 = '[ruby-core:67268] [Bug #10686]'
- x = 0
+ x = x = 0
assert_no_memory_leak([], '200_000.times { |i| i.to_s.to_sym }; GC.start', <<-"end;", bug10686, limit: 1.71, rss: true)
200_000.times { |i| (i + 200_000).to_s.to_sym }
end;
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 11b3f27..e2c524b 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -205,7 +205,7 @@ class TestSyntax < Test::Unit::TestCase
def test_keyword_invalid_name
bug11663 = '[ruby-core:71356] [Bug #11663]'
- o = Object.new
+ o = o = Object.new
assert_syntax_error('def o.foo(arg1?:) end', /arg1\?/, bug11663)
assert_syntax_error('def o.foo(arg1?:, arg2:) end', /arg1\?/, bug11663)
assert_syntax_error('proc {|arg1?:|}', /arg1\?/, bug11663)
@@ -362,7 +362,7 @@ WARN
def test_cmdarg_kwarg_lvar_clashing_method
bug12073 = '[ruby-core:73816] [Bug#12073]'
- a = 1
+ a = a = 1
assert_valid_syntax("a b: 1")
assert_valid_syntax("a = 1; a b: 1", bug12073)
end
@@ -442,7 +442,7 @@ WARN
}
}
assert_warning(/#{w}/){#/3: #{w}.+4: #{w}.+5: #{w}.+5: #{w}/m){
- a = 1
+ a = a = 1
eval %q{
case 1
when 1, 1
@@ -590,7 +590,7 @@ e"
end
def test_dedented_heredoc_with_interpolated_string
- w = ""
+ w = w = ""
result = " \#{mesg} a\n" \
" zy\n"
expect = '#{mesg} a'"\n" \
diff --git a/test/ruby/test_variable.rb b/test/ruby/test_variable.rb
index 7432cbb..3da836b 100644
--- a/test/ruby/test_variable.rb
+++ b/test/ruby/test_variable.rb
@@ -90,14 +90,12 @@ class TestVariable < Test::Unit::TestCase
def test_shadowing_local_variables
bug9486 = '[ruby-core:60501] [Bug #9486]'
- x = tap {|x| break local_variables}
- assert_equal([:x, :bug9486], x)
+ assert_equal([:x, :bug9486], tap {|x| break local_variables}, bug9486)
end
def test_shadowing_block_local_variables
bug9486 = '[ruby-core:60501] [Bug #9486]'
- x = tap {|;x| break local_variables}
- assert_equal([:x, :bug9486], x)
+ assert_equal([:x, :bug9486], tap {|;x| x = x; break local_variables}, bug9486)
end
def test_global_variables