test/test_ruby2ruby.rb in ruby2ruby-2.3.0 vs test/test_ruby2ruby.rb in ruby2ruby-2.3.1

- old
+ new

@@ -410,10 +410,32 @@ out = "x&.>(1)" util_compare inn, out end + def test_safe_op_asgn + inn = s(:safe_op_asgn, + s(:call, nil, :x), + s(:call, nil, :z, s(:lit, 1)), + :y, + :+) + + out = "x&.y += z(1)" + util_compare inn, out + end + + def test_safe_op_asgn2 + inn = s(:safe_op_asgn2, + s(:call, nil, :x), + :y=, + :"||", + s(:lit, 1)) + + out = "x&.y ||= 1" + util_compare inn, out + end + def test_splat_call inn = s(:call, nil, :x, s(:splat, s(:call, s(:call, nil, :line), @@ -513,10 +535,18 @@ out = "(1 #{op} 2)" util_compare inn, out end end + def test_binary_operators_with_multiple_arguments + Ruby2Ruby::BINARY.each do |op| + inn = s(:call, s(:lvar, :x), op, s(:lit, 2), s(:lit, 3)) + out = "x.#{op}(2, 3)" + util_compare inn, out + end + end + def test_call_empty_hash inn = s(:call, nil, :foo, s(:hash)) out = "foo({})" util_compare inn, out end @@ -586,9 +616,20 @@ end def test_nested_rescue_exception2 inn = s(:ensure, s(:rescue, s(:lit, 2), s(:resbody, s(:array, s(:const, :Exception)), s(:lit, 3))), s(:lit, 1)) out = "begin\n 2\nrescue Exception\n 3\nensure\n 1\nend" + util_compare inn, out + end + + def test_op_asgn + inn = s(:op_asgn, + s(:call, nil, :x), + s(:call, nil, :z, s(:lit, 1)), + :y, + :+) + + out = "x.y += z(1)" util_compare inn, out end def test_rescue_block inn = s(:rescue,