summaryrefslogtreecommitdiff
path: root/test/ruby/test_call.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-30 03:56:06 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-30 03:56:06 +0000
commita2845a44ffd3c9ddef704dac1ba1fa2766a64555 (patch)
treeae2a6c2f1da0234e2fd50a8dddfbd8dedf5cfd9b /test/ruby/test_call.rb
parent8af123076ea8c83296b60dbc324f1cc53a616a2e (diff)
* test/ruby/test_call.rb: added test for safe navigation operator.
[fix GH-1066] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_call.rb')
-rw-r--r--test/ruby/test_call.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_call.rb b/test/ruby/test_call.rb
index d2406743af..12793a7572 100644
--- a/test/ruby/test_call.rb
+++ b/test/ruby/test_call.rb
@@ -52,4 +52,17 @@ class TestCall < Test::Unit::TestCase
assert_nothing_raised(NoMethodError) {o.?x = 6}
assert_nothing_raised(NoMethodError) {o.?x *= 7}
end
+
+ def test_safe_call_evaluate_arguments_only_method_call_is_made
+ count = 0
+ proc = proc { count += 1; 1 }
+ s = Struct.new(:x, :y)
+ o = s.new(["a", "b", "c"])
+
+ o.y.?at(proc.call)
+ assert_equal(0, count)
+
+ o.x.?at(proc.call)
+ assert_equal(1, count)
+ end
end