diff options
author | Stan Lo <stan001212@gmail.com> | 2023-05-20 13:28:19 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-05-20 04:28:23 +0000 |
commit | 9ce6c08cafc96f59a6cdf7436c1e708a8c6e4ce8 (patch) | |
tree | 6283df44bf69af2f114d7e4a79a0fce3d9e53383 /test | |
parent | 6d9875ccbf78ca354e63f05a4e37ab1e2c14a9ac (diff) | |
download | ruby-9ce6c08cafc96f59a6cdf7436c1e708a8c6e4ce8.tar.gz |
[ruby/irb] Add assertion for dynamic_prompt's assertion execution
(https://github.com/ruby/irb/pull/586)
Because the assertions for `dynamic_prompt` lives inside a block given to
`RubyLex`, they could be skipped unnoticed if the setup is not correct.
This commit adds a simple assertion to check if the block was actually
executed.
Diffstat (limited to 'test')
-rw-r--r-- | test/irb/test_ruby_lex.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/test/irb/test_ruby_lex.rb b/test/irb/test_ruby_lex.rb index 6a9a5963ae..e2a471c1be 100644 --- a/test/irb/test_ruby_lex.rb +++ b/test/irb/test_ruby_lex.rb @@ -639,6 +639,7 @@ module TestIRB pend if RUBY_ENGINE == 'truffleruby' context = build_context ruby_lex = RubyLex.new(context) + dynamic_prompt_executed = false io = MockIO_DynamicPrompt.new(lines) do |prompt_list| error_message = <<~EOM Expected dynamic prompt: @@ -647,12 +648,14 @@ module TestIRB Actual dynamic prompt: #{prompt_list.join("\n")} EOM + dynamic_prompt_executed = true assert_equal(expected_prompt_list, prompt_list, error_message) end ruby_lex.set_prompt do |ltype, indent, continue, line_no| '%03d:%01d:%1s:%s ' % [line_no, indent, ltype, continue ? '*' : '>'] end ruby_lex.configure_io(io) + assert dynamic_prompt_executed, "dynamic_prompt's assertions were not executed." end def test_dyanmic_prompt |