test/test_ruby2ruby.rb in ruby2ruby-2.0.3 vs test/test_ruby2ruby.rb in ruby2ruby-2.0.4
- old
+ new
@@ -78,9 +78,45 @@
inn = s(:and, s(:true), s(:alias, s(:lit, :a), s(:lit, :b)))
out = "true and (alias :a :b)"
util_compare inn, out
end
+ def test_attr_reader_diff
+ inn = s(:defn, :same, s(:args), s(:ivar, :@diff))
+ out = "def same\n @diff\nend"
+ util_compare inn, out
+ end
+
+ def test_attr_reader_same
+ inn = s(:defn, :same, s(:args), s(:ivar, :@same))
+ out = "attr_reader :same"
+ util_compare inn, out
+ end
+
+ def test_attr_reader_same_name_diff_body
+ inn = s(:defn, :same, s(:args), s(:not, s(:ivar, :@same)))
+ out = "def same\n (not @same)\nend"
+ util_compare inn, out
+ end
+
+ def test_attr_writer_diff
+ inn = s(:defn, :same=, s(:args, :o), s(:iasgn, :@diff, s(:lvar, :o)))
+ out = "def same=(o)\n @diff = o\nend"
+ util_compare inn, out
+ end
+
+ def test_attr_writer_same_name_diff_body
+ inn = s(:defn, :same=, s(:args, :o), s(:iasgn, :@same, s(:lit, 42)))
+ out = "def same=(o)\n @same = 42\nend"
+ util_compare inn, out
+ end
+
+ def test_attr_writer_same
+ inn = s(:defn, :same=, s(:args, :o), s(:iasgn, :@same , s(:lvar, :o)))
+ out = "attr_writer :same"
+ util_compare inn, out
+ end
+
def test_dregx_slash
inn = util_thingy(:dregx)
out = '/a"b#{(1 + 1)}c"d\/e/'
util_compare inn, out, /a"b2c"d\/e/
end