From f7b48456ebffa1dfe7fe201b27c9c34b5703a53e Mon Sep 17 00:00:00 2001 From: Satoshi Tagomori Date: Tue, 23 Dec 2025 22:27:06 +0900 Subject: [PATCH] Box: show the fully qualified URL of the Ruby::Box doc --- box.c | 5 ++++- test/ruby/test_box.rb | 14 ++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/box.c b/box.c index 616a8acf7d..830172cdd5 100644 --- a/box.c +++ b/box.c @@ -902,6 +902,8 @@ rb_box_eval(VALUE box_value, VALUE str) static int box_experimental_warned = 0; +RUBY_EXTERN const char ruby_api_version_name[]; + void rb_initialize_main_box(void) { @@ -914,7 +916,8 @@ rb_initialize_main_box(void) if (!box_experimental_warned) { rb_category_warn(RB_WARN_CATEGORY_EXPERIMENTAL, "Ruby::Box is experimental, and the behavior may change in the future!\n" - "See doc/language/box.md for known issues, etc."); + "See https://docs.ruby-lang.org/en/%s/Ruby/Box.html for known issues, etc.", + ruby_api_version_name); box_experimental_warned = 1; } diff --git a/test/ruby/test_box.rb b/test/ruby/test_box.rb index e584d233ca..f35d07c086 100644 --- a/test/ruby/test_box.rb +++ b/test/ruby/test_box.rb @@ -3,10 +3,10 @@ require 'test/unit' class TestBox < Test::Unit::TestCase - EXPERIMENTAL_WARNINGS = [ - "warning: Ruby::Box is experimental, and the behavior may change in the future!", - "See doc/language/box.md for known issues, etc." - ].join("\n") + EXPERIMENTAL_WARNING_LINE_PATTERNS = [ + /ruby(\.exe)?: warning: Ruby::Box is experimental, and the behavior may change in the future!/, + %r{See https://docs.ruby-lang.org/en/(master|\d\.\d)/Ruby/Box.html for known issues, etc.} + ] ENV_ENABLE_BOX = {'RUBY_BOX' => '1', 'TEST_DIR' => __dir__} def setup @@ -650,8 +650,9 @@ class TestBox < Test::Unit::TestCase end; # No additional warnings except for experimental warnings - assert_includes error.join("\n"), EXPERIMENTAL_WARNINGS assert_equal 2, error.size + assert_match EXPERIMENTAL_WARNING_LINE_PATTERNS[0], error[0] + assert_match EXPERIMENTAL_WARNING_LINE_PATTERNS[1], error[1] assert_includes output.grep(/^before:/).join("\n"), '/bundled_gems.rb' assert_includes output.grep(/^before:/).join("\n"), '/error_highlight.rb' @@ -672,8 +673,9 @@ class TestBox < Test::Unit::TestCase puts ["after:", $LOADED_FEATURES.select{ it.end_with?("/error_highlight.rb") }&.first].join end; - assert_includes error.join("\n"), EXPERIMENTAL_WARNINGS assert_equal 2, error.size + assert_match EXPERIMENTAL_WARNING_LINE_PATTERNS[0], error[0] + assert_match EXPERIMENTAL_WARNING_LINE_PATTERNS[1], error[1] refute_includes output.grep(/^before:/).join("\n"), '/bundled_gems.rb' refute_includes output.grep(/^before:/).join("\n"), '/error_highlight.rb'