summaryrefslogtreecommitdiffhomepage
path: root/test/t/syntax.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2016-09-08 21:13:12 +0900
committerGitHub <[email protected]>2016-09-08 21:13:12 +0900
commit08a1dd2ac89333bd928a3300f712d1a7fb57e8ff (patch)
treee6655656d301bbf0cca0977bd5e99eab089c6079 /test/t/syntax.rb
parentcd5133c57065d9645c125c1ce7b5dc4ce6d39bdd (diff)
parentd46702234700d6b58177829a863224b0b59d4de1 (diff)
downloadmruby-08a1dd2ac89333bd928a3300f712d1a7fb57e8ff.tar.gz
mruby-08a1dd2ac89333bd928a3300f712d1a7fb57e8ff.zip
Merge pull request #3207 from ksss/splat
Fix SEGV when splat object
Diffstat (limited to 'test/t/syntax.rb')
-rw-r--r--test/t/syntax.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/t/syntax.rb b/test/t/syntax.rb
index 25ae09828..3bc68484b 100644
--- a/test/t/syntax.rb
+++ b/test/t/syntax.rb
@@ -307,6 +307,36 @@ assert('Return values of no expression case statement') do
assert_equal 1, when_value
end
+assert('splat object in assignment') do
+ o = Object.new
+ def o.to_a
+ nil
+ end
+ assert_equal [o], (a = *o)
+
+ def o.to_a
+ 1
+ end
+ assert_raise(TypeError) { a = *o }
+
+ def o.to_a
+ [2]
+ end
+ assert_equal [2], (a = *o)
+end
+
+assert('splat object in case statement') do
+ o = Object.new
+ def o.to_a
+ nil
+ end
+ a = case o
+ when *o
+ 1
+ end
+ assert_equal 1, a
+end
+
assert('splat in case statement') do
values = [3,5,1,7,8]
testa = [1,2,7]