Skip to content

Commit

Permalink
Spec that struct-class duping produces identical method tables.
Browse files Browse the repository at this point in the history
This could be expanded into a full set of dup/clone specs, or
the Class#dup/clone specs could be expanded to also test other
types of "weird" classes like structs and prepends.

For #3686
headius committed Apr 28, 2016
1 parent 74d5312 commit a4323b3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/ruby/core/struct/dup_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

describe "Struct-based class#dup" do

# From https://github.com/jruby/jruby/issues/3686
it "retains an included module in the ancestor chain for the struct's singleton class" do
klass = Struct.new(:foo)
mod = Module.new do
def hello
"hello"
end
end

klass.extend(mod)
klass_dup = klass.dup
klass_dup.hello.should == "hello"
end

end

0 comments on commit a4323b3

Please sign in to comment.