mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 16:36:20 +08:00
Use assert_include instead of assert_includes
This commit is contained in:
13 files changed
+34
-34
No files matched your search
@@ -232,7 +232,7 @@ class TestFiberMutex < Test::Unit::TestCase
|
||||
mutex.lock
|
||||
end.resume
|
||||
end
|
||||
assert_includes error.message, "deadlock; lock already owned by another fiber belonging to the same thread"
|
||||
assert_include error.message, "deadlock; lock already owned by another fiber belonging to the same thread"
|
||||
end
|
||||
ensure
|
||||
thr&.kill&.join
|
||||
|
||||
@@ -687,18 +687,18 @@ class TestObjSpace < Test::Unit::TestCase
|
||||
end;
|
||||
assert_empty error
|
||||
assert(output.count > 1)
|
||||
assert_includes output.grep(/"imemo_type":"callinfo"/).join("\n"), '"mid":"baz"'
|
||||
assert_include output.grep(/"imemo_type":"callinfo"/).join("\n"), '"mid":"baz"'
|
||||
end
|
||||
end
|
||||
|
||||
def test_dump_string_coderange
|
||||
assert_includes ObjectSpace.dump("TEST STRING"), '"coderange":"7bit"'
|
||||
assert_include ObjectSpace.dump("TEST STRING"), '"coderange":"7bit"'
|
||||
unknown = "TEST STRING".dup.force_encoding(Encoding::UTF_16BE)
|
||||
2.times do # ensure that dumping the string doesn't mutate it
|
||||
assert_includes ObjectSpace.dump(unknown), '"coderange":"unknown"'
|
||||
assert_include ObjectSpace.dump(unknown), '"coderange":"unknown"'
|
||||
end
|
||||
assert_includes ObjectSpace.dump("Fée"), '"coderange":"valid"'
|
||||
assert_includes ObjectSpace.dump("\xFF"), '"coderange":"broken"'
|
||||
assert_include ObjectSpace.dump("Fée"), '"coderange":"valid"'
|
||||
assert_include ObjectSpace.dump("\xFF"), '"coderange":"broken"'
|
||||
end
|
||||
|
||||
def test_dump_escapes_method_name
|
||||
@@ -711,7 +711,7 @@ class TestObjSpace < Test::Unit::TestCase
|
||||
obj = klass.new.send(method_name)
|
||||
|
||||
dump = ObjectSpace.dump(obj)
|
||||
assert_includes dump, '"method":"foo\"bar"'
|
||||
assert_include dump, '"method":"foo\"bar"'
|
||||
|
||||
parsed = JSON.parse(dump)
|
||||
assert_equal "foo\"bar", parsed["method"]
|
||||
|
||||
@@ -891,10 +891,10 @@ class TestBox < Test::Unit::TestCase
|
||||
assert_match EXPERIMENTAL_WARNING_LINE_PATTERNS[0], error[0]
|
||||
assert_match EXPERIMENTAL_WARNING_LINE_PATTERNS[1], error[1]
|
||||
|
||||
assert_includes output.grep(/^before:/).join("\n"), '/bundled_gems.rb'
|
||||
assert_include output.grep(/^before:/).join("\n"), '/bundled_gems.rb'
|
||||
refute_includes output.grep(/^before:/).join("\n"), '/error_highlight.rb'
|
||||
assert_includes output.grep(/^after:/).join("\n"), '/bundled_gems.rb'
|
||||
assert_includes output.grep(/^after:/).join("\n"), '/error_highlight.rb'
|
||||
assert_include output.grep(/^after:/).join("\n"), '/bundled_gems.rb'
|
||||
assert_include output.grep(/^after:/).join("\n"), '/error_highlight.rb'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -917,7 +917,7 @@ class TestBox < Test::Unit::TestCase
|
||||
refute_includes output.grep(/^before:/).join("\n"), '/bundled_gems.rb'
|
||||
refute_includes output.grep(/^before:/).join("\n"), '/error_highlight.rb'
|
||||
refute_includes output.grep(/^after:/).join("\n"), '/bundled_gems.rb'
|
||||
assert_includes output.grep(/^after:/).join("\n"), '/error_highlight.rb'
|
||||
assert_include output.grep(/^after:/).join("\n"), '/error_highlight.rb'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ class TestISeq < Test::Unit::TestCase
|
||||
# shareable_constant_value: literal
|
||||
REGEX = /#{}/ # [Bug #20569]
|
||||
RUBY
|
||||
assert_includes iseq_to_binary(iseq), "REGEX".b
|
||||
assert_include iseq_to_binary(iseq), "REGEX".b
|
||||
end
|
||||
|
||||
def test_disasm_encoding
|
||||
|
||||
@@ -373,7 +373,7 @@ class TestObject < Test::Unit::TestCase
|
||||
|
||||
# All embed_cap ivars fit - should be embedded
|
||||
embed_cap.times { |i| o1.instance_variable_set(:"@v#{i}", i) }
|
||||
assert_includes ObjectSpace.dump(o1), '"embedded":true'
|
||||
assert_include ObjectSpace.dump(o1), '"embedded":true'
|
||||
|
||||
# One more ivar overflows embed capacity
|
||||
o1.instance_variable_set(:@overflow, 99)
|
||||
@@ -381,11 +381,11 @@ class TestObject < Test::Unit::TestCase
|
||||
|
||||
# Remove the overflow ivar - should re-embed
|
||||
o1.remove_instance_variable(:@overflow)
|
||||
assert_includes ObjectSpace.dump(o1), '"embedded":true'
|
||||
assert_include ObjectSpace.dump(o1), '"embedded":true'
|
||||
|
||||
# An object that never overflowed is also embedded
|
||||
embed_cap.times { |i| o2.instance_variable_set(:"@v#{i}", i) }
|
||||
assert_includes ObjectSpace.dump(o2), '"embedded":true'
|
||||
assert_include ObjectSpace.dump(o2), '"embedded":true'
|
||||
|
||||
# Verify values survived re-embedding
|
||||
embed_cap.times do |i|
|
||||
|
||||
@@ -2822,7 +2822,7 @@ EOS
|
||||
assert_empty($LOADED_FEATURES.grep(/\/(#{features.join("|")})\.rb\z/))
|
||||
Process.warmup
|
||||
features.each do |feature|
|
||||
assert_includes($LOADED_FEATURES.map { File.basename(it, ".rb") }, feature)
|
||||
assert_include($LOADED_FEATURES.map { File.basename(it, ".rb") }, feature)
|
||||
end
|
||||
end;
|
||||
end
|
||||
|
||||
@@ -958,7 +958,7 @@ class TC_Set < Test::Unit::TestCase
|
||||
set = set.dup
|
||||
|
||||
10_000.times do |i|
|
||||
assert_includes set, i
|
||||
assert_include set, i
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -2866,8 +2866,8 @@ CODE
|
||||
end
|
||||
}
|
||||
|
||||
assert_includes lines, while_line
|
||||
assert_includes lines, body_line
|
||||
assert_include lines, while_line
|
||||
assert_include lines, body_line
|
||||
assert_operator lines.index(while_line), :<, lines.index(body_line)
|
||||
end
|
||||
|
||||
@@ -2903,7 +2903,7 @@ CODE
|
||||
child.new.read
|
||||
}
|
||||
|
||||
assert_includes lines, while_line
|
||||
assert_include lines, while_line
|
||||
end
|
||||
|
||||
def test_allow_reentry
|
||||
|
||||
@@ -3627,7 +3627,7 @@ CODE
|
||||
|
||||
substr = str.byteslice(0, hundred.bytesize)
|
||||
assert_equal hundred, substr
|
||||
assert_includes ObjectSpace.dump(substr), ' "shared":true,'
|
||||
assert_include ObjectSpace.dump(substr), ' "shared":true,'
|
||||
|
||||
# Larger terminator
|
||||
substr.force_encoding(Encoding::UTF_16BE)
|
||||
@@ -3648,16 +3648,16 @@ CODE
|
||||
# the copy has to fit in along with the header and the terminator
|
||||
substr = str.byteslice(320, 128)
|
||||
assert_equal "a" * 128, substr
|
||||
assert_includes ObjectSpace.dump(substr), ' "embedded":true,'
|
||||
assert_include ObjectSpace.dump(substr), ' "embedded":true,'
|
||||
|
||||
substr = str.byteslice(128, 320)
|
||||
assert_equal "a" * 320, substr
|
||||
assert_includes ObjectSpace.dump(substr), ' "shared":true,'
|
||||
assert_include ObjectSpace.dump(substr), ' "shared":true,'
|
||||
|
||||
# A frozen source is a shared root itself, so the same substring is shared
|
||||
substr = str.freeze.byteslice(320, 128)
|
||||
assert_equal "a" * 128, substr
|
||||
assert_includes ObjectSpace.dump(substr), ' "shared":true,'
|
||||
assert_include ObjectSpace.dump(substr), ' "shared":true,'
|
||||
end
|
||||
|
||||
def test_unknown_string_option
|
||||
@@ -3725,7 +3725,7 @@ CODE
|
||||
require 'objspace'
|
||||
|
||||
str = "test_uplus_minus_str".freeze
|
||||
assert_includes ObjectSpace.dump(str), '"fstring":true'
|
||||
assert_include ObjectSpace.dump(str), '"fstring":true'
|
||||
|
||||
assert_predicate(str, :frozen?)
|
||||
assert_not_predicate(+str, :frozen?)
|
||||
|
||||
@@ -18,7 +18,7 @@ class TestYJIT < Test::Unit::TestCase
|
||||
running_with_yjit = defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?
|
||||
|
||||
def test_yjit_in_ruby_description
|
||||
assert_includes(RUBY_DESCRIPTION, '+YJIT')
|
||||
assert_include(RUBY_DESCRIPTION, '+YJIT')
|
||||
end if running_with_yjit
|
||||
|
||||
# Check that YJIT is in the version string
|
||||
@@ -63,7 +63,7 @@ class TestYJIT < Test::Unit::TestCase
|
||||
RubyVM::YJIT.enable
|
||||
|
||||
assert_predicate RubyVM::YJIT, :enabled?
|
||||
assert_includes RUBY_DESCRIPTION, "+YJIT"
|
||||
assert_include RUBY_DESCRIPTION, "+YJIT"
|
||||
RUBY
|
||||
end
|
||||
|
||||
@@ -75,7 +75,7 @@ class TestYJIT < Test::Unit::TestCase
|
||||
RubyVM::YJIT.enable
|
||||
|
||||
assert_predicate RubyVM::YJIT, :enabled?
|
||||
assert_includes RUBY_DESCRIPTION, "+YJIT"
|
||||
assert_include RUBY_DESCRIPTION, "+YJIT"
|
||||
RUBY
|
||||
end
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class TestZJITCLI < Test::Unit::TestCase
|
||||
# With --zjit-stats, stats should be printed to stderr
|
||||
out, err, status = eval_with_jit(script, stats: true)
|
||||
assert_success(out, err, status)
|
||||
assert_includes(err, stats_header)
|
||||
assert_include(err, stats_header)
|
||||
assert_equal("true\n", out)
|
||||
|
||||
# With --zjit-stats-quiet, stats should NOT be printed but still enabled
|
||||
@@ -105,7 +105,7 @@ class TestZJITCLI < Test::Unit::TestCase
|
||||
def test_enable_through_env
|
||||
child_env = {'RUBY_YJIT_ENABLE' => nil, 'RUBY_ZJIT_ENABLE' => '1'}
|
||||
assert_in_out_err([child_env, '-v'], '') do |stdout, stderr|
|
||||
assert_includes(stdout.first, '+ZJIT')
|
||||
assert_include(stdout.first, '+ZJIT')
|
||||
assert_equal([], stderr)
|
||||
end
|
||||
end
|
||||
@@ -122,7 +122,7 @@ class TestZJITCLI < Test::Unit::TestCase
|
||||
|
||||
assert_predicate RubyVM::ZJIT, :enabled?
|
||||
refute_predicate RubyVM::ZJIT, :stats_enabled?
|
||||
assert_includes RUBY_DESCRIPTION, "+ZJIT"
|
||||
assert_include RUBY_DESCRIPTION, "+ZJIT"
|
||||
RUBY
|
||||
end
|
||||
|
||||
@@ -134,7 +134,7 @@ class TestZJITCLI < Test::Unit::TestCase
|
||||
RubyVM::ZJIT.enable
|
||||
|
||||
assert_predicate RubyVM::ZJIT, :enabled?
|
||||
assert_includes RUBY_DESCRIPTION, "+ZJIT"
|
||||
assert_include RUBY_DESCRIPTION, "+ZJIT"
|
||||
RUBY
|
||||
end
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ class TestSocket < Test::Unit::TestCase
|
||||
rescue NotImplementedError
|
||||
return
|
||||
end
|
||||
assert_includes list.map(&:ip_address), Addrinfo.tcp("localhost", 0).ip_address
|
||||
assert_include list.map(&:ip_address), Addrinfo.tcp("localhost", 0).ip_address
|
||||
end
|
||||
|
||||
def test_tcp
|
||||
|
||||
@@ -358,7 +358,7 @@ module Test_SyncDefaultGems
|
||||
assert_equal("# 3\n", File.read("src/lib/conflict.rb"), out)
|
||||
subject, body = top_commit("src", format: "%B").split("\n\n", 2)
|
||||
assert_equal("[ruby/#@target] Merge commit", subject, out)
|
||||
assert_includes(body, "Commit in branch", out)
|
||||
assert_include(body, "Commit in branch", out)
|
||||
end
|
||||
|
||||
def test_no_upstream_file
|
||||
|
||||
Reference in new issue
Block a user