summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_pattern_matching.rb22
-rw-r--r--test/ruby/test_syntax.rb13
2 files changed, 18 insertions, 17 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
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 2e0d306c21..0a370d416d 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -1430,8 +1430,6 @@ eom
assert_syntax_error('private def obj.foo = 42', /unexpected '='/)
assert_valid_syntax('private def obj.foo() = 42')
assert_valid_syntax('private def obj.inc(x) = x + 1')
- eval('def self.inc(x) = x + 1 => @x')
- assert_equal(:inc, @x)
k = Class.new do
class_eval('def rescued(x) = raise("to be caught") rescue "instance #{x}"')
class_eval('def self.rescued(x) = raise("to be caught") rescue "class #{x}"')
@@ -1715,10 +1713,13 @@ eom
end
def test_rightward_assign
- assert_equal(1, eval("1 => a"))
- assert_equal([2,3], eval("13.divmod(5) => a,b; [a, b]"))
- assert_equal([2,3,2,3], eval("13.divmod(5) => a,b => c, d; [a, b, c, d]"))
- assert_equal(3, eval("1+2 => a"))
+ a = b = nil
+ EnvUtil.suppress_warning {eval("1 => a")}
+ assert_equal(1, a)
+ EnvUtil.suppress_warning {eval("13.divmod(5) => [a,b]")}
+ assert_equal([2,3], [a, b])
+ EnvUtil.suppress_warning {eval("1+2 => a")}
+ assert_equal(3, a)
end
private