Fix most of the unused variable warnings in Ruby tests (#5313)

* Fix most of the unused variable warnings in Ruby tests

* Add encoded_field_b back in tests/common_tests.rb
pull/5375/head
Toby Hsieh 6 years ago committed by Paul Yang
parent 436139803f
commit 59133296a6
  1. 19
      ruby/tests/common_tests.rb
  2. 2
      ruby/tests/encode_decode_test.rb
  3. 6
      ruby/tests/generated_code_proto2_test.rb
  4. 6
      ruby/tests/generated_code_test.rb

@ -204,10 +204,10 @@ module CommonTests
m.optional_string = "asdf".encode!('UTF-8')
# Ruby 2.5 changed to raise FrozenError. However, assert_raise don't
# accept subclass.
ok = true
ok = false
begin
m.optional_string.encode!('ASCII-8BIT')
rescue RuntimeError => e
rescue RuntimeError
ok = true
end
assert ok
@ -341,16 +341,16 @@ module CommonTests
def test_rptfield_initialize
assert_raise ArgumentError do
l = Google::Protobuf::RepeatedField.new
Google::Protobuf::RepeatedField.new
end
assert_raise ArgumentError do
l = Google::Protobuf::RepeatedField.new(:message)
Google::Protobuf::RepeatedField.new(:message)
end
assert_raise ArgumentError do
l = Google::Protobuf::RepeatedField.new([1, 2, 3])
Google::Protobuf::RepeatedField.new([1, 2, 3])
end
assert_raise ArgumentError do
l = Google::Protobuf::RepeatedField.new(:message, [proto_module::TestMessage2.new])
Google::Protobuf::RepeatedField.new(:message, [proto_module::TestMessage2.new])
end
end
@ -620,14 +620,14 @@ module CommonTests
encoded_field_d = proto_module::OneofMessage.encode(proto_module::OneofMessage.new(:d => :B))
d3 = proto_module::OneofMessage.decode(
encoded_field_c + encoded_field_a + encoded_field_d)
encoded_field_c + encoded_field_a + encoded_field_b + encoded_field_d)
assert d3.a == ""
assert d3.b == 0
assert d3.c == nil
assert d3.d == :B
d4 = proto_module::OneofMessage.decode(
encoded_field_c + encoded_field_a + encoded_field_d +
encoded_field_c + encoded_field_a + encoded_field_b + encoded_field_d +
encoded_field_c)
assert d4.a == ""
assert d4.b == 0
@ -800,7 +800,7 @@ module CommonTests
m = proto_module::Recursive1.new(:foo => proto_module::Recursive2.new)
m.foo.foo = m
assert_raise RuntimeError do
serialized = proto_module::Recursive1.encode(m)
proto_module::Recursive1.encode(m)
end
end
@ -933,7 +933,6 @@ module CommonTests
data = proto_module::TestMessage.encode(m)
l = 0
10_000.times do
m = proto_module::TestMessage.decode(data)
data_new = proto_module::TestMessage.encode(m)

@ -86,7 +86,7 @@ class EncodeDecodeTest < Test::Unit::TestCase
end
def test_encode_wrong_msg
e = assert_raise ::ArgumentError do
assert_raise ::ArgumentError do
m = A::B::C::TestMessage.new(
:optional_int32 => 1,
)

@ -14,8 +14,8 @@ class GeneratedCodeProto2Test < Test::Unit::TestCase
# is to ensure that the output of the code generator is valid Ruby and
# successfully creates message definitions and classes, not to test every
# aspect of the extension (basic.rb is for that).
m = A::B::Proto2::TestMessage.new()
m2 = FooBar::Proto2::TestImportedMessage.new()
m3 = A::B::Proto2::TestRubyPackageMessage.new()
A::B::Proto2::TestMessage.new
FooBar::Proto2::TestImportedMessage.new
A::B::Proto2::TestRubyPackageMessage.new
end
end

@ -14,8 +14,8 @@ class GeneratedCodeTest < Test::Unit::TestCase
# is to ensure that the output of the code generator is valid Ruby and
# successfully creates message definitions and classes, not to test every
# aspect of the extension (basic.rb is for that).
m = A::B::C::TestMessage.new()
m2 = FooBar::TestImportedMessage.new()
m3 = A::B::TestRubyPackageMessage.new()
A::B::C::TestMessage.new
FooBar::TestImportedMessage.new
A::B::TestRubyPackageMessage.new
end
end

Loading…
Cancel
Save