Box: show the fully qualified URL of the Ruby::Box doc

This commit is contained in:
Satoshi Tagomori 2025-12-23 22:27:06 +09:00 committed by Satoshi Tagomori
parent 352de161ff
commit f7b48456eb
Notes: git 2025-12-24 06:10:54 +00:00
2 changed files with 12 additions and 7 deletions

5
box.c
View File

@ -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;
}

View File

@ -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'