Update ruby test for colon-style hash inspect
This commit is contained in:
parent
f4e548924e
commit
7237af75d2
Notes:
git
2024-10-03 09:47:29 +00:00
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user