diff options
author | tompng <tomoyapenguin@gmail.com> | 2024-06-08 00:23:12 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2024-10-03 18:47:09 +0900 |
commit | 7237af75d2aa700454fbaba9bda7a9283413d903 (patch) | |
tree | 9a3d57943a0d60786dc93f5b2ed6e24ea8c9e757 | |
parent | f4e548924e36c9b1d19551a943881cb57bb41471 (diff) |
Update ruby test for colon-style hash inspect
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/10924
-rw-r--r-- | test/coverage/test_coverage.rb | 30 | ||||
-rw-r--r-- | test/ruby/test_ast.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_exception.rb | 4 | ||||
-rw-r--r-- | test/ruby/test_hash.rb | 4 | ||||
-rw-r--r-- | test/ruby/test_keyword.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_pattern_matching.rb | 10 | ||||
-rw-r--r-- | test/ruby/test_sprintf.rb | 2 |
7 files changed, 27 insertions, 27 deletions
diff --git a/test/coverage/test_coverage.rb b/test/coverage/test_coverage.rb index 4773280cae..2fe7f1b0b9 100644 --- a/test/coverage/test_coverage.rb +++ b/test/coverage/test_coverage.rb @@ -649,9 +649,9 @@ class TestCoverage < Test::Unit::TestCase end exp = [ - "{:lines=>[1, 0, 0, nil, 0, nil, nil]}", - "{:lines=>[0, 1, 1, nil, 0, nil, nil]}", - "{:lines=>[0, 1, 0, nil, 1, nil, nil]}", + { lines: [1, 0, 0, nil, 0, nil, nil] }.inspect, + { lines: [0, 1, 1, nil, 0, nil, nil] }.inspect, + { lines: [0, 1, 0, nil, 1, nil, nil] }.inspect, ] assert_in_out_err(ARGV, <<-"end;", exp, []) Coverage.start(lines: true) @@ -682,10 +682,10 @@ class TestCoverage < Test::Unit::TestCase end exp = [ - "{:branches=>{[:if, 0, 2, 2, 6, 5]=>{[:then, 1, 3, 4, 3, 8]=>0, [:else, 2, 5, 4, 5, 12]=>0}}}", - "{:branches=>{[:if, 0, 2, 2, 6, 5]=>{[:then, 1, 3, 4, 3, 8]=>1, [:else, 2, 5, 4, 5, 12]=>0}}}", - "{:branches=>{[:if, 0, 2, 2, 6, 5]=>{[:then, 1, 3, 4, 3, 8]=>0, [:else, 2, 5, 4, 5, 12]=>1}}}", - "{:branches=>{[:if, 0, 2, 2, 6, 5]=>{[:then, 1, 3, 4, 3, 8]=>0, [:else, 2, 5, 4, 5, 12]=>1}}}", + { branches: { [:if, 0, 2, 2, 6, 5] => { [:then, 1, 3, 4, 3, 8] => 0, [:else, 2, 5, 4, 5, 12] => 0 } } }.inspect, + { branches: { [:if, 0, 2, 2, 6, 5] => { [:then, 1, 3, 4, 3, 8] => 1, [:else, 2, 5, 4, 5, 12] => 0 } } }.inspect, + { branches: { [:if, 0, 2, 2, 6, 5] => { [:then, 1, 3, 4, 3, 8] => 0, [:else, 2, 5, 4, 5, 12] => 1 } } }.inspect, + { branches: { [:if, 0, 2, 2, 6, 5] => { [:then, 1, 3, 4, 3, 8] => 0, [:else, 2, 5, 4, 5, 12] => 1 } } }.inspect, ] assert_in_out_err(ARGV, <<-"end;", exp, []) Coverage.start(branches: true) @@ -718,10 +718,10 @@ class TestCoverage < Test::Unit::TestCase end exp = [ - "{:methods=>{[Object, :foo, 1, 0, 7, 3]=>0}}", - "{:methods=>{[Object, :foo, 1, 0, 7, 3]=>1}}", - "{:methods=>{[Object, :foo, 1, 0, 7, 3]=>1}}", - "{:methods=>{[Object, :foo, 1, 0, 7, 3]=>1}}" + { methods: { [Object, :foo, 1, 0, 7, 3] => 0 } }.inspect, + { methods: { [Object, :foo, 1, 0, 7, 3] => 1 } }.inspect, + { methods: { [Object, :foo, 1, 0, 7, 3] => 1 } }.inspect, + { methods: { [Object, :foo, 1, 0, 7, 3] => 1 } }.inspect ] assert_in_out_err(ARGV, <<-"end;", exp, []) Coverage.start(methods: true) @@ -754,10 +754,10 @@ class TestCoverage < Test::Unit::TestCase end exp = [ - "{:oneshot_lines=>[1]}", - "{:oneshot_lines=>[2, 3]}", - "{:oneshot_lines=>[5]}", - "{:oneshot_lines=>[]}", + { oneshot_lines: [1] }.inspect, + { oneshot_lines: [2, 3] }.inspect, + { oneshot_lines: [5] }.inspect, + { oneshot_lines: [] }.inspect, ] assert_in_out_err(ARGV, <<-"end;", exp, []) Coverage.start(oneshot_lines: true) diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index 91f4250cfc..edfc25c43d 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -803,7 +803,7 @@ dummy "puts RubyVM::AbstractSyntaxTree.of(->{ 1 + 2 }, keep_script_lines: true).script_lines", "p SCRIPT_LINES__" ] - test_stdout = lines + ['{"-e"=>[]}'] + test_stdout = lines + ['{"-e" => []}'] assert_in_out_err(["-e", lines.join("\n")], "", test_stdout, []) end diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 09df1b5dcb..84581180b6 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -1128,11 +1128,11 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status| assert_raise(ArgumentError) {warn("test warning", uplevel: -1)} assert_in_out_err(["-e", "warn 'ok', uplevel: 1"], '', [], /warning:/) warning = capture_warning_warn {warn("test warning", {uplevel: 0})} - assert_match(/test warning.*{:uplevel=>0}/m, warning[0]) + assert_match(/test warning.*{uplevel: 0}/m, warning[0]) warning = capture_warning_warn {warn("test warning", **{uplevel: 0})} assert_equal("#{__FILE__}:#{__LINE__-1}: warning: test warning\n", warning[0]) warning = capture_warning_warn {warn("test warning", {uplevel: 0}, **{})} - assert_equal("test warning\n{:uplevel=>0}\n", warning[0]) + assert_equal("test warning\n{uplevel: 0}\n", warning[0]) assert_raise(ArgumentError) {warn("test warning", foo: 1)} end diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index 8219abc678..9578e71f00 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -2295,7 +2295,7 @@ class TestHashOnly < Test::Unit::TestCase h = obj.h h[obj] = true - assert_equal '{0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5, 6=>6, 7=>7, 8=>8, 9=>9, test=>true}', h.inspect + assert_equal '{0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, test => true}', h.inspect end def test_ar2st_delete @@ -2309,7 +2309,7 @@ class TestHashOnly < Test::Unit::TestCase h[obj2] = true h.delete obj - assert_equal '{0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5, 6=>6, 7=>7, 8=>8, 9=>9}', h.inspect + assert_equal '{0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9}', h.inspect end def test_ar2st_lookup diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index a214acc232..6da1b73c15 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -2863,7 +2863,7 @@ class TestKeywordArguments < Test::Unit::TestCase end def test_top_ruby2_keywords - assert_in_out_err([], <<-INPUT, ["[1, 2, 3]", "{:k=>1}"], []) + assert_in_out_err([], <<-INPUT, ["[1, 2, 3]", "{k: 1}"], []) def bar(*a, **kw) p a, kw end diff --git a/test/ruby/test_pattern_matching.rb b/test/ruby/test_pattern_matching.rb index cfe3bd1e19..92a3244fc2 100644 --- a/test/ruby/test_pattern_matching.rb +++ b/test/ruby/test_pattern_matching.rb @@ -1664,7 +1664,7 @@ END raise a # suppress "unused variable: a" warning end - assert_raise_with_message(NoMatchingPatternKeyError, "{:a=>0}: key not found: :aa") do + assert_raise_with_message(NoMatchingPatternKeyError, "{a: 0}: key not found: :aa") do {a: 0} => {aa:} raise aa # suppress "unused variable: aa" warning rescue NoMatchingPatternKeyError => e @@ -1673,7 +1673,7 @@ END raise e end - assert_raise_with_message(NoMatchingPatternKeyError, "{:a=>{:b=>0}}: key not found: :bb") do + assert_raise_with_message(NoMatchingPatternKeyError, "{a: {b: 0}}: key not found: :bb") do {a: {b: 0}} => {a: {bb:}} raise bb # suppress "unused variable: bb" warning rescue NoMatchingPatternKeyError => e @@ -1682,15 +1682,15 @@ END raise e end - assert_raise_with_message(NoMatchingPatternError, "{:a=>0}: 1 === 0 does not return true") do + assert_raise_with_message(NoMatchingPatternError, "{a: 0}: 1 === 0 does not return true") do {a: 0} => {a: 1} end - assert_raise_with_message(NoMatchingPatternError, "{:a=>0}: {:a=>0} is not empty") do + assert_raise_with_message(NoMatchingPatternError, "{a: 0}: {a: 0} is not empty") do {a: 0} => {} end - assert_raise_with_message(NoMatchingPatternError, "[{:a=>0}]: rest of {:a=>0} is not empty") do + assert_raise_with_message(NoMatchingPatternError, "[{a: 0}]: rest of {a: 0} is not empty") do [{a: 0}] => [{**nil}] end end diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb index 8cf2c63a20..498f93aec4 100644 --- a/test/ruby/test_sprintf.rb +++ b/test/ruby/test_sprintf.rb @@ -235,7 +235,7 @@ class TestSprintf < Test::Unit::TestCase def test_hash options = {:capture=>/\d+/} - assert_equal("with options {:capture=>/\\d+/}", sprintf("with options %p" % options)) + assert_equal("with options #{options.inspect}", sprintf("with options %p" % options)) end def test_inspect |