mirror of
https://github.com/ruby/ruby.git
synced 2025-09-19 02:23:59 +02:00
remove string literal concatenation
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
acd82f6e24
commit
db1f7079b6
16 changed files with 35 additions and 44 deletions
|
@ -42,8 +42,7 @@ class TestJSON < Test::Unit::TestCase
|
|||
'h' => 1000.0,
|
||||
'i' => 0.001
|
||||
}
|
||||
@json = '{"a":2,"b":3.141,"c":"c","d":[1,"b",3.14],"e":{"foo":"bar"},'\
|
||||
'"g":"\\"\\u0000\\u001f","h":1.0E3,"i":1.0E-3}'
|
||||
@json = '{"a":2,"b":3.141,"c":"c","d":[1,"b",3.14],"e":{"foo":"bar"},"g":"\\"\\u0000\\u001f","h":1.0E3,"i":1.0E-3}'
|
||||
end
|
||||
|
||||
def test_construction
|
||||
|
@ -190,8 +189,7 @@ class TestJSON < Test::Unit::TestCase
|
|||
assert_equal([1], parse('[1]'))
|
||||
assert_equal([1], parse(' [ 1 ] '))
|
||||
assert_equal(@ary,
|
||||
parse('[[1],["foo"],[3.14],[47.11e+2],[2718.0E-3],[null],[[1,-2,3]]'\
|
||||
',[false],[true]]'))
|
||||
parse('[[1],["foo"],[3.14],[47.11e+2],[2718.0E-3],[null],[[1,-2,3]],[false],[true]]'))
|
||||
assert_equal(@ary, parse(%Q{ [ [1] , ["foo"] , [3.14] \t , [47.11e+2]\s
|
||||
, [2718.0E-3 ],\r[ null] , [[1, -2, 3 ]], [false ],[ true]\n ] }))
|
||||
end
|
||||
|
|
|
@ -19,10 +19,10 @@ class TestRubyMode
|
|||
EVAL_OPT = "--eval"
|
||||
EXPR_SAVE = "(save-buffer)"
|
||||
EXPR_RUBYMODE = "(ruby-mode)"
|
||||
EXPR_NOBACKUP = "(progn" \
|
||||
" (set (make-local-variable \'backup-inhibited) t)" \
|
||||
" (set-buffer-modified-p t)" \
|
||||
")"
|
||||
EXPR_NOBACKUP = "(progn" <<
|
||||
" (set (make-local-variable \'backup-inhibited) t)" <<
|
||||
" (set-buffer-modified-p t)" <<
|
||||
")"
|
||||
|
||||
def run_emacs(src, *exprs)
|
||||
tmp = Tempfile.new(%w"ruby-mode.test. .rb")
|
||||
|
|
|
@ -656,13 +656,13 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
|
|||
assert_equal ['<<-EOS'],
|
||||
scan('heredoc_beg', "<<-EOS\nheredoc\n\tEOS \n")
|
||||
assert_equal ['<<"EOS"'],
|
||||
scan('heredoc_beg', '<<"EOS"'"\nheredoc\nEOS")
|
||||
scan('heredoc_beg', "<<\"EOS\"\nheredoc\nEOS")
|
||||
assert_equal ["<<'EOS'"],
|
||||
scan('heredoc_beg', "<<'EOS'\nheredoc\nEOS")
|
||||
assert_equal ['<<`EOS`'],
|
||||
scan('heredoc_beg', "<<`EOS`\nheredoc\nEOS")
|
||||
assert_equal ['<<" "'],
|
||||
scan('heredoc_beg', '<<" "'"\nheredoc\nEOS")
|
||||
scan('heredoc_beg', "<<\" \"\nheredoc\nEOS")
|
||||
end
|
||||
|
||||
def test_tstring_content_HEREDOC
|
||||
|
|
|
@ -209,9 +209,9 @@ module Test
|
|||
"-v", "-",
|
||||
]
|
||||
cmd = [
|
||||
'END {STDERR.puts '"#{token_dump}"'"FINAL=#{Memory::Status.new.size}"}',
|
||||
%Q[END {STDERR.puts #{token_dump}+"FINAL=\#{Memory::Status.new.size}"}],
|
||||
prepare,
|
||||
'STDERR.puts('"#{token_dump}"'"START=#{$initial_size = Memory::Status.new.size}")',
|
||||
%Q[STDERR.puts(#{token_dump}+"START=\#{$initial_size = Memory::Status.new.size}")],
|
||||
code,
|
||||
].join("\n")
|
||||
_, err, status = EnvUtil.invoke_ruby(args, cmd, true, true)
|
||||
|
|
|
@ -56,6 +56,7 @@ class TestRubyLiteral < Test::Unit::TestCase
|
|||
assert_equal "\n", "\n"
|
||||
bug2500 = '[ruby-core:27228]'
|
||||
bug5262 = '[ruby-core:39222]'
|
||||
verbose, $VERBOSE = $VERBOSE, nil
|
||||
%w[c C- M-].each do |pre|
|
||||
["u", %w[u{ }]].each do |open, close|
|
||||
["?", ['"', '"']].each do |qopen, qclose|
|
||||
|
@ -89,6 +90,8 @@ class TestRubyLiteral < Test::Unit::TestCase
|
|||
assert_equal "\u201c", eval(%[?\\\u{201c}]), bug6069
|
||||
assert_equal "\u201c".encode("euc-jp"), eval(%[?\\\u{201c}].encode("euc-jp")), bug6069
|
||||
assert_equal "\u201c".encode("iso-8859-13"), eval(%[?\\\u{201c}].encode("iso-8859-13")), bug6069
|
||||
ensure
|
||||
$VERBOSE = verbose
|
||||
end
|
||||
|
||||
def test_dstring
|
||||
|
|
|
@ -560,7 +560,7 @@ FOO
|
|||
end
|
||||
|
||||
assert_nothing_raised do
|
||||
eval "x = <<""FOO\r\n1\r\nFOO"
|
||||
eval "x = <\<FOO\r\n1\r\nFOO"
|
||||
end
|
||||
assert_equal("1\n", x)
|
||||
end
|
||||
|
|
|
@ -303,9 +303,9 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
bug4118 = '[ruby-dev:42680]'
|
||||
assert_in_out_err(%w[], "#!/bin/sh\n""#!shebang\n""#!ruby\n""puts __LINE__\n",
|
||||
assert_in_out_err(%w[], "#!/bin/sh\n#!shebang\n#!ruby\nputs __LINE__\n",
|
||||
%w[4], [], bug4118)
|
||||
assert_in_out_err(%w[-x], "#!/bin/sh\n""#!shebang\n""#!ruby\n""puts __LINE__\n",
|
||||
assert_in_out_err(%w[-x], "#!/bin/sh\n#!shebang\n#!ruby\nputs __LINE__\n",
|
||||
%w[4], [], bug4118)
|
||||
end
|
||||
|
||||
|
@ -498,22 +498,22 @@ class TestRubyOptions < Test::Unit::TestCase
|
|||
assert_in_out_err(["-we", "def foo\n eval('a=1')\nend"], "", [], [], feature3446)
|
||||
assert_in_out_err(["-we", "1.times do\n a=1\nend"], "", [], [], feature3446)
|
||||
assert_in_out_err(["-we", "def foo\n 1.times do\n a=1\n end\nend"], "", [], ["-e:3: warning: assigned but unused variable - a"], feature3446)
|
||||
assert_in_out_err(["-we", "def foo\n"" 1.times do |a| end\n""end"], "", [], [])
|
||||
assert_in_out_err(["-we", "def foo\n 1.times do |a| end\nend"], "", [], [])
|
||||
feature6693 = '[ruby-core:46160]'
|
||||
assert_in_out_err(["-we", "def foo\n _a=1\nend"], "", [], [], feature6693)
|
||||
end
|
||||
|
||||
def test_shadowing_variable
|
||||
bug4130 = '[ruby-dev:42718]'
|
||||
assert_in_out_err(["-we", "def foo\n"" a=1\n"" 1.times do |a| end\n"" a\n""end"],
|
||||
assert_in_out_err(["-we", "def foo\n a=1\n 1.times do |a| end\n a\nend"],
|
||||
"", [], ["-e:3: warning: shadowing outer local variable - a"], bug4130)
|
||||
assert_in_out_err(["-we", "def foo\n"" a=1\n"" 1.times do |a| end\n""end"],
|
||||
assert_in_out_err(["-we", "def foo\n a=1\n 1.times do |a| end\nend"],
|
||||
"", [],
|
||||
["-e:3: warning: shadowing outer local variable - a",
|
||||
"-e:2: warning: assigned but unused variable - a",
|
||||
], bug4130)
|
||||
feature6693 = '[ruby-core:46160]'
|
||||
assert_in_out_err(["-we", "def foo\n"" _a=1\n"" 1.times do |_a| end\n""end"],
|
||||
assert_in_out_err(["-we", "def foo\n _a=1\n 1.times do |_a| end\nend"],
|
||||
"", [], [], feature6693)
|
||||
end
|
||||
|
||||
|
|
|
@ -5,10 +5,6 @@ class TestStringchar < Test::Unit::TestCase
|
|||
assert_equal("abcd", "abcd")
|
||||
assert_match(/abcd/, "abcd")
|
||||
assert("abcd" === "abcd")
|
||||
# compile time string concatenation
|
||||
assert_equal("abcd", "ab" "cd")
|
||||
assert_equal("22aacd44", "#{22}aa" "cd#{44}")
|
||||
assert_equal("22aacd445566", "#{22}aa" "cd#{44}" "55" "#{66}")
|
||||
assert("abc" !~ /^$/)
|
||||
assert("abc\n" !~ /^$/)
|
||||
assert("abc" !~ /^d*$/)
|
||||
|
|
|
@ -118,7 +118,7 @@ class TestSyntax < Test::Unit::TestCase
|
|||
|
||||
def test_warn_unreachable
|
||||
assert_warn("test:3: warning: statement not reached\n") do
|
||||
code = "loop do\n" "break\n" "foo\n" "end"
|
||||
code = "loop do\nbreak\nfoo\nend"
|
||||
assert_valid_syntax(code, "test") {$VERBOSE = true}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue