Skip to content

Commit bb68645

Browse files
authored
Add assertion for dynamic_prompt's assertion execution (#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.
1 parent b5f3efd commit bb68645

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

test/irb/test_ruby_lex.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ def assert_dynamic_prompt(lines, expected_prompt_list)
639639
pend if RUBY_ENGINE == 'truffleruby'
640640
context = build_context
641641
ruby_lex = RubyLex.new(context)
642+
dynamic_prompt_executed = false
642643
io = MockIO_DynamicPrompt.new(lines) do |prompt_list|
643644
error_message = <<~EOM
644645
Expected dynamic prompt:
@@ -647,12 +648,14 @@ def assert_dynamic_prompt(lines, expected_prompt_list)
647648
Actual dynamic prompt:
648649
#{prompt_list.join("\n")}
649650
EOM
651+
dynamic_prompt_executed = true
650652
assert_equal(expected_prompt_list, prompt_list, error_message)
651653
end
652654
ruby_lex.set_prompt do |ltype, indent, continue, line_no|
653655
'%03d:%01d:%1s:%s ' % [line_no, indent, ltype, continue ? '*' : '>']
654656
end
655657
ruby_lex.configure_io(io)
658+
assert dynamic_prompt_executed, "dynamic_prompt's assertions were not executed."
656659
end
657660

658661
def test_dyanmic_prompt

0 commit comments

Comments
 (0)