* test_struct.rb: Test that initialize is overridable [#11708]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
marcandre 2015-12-16 03:25:09 +00:00
parent 632b1e9442
commit f6f7073e12
2 changed files with 10 additions and 0 deletions

View file

@ -94,6 +94,12 @@ module TestStruct
def test_initialize
klass = @Struct.new(:a)
assert_raise(ArgumentError) { klass.new(1, 2) }
klass = @Struct.new(:total) do
def initialize(a, b)
super(a+b)
end
end
assert_equal 3, klass.new(1,2).total
end
def test_each