aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_call.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-23 04:51:35 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-23 04:51:35 +0000
commit1d3c07633c1e85c9499c1dec2169bad9fa4ff9f1 (patch)
tree0339fba8927ffd5457fa1c69329ea7cb4101493f /test/ruby/test_call.rb
parentae8f8fddb0f8e89e86d27a7710a9c07addf7901b (diff)
downloadruby-1d3c07633c1e85c9499c1dec2169bad9fa4ff9f1.tar.gz
test_call.rb: add tests
* test_call.rb (test_safe_call): Add test cases for safe navigation operator assignment. [Fix GH-1064] Validate: * can assign an attribute which is `nil` * can "or assign" an attribute which is `nil` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_call.rb')
-rw-r--r--test/ruby/test_call.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/test/ruby/test_call.rb b/test/ruby/test_call.rb
index 33eec70f6a..d2406743af 100644
--- a/test/ruby/test_call.rb
+++ b/test/ruby/test_call.rb
@@ -33,7 +33,7 @@ class TestCall < Test::Unit::TestCase
end
def test_safe_call
- s = Struct.new(:x, :y)
+ s = Struct.new(:x, :y, :z)
o = s.new("x")
assert_equal("X", o.x.?upcase)
assert_nil(o.y.?upcase)
@@ -42,6 +42,10 @@ class TestCall < Test::Unit::TestCase
assert_equal(6, o.x)
o.?x *= 7
assert_equal(42, o.x)
+ o.?y = 5
+ assert_equal(5, o.y)
+ o.?z ||= 6
+ assert_equal(6, o.z)
o = nil
assert_nil(o.?x)