Skip to content

Commit

Permalink
Update default gem test for colon-style hash inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Jun 7, 2024
1 parent 49d2983 commit 898f9cb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion test/error_highlight/test_error_highlight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ def custom_formatter.message_for(spot)
assert_error_message(NoMethodError, <<~END) do
undefined method `time' for #{ ONE_RECV_MESSAGE }
{:first_lineno=>#{ __LINE__ + 3 }, :first_column=>7, :last_lineno=>#{ __LINE__ + 3 }, :last_column=>12, :snippet=>" 1.time {}\\n"}
#{{ first_lineno: __LINE__ + 3, first_column: 7, last_lineno: __LINE__ + 3, last_column: 12, snippet: " 1.time {}\n" }.inspect}
END

1.time {}
Expand Down
8 changes: 4 additions & 4 deletions test/rdoc/test_rdoc_ri_driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ def test_self_dump
RDoc::RI::Driver.dump @store1.cache_path
end

assert_match %r%:class_methods%, out
assert_match %r%:modules%, out
assert_match %r%:instance_methods%, out
assert_match %r%:ancestors%, out
assert_match %r%:class_methods|class_methods:%, out
assert_match %r%:modules|modules:%, out
assert_match %r%:instance_methods|instance_methods:%, out
assert_match %r%:ancestors|ancestors:%, out
end

def test_add_also_in_empty
Expand Down
4 changes: 2 additions & 2 deletions test/reline/test_reline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def test_read_eof_returns_input
io.close_write
io.read
end
assert_include(out, '{:result=>"a"}')
assert_include(out, { result: "a" }.inspect)
end

def test_read_eof_returns_nil_if_empty
Expand All @@ -411,7 +411,7 @@ def test_read_eof_returns_nil_if_empty
io.close_write
io.read
end
assert_include(out, '{:result=>nil}')
assert_include(out, { result: nil }.inspect)
end

def test_require_reline_should_not_trigger_winsize
Expand Down
2 changes: 1 addition & 1 deletion test/rubygems/test_gem_dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_initialize_type_bad
Gem::Dependency.new "monkey" => "1.0"
end

assert_equal 'dependency name must be a String, was {"monkey"=>"1.0"}',
assert_equal "dependency name must be a String, was #{{ "monkey" => "1.0" }.inspect}",
e.message
end

Expand Down
4 changes: 2 additions & 2 deletions test/rubygems/test_require.rb
Original file line number Diff line number Diff line change
Expand Up @@ -689,11 +689,11 @@ def test_require_bundler
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--disable=gems", "-C", dir, "main.rb")
end
assert_match(/{:x=>1}\n{:y=>2}\n$/, err)
assert_match(/#{{ x: 1 }.inspect}\n#{{ y: 2 }.inspect}\n$/, err)
_, err = capture_subprocess_io do
system(*ruby_with_rubygems_in_load_path, "-w", "--enable=gems", "-C", dir, "main.rb")
end
assert_match(/{:x=>1}\n{:y=>2}\n$/, err)
assert_match(/#{{ x: 1 }.inspect}\n#{{ y: 2 }.inspect}\n$/, err)
end
end
end
Expand Down
9 changes: 4 additions & 5 deletions test/test_pp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ def test_array
def test_hash
a = {}
a[0] = a
assert_equal("{0=>{...}}\n", PP.pp(a, ''.dup))
assert_equal("#{a.inspect}\n", PP.pp(a, ''.dup))
assert_equal("{0 => {...}}\n", PP.pp(a, ''.dup))
end

S = Struct.new("S", :a, :b)
Expand Down Expand Up @@ -194,7 +193,7 @@ def test_share_nil

class PPSingleLineTest < Test::Unit::TestCase
def test_hash
assert_equal("{1=>1}", PP.singleline_pp({ 1 => 1}, ''.dup)) # [ruby-core:02699]
assert_equal("{1 => 1}", PP.singleline_pp({ 1 => 1}, ''.dup)) # [ruby-core:02699]
assert_equal("[1#{', 1'*99}]", PP.singleline_pp([1]*100, ''.dup))
end

Expand Down Expand Up @@ -261,7 +260,7 @@ class PPSymbolHash < PP
def pp_hash_pair(k, v)
case k
when Symbol
text k.inspect.delete_prefix(":")
text k.inspect.delete_prefix(":").tr('"', "'")
text ":"
group(1) {
breakable
Expand All @@ -276,7 +275,7 @@ def pp_hash_pair(k, v)
def test_hash_override
obj = {k: 1, "": :null, "0": :zero, 100 => :ten}
assert_equal <<~EXPECT, PPSymbolHash.pp(obj, "".dup)
{k: 1, "": :null, "0": :zero, 100=>:ten}
{k: 1, '': :null, '0': :zero, 100 => :ten}
EXPECT
end
end
Expand Down

0 comments on commit 898f9cb

Please sign in to comment.