Skip to content

Commit f7b4845

Browse files
committed
Box: show the fully qualified URL of the Ruby::Box doc
1 parent 352de16 commit f7b4845

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

box.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,8 @@ rb_box_eval(VALUE box_value, VALUE str)
902902

903903
static int box_experimental_warned = 0;
904904

905+
RUBY_EXTERN const char ruby_api_version_name[];
906+
905907
void
906908
rb_initialize_main_box(void)
907909
{
@@ -914,7 +916,8 @@ rb_initialize_main_box(void)
914916
if (!box_experimental_warned) {
915917
rb_category_warn(RB_WARN_CATEGORY_EXPERIMENTAL,
916918
"Ruby::Box is experimental, and the behavior may change in the future!\n"
917-
"See doc/language/box.md for known issues, etc.");
919+
"See https://docs.ruby-lang.org/en/%s/Ruby/Box.html for known issues, etc.",
920+
ruby_api_version_name);
918921
box_experimental_warned = 1;
919922
}
920923

test/ruby/test_box.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
require 'test/unit'
44

55
class TestBox < Test::Unit::TestCase
6-
EXPERIMENTAL_WARNINGS = [
7-
"warning: Ruby::Box is experimental, and the behavior may change in the future!",
8-
"See doc/language/box.md for known issues, etc."
9-
].join("\n")
6+
EXPERIMENTAL_WARNING_LINE_PATTERNS = [
7+
/ruby(\.exe)?: warning: Ruby::Box is experimental, and the behavior may change in the future!/,
8+
%r{See https://docs.ruby-lang.org/en/(master|\d\.\d)/Ruby/Box.html for known issues, etc.}
9+
]
1010
ENV_ENABLE_BOX = {'RUBY_BOX' => '1', 'TEST_DIR' => __dir__}
1111

1212
def setup
@@ -650,8 +650,9 @@ def test_prelude_gems_and_loaded_features
650650
end;
651651

652652
# No additional warnings except for experimental warnings
653-
assert_includes error.join("\n"), EXPERIMENTAL_WARNINGS
654653
assert_equal 2, error.size
654+
assert_match EXPERIMENTAL_WARNING_LINE_PATTERNS[0], error[0]
655+
assert_match EXPERIMENTAL_WARNING_LINE_PATTERNS[1], error[1]
655656

656657
assert_includes output.grep(/^before:/).join("\n"), '/bundled_gems.rb'
657658
assert_includes output.grep(/^before:/).join("\n"), '/error_highlight.rb'
@@ -672,8 +673,9 @@ def test_prelude_gems_and_loaded_features_with_disable_gems
672673
puts ["after:", $LOADED_FEATURES.select{ it.end_with?("/error_highlight.rb") }&.first].join
673674
end;
674675

675-
assert_includes error.join("\n"), EXPERIMENTAL_WARNINGS
676676
assert_equal 2, error.size
677+
assert_match EXPERIMENTAL_WARNING_LINE_PATTERNS[0], error[0]
678+
assert_match EXPERIMENTAL_WARNING_LINE_PATTERNS[1], error[1]
677679

678680
refute_includes output.grep(/^before:/).join("\n"), '/bundled_gems.rb'
679681
refute_includes output.grep(/^before:/).join("\n"), '/error_highlight.rb'

0 commit comments

Comments
 (0)