Skip to content

Commit

Permalink
Add testing for regression
Browse files Browse the repository at this point in the history
  • Loading branch information
ksss committed Sep 8, 2016
1 parent d265c03 commit d467022
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/t/syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,36 @@ def fb
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]
Expand Down

0 comments on commit d467022

Please sign in to comment.