Skip to content

Commit 1f2a102

Browse files
committed
Module#attr family accepts strings as well as symbols
1 parent 85eb33d commit 1f2a102

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/ruby/test_module.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,7 @@ def test_attr
14521452
c.instance_eval { attr_reader :"." }
14531453
end
14541454

1455+
c = Class.new
14551456
assert_equal([:a], c.class_eval { attr :a })
14561457
assert_equal([:b, :c], c.class_eval { attr :b, :c })
14571458
assert_equal([:d], c.class_eval { attr_reader :d })
@@ -1460,6 +1461,16 @@ def test_attr
14601461
assert_equal([:h=, :i=], c.class_eval { attr_writer :h, :i })
14611462
assert_equal([:j, :j=], c.class_eval { attr_accessor :j })
14621463
assert_equal([:k, :k=, :l, :l=], c.class_eval { attr_accessor :k, :l })
1464+
1465+
c = Class.new
1466+
assert_equal([:a], c.class_eval { attr "a" })
1467+
assert_equal([:b, :c], c.class_eval { attr "b", "c" })
1468+
assert_equal([:d], c.class_eval { attr_reader "d" })
1469+
assert_equal([:e, :f], c.class_eval { attr_reader "e", "f" })
1470+
assert_equal([:g=], c.class_eval { attr_writer "g" })
1471+
assert_equal([:h=, :i=], c.class_eval { attr_writer "h", "i" })
1472+
assert_equal([:j, :j=], c.class_eval { attr_accessor "j" })
1473+
assert_equal([:k, :k=, :l, :l=], c.class_eval { attr_accessor "k", "l" })
14631474
end
14641475

14651476
def test_alias_method

0 commit comments

Comments
 (0)