summaryrefslogtreecommitdiff
path: root/spec/ruby/core/struct/shared
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/struct/shared')
-rw-r--r--spec/ruby/core/struct/shared/dup.rb9
-rw-r--r--spec/ruby/core/struct/shared/equal_value.rb7
-rw-r--r--spec/ruby/core/struct/shared/inspect.rb5
3 files changed, 16 insertions, 5 deletions
diff --git a/spec/ruby/core/struct/shared/dup.rb b/spec/ruby/core/struct/shared/dup.rb
new file mode 100644
index 0000000000..994f3f443e
--- /dev/null
+++ b/spec/ruby/core/struct/shared/dup.rb
@@ -0,0 +1,9 @@
+describe :struct_dup, shared: true do
+ it "duplicates members" do
+ klass = Struct.new(:foo, :bar)
+ instance = klass.new(14, 2)
+ duped = instance.send(@method)
+ duped.foo.should == 14
+ duped.bar.should == 2
+ end
+end
diff --git a/spec/ruby/core/struct/shared/equal_value.rb b/spec/ruby/core/struct/shared/equal_value.rb
index 711862cb44..a7e0856df5 100644
--- a/spec/ruby/core/struct/shared/equal_value.rb
+++ b/spec/ruby/core/struct/shared/equal_value.rb
@@ -16,6 +16,13 @@ describe :struct_equal_value, shared: true do
car.send(@method, different_car).should == false
end
+ it "returns false if other is of a different class" do
+ car = StructClasses::Car.new("Honda", "Accord", "1998")
+ klass = Struct.new(:make, :model, :year)
+ clone = klass.new("Honda", "Accord", "1998")
+ car.send(@method, clone).should == false
+ end
+
it "handles recursive structures by returning false if a difference can be found" do
x = StructClasses::Car.new("Honda", "Accord", "1998")
x[:make] = x
diff --git a/spec/ruby/core/struct/shared/inspect.rb b/spec/ruby/core/struct/shared/inspect.rb
deleted file mode 100644
index 90594a5452..0000000000
--- a/spec/ruby/core/struct/shared/inspect.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-describe :struct_inspect, shared: true do
- it "returns a string representation without the class name for anonymous structs" do
- Struct.new(:a).new("").send(@method).should == '#<struct a="">'
- end
-end