Skip to content

Commit 24f48c8

Browse files
nobuk0kubun
authored andcommitted
[Bug #20982] Put spaces in ENV.inspect results as well as Hash
1 parent 80f2329 commit 24f48c8

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5923,7 +5923,7 @@ env_inspect(VALUE _)
59235923
}
59245924
if (s) {
59255925
rb_str_buf_append(str, rb_str_inspect(env_enc_str_new(*env, s-*env, enc)));
5926-
rb_str_buf_cat2(str, "=>");
5926+
rb_str_buf_cat2(str, " => ");
59275927
s++;
59285928
rb_str_buf_append(str, rb_str_inspect(env_enc_str_new(s, strlen(s), enc)));
59295929
}

spec/ruby/core/env/inspect_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
it "returns a String that looks like a Hash with real data" do
66
ENV["foo"] = "bar"
7-
ENV.inspect.should =~ /\{.*"foo"=>"bar".*\}/
7+
ENV.inspect.should =~ /\{.*"foo" *=> *"bar".*\}/
88
ENV.delete "foo"
99
end
1010

test/ruby/test_env.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def test_inspect
347347
ENV["foo"] = "bar"
348348
ENV["baz"] = "qux"
349349
s = ENV.inspect
350-
expected = [%("foo"=>"bar"), %("baz"=>"qux")]
350+
expected = [%("foo" => "bar"), %("baz" => "qux")]
351351
unless s.start_with?(/\{"foo"/i)
352352
expected.reverse!
353353
end
@@ -363,7 +363,7 @@ def test_inspect_encoding
363363
ENV.clear
364364
key = "VAR\u{e5 e1 e2 e4 e3 101 3042}"
365365
ENV[key] = "foo"
366-
assert_equal(%{{"VAR\u{e5 e1 e2 e4 e3 101 3042}"=>"foo"}}, ENV.inspect)
366+
assert_equal(%{{"VAR\u{e5 e1 e2 e4 e3 101 3042}" => "foo"}}, ENV.inspect)
367367
end
368368

369369
def test_to_a
@@ -1097,7 +1097,7 @@ def test_inspect_in_ractor
10971097
Ractor.yield s
10981098
end
10991099
s = r.take
1100-
expected = ['"foo"=>"bar"', '"baz"=>"qux"']
1100+
expected = ['"foo" => "bar"', '"baz" => "qux"']
11011101
unless s.start_with?(/\{"foo"/i)
11021102
expected.reverse!
11031103
end

0 commit comments

Comments
 (0)