summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2019-12-20 23:48:15 +0900
committerNobuyoshi Nakada <[email protected]>2019-12-20 23:48:15 +0900
commit07e595fdbd75ed44473073cdf8cd758572d11709 ()
tree05adbd2b9d08690bed5be134acf2cb4111c4ea07
parentdd7f0c87c9da8e695c38a6529deb6e0f24f6d06c (diff)
Added `experimental` warning category
[Feature #16420]
-rw-r--r--error.c3
-rw-r--r--internal.h1
-rw-r--r--parse.y3
-rw-r--r--test/ruby/test_exception.rb1
-rw-r--r--test/ruby/test_pattern_matching.rb26
5 files changed, 29 insertions, 5 deletions
@@ -144,6 +144,9 @@ rb_warning_category_from_name(VALUE category)
if (category == ID2SYM(rb_intern("deprecated"))) {
cat = RB_WARN_CATEGORY_DEPRECATED;
}
else {
rb_raise(rb_eArgError, "unknown category: %"PRIsVALUE, category);
}
@@ -1558,6 +1558,7 @@ PRINTF_ARGS(void rb_syserr_enc_warning(int err, rb_encoding *enc, const char *fm
typedef enum {
RB_WARN_CATEGORY_NONE,
RB_WARN_CATEGORY_DEPRECATED,
} rb_warning_category_t;
rb_warning_category_t rb_warning_category_from_name(VALUE category);
bool rb_warning_category_enabled_p(rb_warning_category_t category);
@@ -11457,7 +11457,8 @@ new_case3(struct parser_params *p, NODE *val, NODE *pat, const YYLTYPE *loc)
{
NODE *node = NEW_CASE3(val, pat, loc);
- rb_warn0L(nd_line(node), "Pattern matching is experimental, and the behavior may change in future versions of Ruby!");
return node;
}
@@ -1266,6 +1266,7 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
assert_raise(TypeError) {Warning[nil]}
assert_raise(ArgumentError) {Warning[:XXXX]}
assert_include([true, false], Warning[:deprecated])
end
def test_undefined_backtrace
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require 'test/unit'
-verbose, $VERBOSE = $VERBOSE, nil # suppress "warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby!"
eval "\n#{<<~'END_of_GUARD'}", binding, __FILE__, __LINE__
class TestPatternMatching < Test::Unit::TestCase
class C
@@ -92,7 +92,8 @@ class TestPatternMatching < Test::Unit::TestCase
end
assert_block do
- verbose, $VERBOSE = $VERBOSE, nil # suppress "warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby!"
eval(%q{
case true
in a
@@ -100,7 +101,7 @@ class TestPatternMatching < Test::Unit::TestCase
end
})
ensure
- $VERBOSE = verbose
end
assert_block do
@@ -1274,6 +1275,23 @@ END
1 in a:
}, /unexpected/, '[ruby-core:95098]')
end
end
END_of_GUARD
-$VERBOSE = verbose