mirror of
https://github.com/ruby/ruby.git
synced 2025-09-16 17:14:01 +02:00
* 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:
parent
632b1e9442
commit
f6f7073e12
2 changed files with 10 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue