mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/error_highlight] Fix leaked tempfiles
https://github.com/ruby/error_highlight/commit/8b353a10a7
This commit is contained in:
parent
6073a8bdc0
commit
29ed9d1aaa
1 changed files with 12 additions and 10 deletions
|
@ -1002,34 +1002,36 @@ undefined method `time' for 1:Integer
|
|||
end
|
||||
|
||||
def test_hard_tabs
|
||||
tmp = Tempfile.new(["error_highlight_test", ".rb"], binmode: true)
|
||||
tmp << "\t \t1.time {}\n"
|
||||
tmp.close(false)
|
||||
Tempfile.create(["error_highlight_test", ".rb"], binmode: true) do |tmp|
|
||||
tmp << "\t \t1.time {}\n"
|
||||
tmp.close
|
||||
|
||||
assert_error_message(NoMethodError, <<~END.gsub("_", "\t")) do
|
||||
assert_error_message(NoMethodError, <<~END.gsub("_", "\t")) do
|
||||
undefined method `time' for 1:Integer
|
||||
|
||||
_ _1.time {}
|
||||
_ _ ^^^^^
|
||||
END
|
||||
|
||||
load tmp.path
|
||||
load tmp.path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_no_final_newline
|
||||
tmp = Tempfile.new(["error_highlight_test", ".rb"])
|
||||
tmp << "1.time {}"
|
||||
tmp.close(false)
|
||||
Tempfile.create(["error_highlight_test", ".rb"]) do |tmp|
|
||||
tmp << "1.time {}"
|
||||
tmp.close
|
||||
|
||||
assert_error_message(NoMethodError, <<~END) do
|
||||
assert_error_message(NoMethodError, <<~END) do
|
||||
undefined method `time' for 1:Integer
|
||||
|
||||
1.time {}
|
||||
^^^^^
|
||||
END
|
||||
|
||||
load tmp.path
|
||||
load tmp.path
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue