summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2018-07-28 00:07:56 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-05-05 00:29:12 +0900
commitff21e75d32e27a2b362ed53fb471828876b54418 (patch)
treef32f96d4bfb0ecf917428a893d9aff9bb84a47cc /test
parent848edb03f8d3e5f5e97d3ea45fec592d87d73b05 (diff)
parse.y: duplicated when clause warning
* parse.y (case_args): moved "duplicated when clause" warning from compile phase, so that `ruby -wc` shows them.
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_syntax.rb17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 771764720b..ff8c62f6a1 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -515,8 +515,8 @@ WARN
end
def test_duplicated_when
- w = 'warning: duplicated when clause is ignored'
- assert_warning(/3: #{w}.+4: #{w}.+4: #{w}.+5: #{w}.+5: #{w}/m){
+ w = 'warning: duplicated `when\' clause with line 3 is ignored'
+ assert_warning(/3: #{w}.+4: #{w}.+4: #{w}.+5: #{w}.+5: #{w}/m) {
eval %q{
case 1
when 1, 1
@@ -525,7 +525,7 @@ WARN
end
}
}
- assert_warning(/#{w}/){#/3: #{w}.+4: #{w}.+5: #{w}.+5: #{w}/m){
+ assert_warning(/#{w}/) {#/3: #{w}.+4: #{w}.+5: #{w}.+5: #{w}/m){
a = a = 1
eval %q{
case 1
@@ -537,6 +537,17 @@ WARN
}
end
+ def test_duplicated_when_check_option
+ w = /duplicated `when\' clause with line 3 is ignored/
+ assert_in_out_err(%[-wc], "#{<<~"begin;"}\n#{<<~'end;'}", ["Syntax OK"], w)
+ begin;
+ case 1
+ when 1
+ when 1
+ end
+ end;
+ end
+
def test_invalid_break
assert_syntax_error("def m; break; end", /Invalid break/)
assert_syntax_error('/#{break}/', /Invalid break/)