aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_pattern_matching.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-10-26 18:00:24 +0900
committerGitHub <noreply@github.com>2020-10-26 18:00:24 +0900
commit52c630da004d9273e8e5fc91c6304e9eed902566 (patch)
tree8414c98aa099355174ca6525757128d560ce5f8a /test/ruby/test_pattern_matching.rb
parentcffdacb15a363321e1c1879aa7d94924acafd1cf (diff)
downloadruby-52c630da004d9273e8e5fc91c6304e9eed902566.tar.gz
Assoc pattern matching (#3703)
[Feature #17260] One-line pattern matching using tASSOC R-assignment is rejected instead.
Diffstat (limited to 'test/ruby/test_pattern_matching.rb')
-rw-r--r--test/ruby/test_pattern_matching.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/test/ruby/test_pattern_matching.rb b/test/ruby/test_pattern_matching.rb
index e5a18c5afe..d4de685495 100644
--- a/test/ruby/test_pattern_matching.rb
+++ b/test/ruby/test_pattern_matching.rb
@@ -272,7 +272,7 @@ class TestPatternMatching < Test::Unit::TestCase
end
assert_syntax_error(%q{
- 0 in [a, a]
+ 0 => [a, a]
}, /duplicated variable name/)
end
@@ -737,10 +737,10 @@ END
end
def test_find_pattern
- [0, 1, 2] in [*, 1 => a, *]
+ [0, 1, 2] => [*, 1 => a, *]
assert_equal(1, a)
- [0, 1, 2] in [*a, 1 => b, *c]
+ [0, 1, 2] => [*a, 1 => b, *c]
assert_equal([0], a)
assert_equal(1, b)
assert_equal([2], c)
@@ -763,7 +763,7 @@ END
end
end
- [0, 1, 2] in [*a, 1 => b, 2 => c, *d]
+ [0, 1, 2] => [*a, 1 => b, 2 => c, *d]
assert_equal([0], a)
assert_equal(1, b)
assert_equal(2, c)
@@ -1451,18 +1451,18 @@ END
################################################################
- def test_modifier_in
- 1 in a
+ def test_assoc
+ 1 => a
assert_equal 1, a
assert_raise(NoMatchingPatternError) do
- {a: 1} in {a: 0}
+ {a: 1} => {a: 0}
end
- assert_syntax_error("if {} in {a:}; end", /void value expression/)
+ assert_syntax_error("if {} => {a:}; end", /void value expression/)
assert_syntax_error(%q{
- 1 in a, b
+ 1 => a, b
}, /unexpected/, '[ruby-core:95098]')
assert_syntax_error(%q{
- 1 in a:
+ 1 => a:
}, /unexpected/, '[ruby-core:95098]')
end
@@ -1480,7 +1480,7 @@ END
def test_experimental_warning
assert_experimental_warning("case 0; in 0; end")
- assert_experimental_warning("0 in 0")
+ assert_experimental_warning("0 => 0")
end
end
END_of_GUARD