From a4ee1b9d886fff3981d2a2beaa0eb126ebc4b0dd Mon Sep 17 00:00:00 2001 From: tompng Date: Sat, 25 Oct 2025 15:45:30 +0900 Subject: [PATCH] Fix prompt cache flaky test "#{rand}" might include "e-" which doesn't match to /[\d.]+/ --- test/irb/test_context.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index 0c1c527b4..f90360379 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -646,11 +646,11 @@ def test_prompt_main_inspect_escape def test_prompt_part_cached main = Object.new - def main.to_s; "to_s#{rand}"; end - def main.inspect; "inspect#{rand}"; end + def main.to_s; "to_s#{rand(10000)}"; end + def main.inspect; "inspect#{rand(10000)}"; end irb = IRB::Irb.new(IRB::WorkSpace.new(main), TestInputMethod.new) format = '[%m %M %m %M]>' - pattern = /\A\[(to_s[\d.]+) (inspect[\d.]+) \1 \2\]>\z/ + pattern = /\A\[(to_s\d+) (inspect\d+) \1 \2\]>\z/ prompt1, prompt2 = nil irb.send(:with_prompt_part_cached) do