ruby-changes:40302
From: hsbt <ko1@a...>
Date: Fri, 30 Oct 2015 12:56:17 +0900 (JST)
Subject: [ruby-changes:40302] hsbt:r52383 (trunk): * test/ruby/test_call.rb: added test for safe navigation operator.
hsbt 2015-10-30 12:56:06 +0900 (Fri, 30 Oct 2015) New Revision: 52383 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52383 Log: * test/ruby/test_call.rb: added test for safe navigation operator. [fix GH-1066] Modified files: trunk/ChangeLog trunk/test/ruby/test_call.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 52382) +++ ChangeLog (revision 52383) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Oct 30 12:53:21 2015 yui-knk <spiketeika@g...> + + * test/ruby/test_call.rb: added test for safe navigation operator. + [fix GH-1066] + Fri Oct 30 12:47:34 2015 SHIBATA Hiroshi <hsbt@r...> * ChangeLog: fix wrong commit name. Index: test/ruby/test_call.rb =================================================================== --- test/ruby/test_call.rb (revision 52382) +++ test/ruby/test_call.rb (revision 52383) @@ -52,4 +52,17 @@ class TestCall < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_call.rb#L52 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/